Simplest way to display notifications in flutter?

Viewed 1315

How can I show notifications in a Flutter app?

I've tried various packages like flutter_local_notifications and awesome_notifications. But I am unable to use them properly.

Also, I want simple and local notifications. So cloud notifications are not really suitable for my need.

1 Answers

One of the easiest way to have local notifications on an app is to use the Toast library. It is very popular due to ease of use, few bugs across platforms and many recent code examples.

Only caveat: Please check that the look and feel of toast is what you have in mind. By default it is a notification that pops out at the bottom of the screen. (You can override default behavior but that requires more code ex:How to display Toast at center of screen)

The only "difficulty" of toast is that you might have to deal with state at the widget level (maybe inter- widget but that can be avoided in many use cases). The example given is pretty self explanatory imho. https://pub.dev/packages/fluttertoast/example

If not enough from official doc, or want stateless examples, feel free to check this link on SO. How to create Toast in Flutter? One of the 31 answers in there should be a code that should be pretty close to something you are comfortable with.

Now here is a list of other type of notifications. If toast does not suit your UX/UI needs, this might give you ideas. https://ux.stackexchange.com/questions/91406/what-is-the-difference-between-alert-notification-banner-and-toast-message

Related