How To Add Snackbars In Flutter

Google's Android 11 splash screen at the same time the maker of material design which is today's blog about how to add snackbars in flutter.
Credit to: unsplash.com | Mika Baumeister

Snacks are great when we’re on a break working on projects in Flutter, but today’s topic isn’t about food but about a user interface that, consequently enough, the people at Google called it snackbars. Basically, a Snackbar informs users of a process that an app has performed or will perform. They appear temporarily, towards the bottom of the screen. They shouldn’t interrupt the user experience, and they don’t require user input to disappear.

Things you need to know before using snackbars In flutter

Snackbars provide updates on an app’s processes. Snackbars appear temporarily, and disappear on their own without requiring user input. Only one snackbar may be displayed at a time. “Dismiss” or “cancel” actions are optional; you should only use them when you need to communicate messages that are minimally interruptive and don’t require action.

Snackbars Fundamental

They can show a text label related to the program’s process or a basic text button that allows users to take action on what the app performs. Snackbars are displayed in grey-colored rectangular containers. Above all, Snackbars should not be the only means to reach a core use case or make an app usable.

Snackbars Code In Flutter

SnackBar(
  behavior: SnackBarBehavior.floating,
  content: Text('Text label'),
  action: SnackBarAction(
    label: 'Action',
    onPressed: () {},
  ),
)

Conclusion

On this blog, we learned that snackbars appear temporarily, and disappear on their own without requiring user input. “Dismiss” or “cancel” actions are optional; you should only use them when you need to communicate messages that are minimally interruptive and don’t require action. You can always visit the official documentation here because in the future, Google might update snackbars and this blog would become outdated. There are more flutter blogs I am going to create. You can always visit here. Thank you for reading. If you found this useful, please share it with your friends and family. 

Leave a Comment

Your email address will not be published. Required fields are marked *