toast function

void toast (
  1. String message,
  2. {Duration duration: Toast.LENGTH_SHORT}
)

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}) {
  if (duration <= Duration.zero) {
    //fast fail
    return;
  }

  showOverlay((context, t) {
    return Opacity(opacity: t, child: _Toast(content: Text(message)));
  }, curve: Curves.ease, key: const ValueKey('overlay_toast'), duration: duration);
}