Skip to content

SnackBarBehavior.floating does not account for safe area #64194

@Piinks

Description

@Piinks

SnackBars can contain actions, which are interactive so should be placed within a safe area. The placement of a floating SnackBar does not appear to fall within a safe interactive area. SnackBarBehavior.fixed looks ok.
This placement is calculated by the Scaffold, so that is where we probably need to fix this.

Here's a comparison of fixed -v- floating in debug paint:

Untitled drawing (1)

import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      home: Scaffold(
        appBar:  AppBar(title: Text('Demo')),
        body: Builder(
          builder: (BuildContext context) {
            return FloatingActionButton(
              onPressed: () {
                Scaffold.of(context).showSnackBar(SnackBar(
                  // Toggle different behaviors with debug paint on
                  // to see if we're laying out within the SafeArea.
                  // behavior: SnackBarBehavior.floating,
                  content: Text('Am I in a SafeArea?'),
                  action: SnackBarAction(label: 'PRESS', onPressed: () {})),
                );
              },
              child: Icon(Icons.add),
            );
          }
        )
      )
    );
  }
}

flutter doctor -v

[✓] Flutter (Channel master, 1.21.0-10.0.pre.173, on Mac OS X 10.15.5 19F101,
    locale en-US)
    • Flutter version 1.21.0-10.0.pre.173 at /Users/katelovett/github/flutter
    • Framework revision d981fafe8b (77 minutes ago), 2020-08-19 16:41:08 -0400
    • Engine revision 8177937133
    • Dart version 2.10.0 (build 2.10.0-45.0.dev)


[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    • Android SDK at /Users/katelovett/Library/Android/sdk
    • Platform android-28, build-tools 28.0.3
    • Java binary at: /Applications/Android
      Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build
      1.8.0_212-release-1586-b4-5784211)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 11.3.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.3.1, Build version 11C505
    • CocoaPods version 1.8.4

[✓] Android Studio (version 3.6)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 44.0.2
    • Dart plugin version 192.7761
    • Java version OpenJDK Runtime Environment (build
      1.8.0_212-release-1586-b4-5784211)

[✓] VS Code (version 1.47.3)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.13.2

[✓] Connected device (1 available)
    • iPhone 11 Pro Max (mobile) • 76F7404B-2863-4D33-AF5D-5404C0678B24 • ios •
      com.apple.CoreSimulator.SimRuntime.iOS-13-3 (simulator)

• No issues found!

Metadata

Metadata

Assignees

Labels

a: qualityA truly polished experiencec: regressionIt was better in the past than it is nowf: material designflutter/packages/flutter/material repository.frameworkflutter/packages/flutter repository. See also f: labels.waiting for PR to land (fixed)A fix is in flight

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions