How to create Toast/Snackbar in Flutter.

Officially, Snackbars are the implementation of Toast messages in Flutter. Thus, we will show you how to create Snackbars in Flutter. Creating a Snackbar is simple in Flutter.

Just like Navigation, we will require a ScaffoldState and we will use this to create the Snackbar. The desired code is:-

Scaffold.of(context).showSnackBar(SnackBar(
      content: Text("Hello! this is a SnackBar"),
    ));

You can now use this Snackbar wherever suitable as per your requirement.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.