Adjustable timing - Flutter
In Flutter, a SnackBar
is often used display temporary messages. The display duration might be too short for people to read or hear the message.
We recommend displaying messages by using an AlertDialog
. Or, when using a Snackbar
, you can set the duration to "infinite
". Don't forget to add a close button for both options.
Also make sure that the use of time limits, e.g. by using Future.delayed()
, can be extended.
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
duration: const Duration(days: 1),
content: Text('Appt'),
action: SnackBarAction(
label: 'Close',
onPressed: () {
ScaffoldMessenger.of(context).hideCurrentSnackBar();
},
),
));