toast function
Popup a message in front of screen.
duration
: the duration to show a toast,
for most situation, you can use Toast.LENGTH_SHORT and Toast.LENGTH_LONG
Implementation
void toast(
String message, {
Duration duration = Toast.LENGTH_SHORT,
BuildContext? context,
}) {
if (duration <= Duration.zero) {
//fast fail
return;
}
showOverlay(
(context, t) {
return IgnorePointer(
child: Opacity(
opacity: t,
child: _Toast(content: Text(message)),
),
);
},
curve: Curves.ease,
key: const ValueKey('overlay_toast'),
duration: duration,
context: context,
);
}