Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Flutter and app store releases

'Floating SnackBar presented off screen' assertion in a Scaffold

ErrorFloating SnackBar presented off screen.

Short answer

A floating SnackBar is placed above the Scaffold's bottom widgets. The debug check fails when its top edge would land above the screen. The floating action button, persistentFooterButtons, bottomNavigationBar or the SnackBar itself is taking too much height. Shrink the widget that is too tall.

  • Applies to Flutter 3.3x, Dart 3.x
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Find which of the Scaffold's bottom widgets are set, then check how tall each is. The error names floatingActionButton, persistentFooterButtons and bottomNavigationBar as the usual users of the space.

    grep -rn "floatingActionButton\|persistentFooterButtons\|bottomNavigationBar\|SnackBarBehavior.floating" lib
  2. 2Match what you see, then jump to its fix

    1. 1Floating SnackBar presented off screen, and the screen has a large bottom bar or footerbottomNavigationBar or persistentFooterButtons is too tallFix
    2. 2Floating SnackBar presented off screen, only on screens with a FABAn oversized floating action buttonFix
    3. 3Floating SnackBar presented off screen after a long messageThe SnackBar content is itself taller than the free spaceFix

What does the error look like?

  • Floating SnackBar presented off screen.
  • Consider constraining the size of these widgets to allow room for the SnackBar to be visible.

Cause 1 of 3

bottomNavigationBar or persistentFooterButtons is too tall

1Check

A floating SnackBar appears above other Scaffold widgets, including a bottom navigation bar. If these take too much of the height, the snack bar cannot fit above them.

grep -rn "bottomNavigationBar\|persistentFooterButtons" lib

2Fix

Constrain the height of the bottom widget, for example in small landscape layouts.

bottomNavigationBar: ConstrainedBox(
  constraints: const BoxConstraints(maxHeight: 80),
  child: const MyNavBar(),
),

3Verify

Show the SnackBar again.

ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: Text('Saved'), behavior: SnackBarBehavior.floating));

Confirmed by raw.githubusercontent.com

Did this fix it?

Cause 2 of 3

An oversized floating action button

1Check

The SnackBar is positioned from the top edge of the floating action button when it is shown above it. A very tall FAB or a custom widget placed as the FAB moves that edge up.

grep -rn "floatingActionButton" lib

2Fix

Keep the FAB within its normal size, or constrain the widget you pass as floatingActionButton.

floatingActionButton: SizedBox(
  height: 56,
  child: FloatingActionButton(onPressed: onAdd, child: const Icon(Icons.add)),
),

3Verify

Hot restart, show the SnackBar and watch the debug console for the assertion.

ScaffoldMessenger.of(context).showSnackBar(snackBar);

Confirmed by api.flutter.dev

Did this fix it?

Cause 3 of 3

The SnackBar content is itself taller than the free space

1Check

The check fails when the SnackBar's top edge (its base position minus its own height) would be negative. A long multi-line message on a screen with little free height can cause that.

grep -rn "SnackBar(" lib

2Fix

Shorten the message and limit its lines.

SnackBar(
  behavior: SnackBarBehavior.floating,
  content: const Text('Saved', maxLines: 2, overflow: TextOverflow.ellipsis),
)

3Verify

Show the same SnackBar on the smallest screen you support.

ScaffoldMessenger.of(context).showSnackBar(snackBar);

Confirmed by raw.githubusercontent.com

Did this fix it?

How do I stop it coming back?

  • Test SnackBars on the smallest screen and in landscape, not only on a tall phone.
  • Keep bottom bars and footers at their standard heights.
  • Keep SnackBar messages short.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.