2

Is there a way to show a Flutter Snackbar at the top of the screen rather than at the bottom?

According to the docs you can set behaviour: SnackBarBehavior.floating and that raises slightly the snackbar and makes it look a bit like a popup, but it still doesn't provide an option to explicitly set the positioning at the top, for example, right below the action bar.

ccpizza
  • 28,968
  • 18
  • 162
  • 169

2 Answers2

1

Try to use this plugin: flushbar

Flushbar( flushbarPosition: FlushbarPosition.TOP, )

Johnny
  • 367
  • 1
  • 2
  • 12
  • I've seen the `flushbar` plugin before posting the question; would prefer to stick to the standard ootb widgets. – ccpizza Dec 03 '20 at 16:29
0

The answer is described here. Flutter Snakbar- A lightweight message with an optional action which briefly displays at the bottom of the screen.

and I found an alternative flushbar. using flushbar you can change position TOP/BOTTOM.

  Flushbar(
    flushbarPosition: FlushbarPosition.TOP,
    message:
        "Lorem Ipsum is simply dummy text of the printing and typesetting industry",
    duration: Duration(seconds: 3),
  )..show(context);
ajay
  • 808
  • 9
  • 18
  • Flushbar is a 3rd party library. I was looking at ways to do it with the ootb SnackBar, possibly by passing a different `context` object similar to how Snackbar works in android where the Snackbar is anchored to a specific widget. – ccpizza Dec 03 '20 at 16:27
  • @ccpizza I understand what you are looking in to. According to Material design, Snackbars used to provide brief messages about app processes at the bottom of the screen. have a look - [Snackbar](https://material.io/components/snackbars) – ajay Dec 05 '20 at 08:39
  • 1
    yes, i know, yet the android native snackbar can be tweaked to appear on top, eg https://stackoverflow.com/a/31746370/191246 — I was assuming something similar might be possible with flutter. – ccpizza Dec 05 '20 at 09:59
  • The Flushbar is labeled discontinued. If you want another similar package, use this package [another_flushbar](https://pub.dev/packages/another_flushbar) – Iliya Mirzaei Jan 01 '23 at 12:10