SnackBar without using scaffold or state key in Flutter


SnackBar is used to show some quick information to the user in Android app. Flutter allows you to use SnackBar with scaffold or ScaffoldState key / Global key.

The Get Framework, dependency management tool, allows you to use SnackBar and without using scaffold. Get has its own dependency /state management system so we need not feel the pain.

So how how do we use it , add the dependency first at yaml file

pubspec.yaml

dependencies:
  flutter:
    sdk: flutter
  get:

import

import 'package:get/get.dart';

import the package and go on with Snackbar

Get.snackbar(title', 'message');

You can use SnackBar options in case miss something. Forget the Scaffold for a while. Get is lightweight ,secure and fast.

You may also interested in these Get tutorials

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

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