I’m using a CupertinoModalPopup with a CupertinoActionSheet widget to display a set of options for the user to choose from.
I intend to show a loading indicator followed by a checkmark(tick) to
give the use the impression that he has clicked the option and it is
saved after popping out using Navingator.pop(context).
First , I’m attempting to do this with a delay of 50 milliseconds using
Future.delayed after clicking onPressed
using only a Widget that displays a checkmark tick. But it isn’t working.
Here is my code to better explain what I’m doing. Only relevant code is published.
@override
Widget build(BuildContext context) {
return CupertinoActionSheet(
actions: <Widget>[
Container(
color: Colors.white,
child: CupertinoActionSheetAction(
// A loading indicator(100 milliseconds) followed by a checkmark(50 milliseconds) will appear after clicking on actions onPressed to give the user an impression that its a success.
onPressed: ({int index = 0}) async {
await Future.delayed(const Duration(milliseconds: 100), () {
setState(() {
VideosSoundSetting newType =
allVideosSoundSettings[index];
widget.onTypeChanged(newType);
const ListTile(
trailing: KNIcon(KNIcons.check),
);
Navigator.pop(context);
});
});
},
child: KNText(
style: TextStyle(color: Colors.black),
'Enabled',
),
)),
Container()],
cancelButton: Container());
)
);
}
What is working :
The options and selection does work with a delay in milliseconds as specified
What doesn’t :
The checkmark tick at the very end of ‘Enabled’ action doesn’t appear
despite me calling a ListTile with a trailing widget(checkmark).
After fixing the checkmark tick , I intend to call a loading indicator widget with a delayed duration after which the checkmark should appear and popout.
If I could be pointed in the right direction of how best to achieve the above goal of
- Loading indicator with a delay of 100 milliseconds.
- Checkmark Tick appearing immediately after the loading indicator in the same place and popping out after 50 milliseconds