Skip to content

SnackBarBehavior.floating works improperly with FloatingActionButtonLocation.endContained and M3 theme #136162

Closed

Description

@CaLouro

Is there an existing issue for this?

Steps to reproduce

  1. Use Material 3 theming;
  2. Create a view with Scaffold containing a BottomAppBar on the bottomNavigationBar attribute;
  3. Have a FAB with FloatingActionButtonLocation.endContained on the same Scaffold;
  4. Display a SnackBar with the floating behaviour;
  5. SnackBar doesn't look floating.

Expected results

SnackBar is expected to look like the screenshot

Floating SnackBar

Actual results

SnackBar does not look floating and seems to touch the BottomAppBar

Wrong Floating SnackBar

Code sample

Code sample
import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData(
        colorSchemeSeed: Colors.green,
        useMaterial3: true,
      ),
      home: const MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key});

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      floatingActionButton: FloatingActionButton(
        onPressed: () {},
        child: const Icon(Icons.add),
      ),
      floatingActionButtonLocation: FloatingActionButtonLocation.endContained,
      bottomNavigationBar: const BottomAppBar(),
      body: Center(
        child: ElevatedButton(
          onPressed: () {
            ScaffoldMessenger.of(context).showSnackBar(
              const SnackBar(
                content: Text('Content'),
                behavior: SnackBarBehavior.floating,
              ),
            );
          },
          child: const Text('Show SnackBar'),
        ),
      ),
    );
  }
}

Screenshots or Video

Same screenshots from above for side-by-side comparison

Screenshots / Video demonstration
Right looking SnackBar Wrong looking SnackBar
Floating SnackBar Wrong Floating SnackBar

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output (stable)
[✓] Flutter (Channel stable, 3.13.6, on Microsoft Windows [Version 10.0.22621.2283], locale en-CA)
    • Flutter version 3.13.6 on channel stable at C:\Users\Caio\Tools\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision ead455963c (12 days ago), 2023-09-26 18:28:17 -0700
    • Engine revision a794cf2681
    • Dart version 3.1.3
    • DevTools version 2.25.0

[✓] Windows Version (Installed version of Windows is version 10 or higher)

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
    • Android SDK at C:\Users\Caio\AppData\Local\Android\sdk
    • Platform android-33, build-tools 33.0.2
    • Java binary at: C:\Program Files\Android\Android Studio\jbr\bin\java
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-b2043.56-10027231)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[✗] Visual Studio - develop Windows apps
    ✗ Visual Studio not installed; this is necessary to develop Windows apps.
      Download at https://visualstudio.microsoft.com/downloads/.
      Please install the "Desktop development with C++" workload, including all of its default components

[✓] Android Studio (version 2022.3)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-b2043.56-10027231)

[✓] VS Code (version 1.82.2)
    • VS Code at C:\Users\Caio\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.64.0

[✓] Connected device (4 available)
    • sdk gphone x86 64 (mobile) • emulator-5554 • android-x64    • Android 13 (API 33) (emulator)
    • Windows (desktop)          • windows       • windows-x64    • Microsoft Windows [Version 10.0.22621.2283]
    • Chrome (web)               • chrome        • web-javascript • Google Chrome 117.0.5938.134
    • Edge (web)                 • edge          • web-javascript • Microsoft Edge 117.0.2045.60

[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 1 category.

Activity

  1. danagbemava-nc commented on Oct 9, 2023

    @danagbemava-nc
    Member

    Reproducible using the code sample provided above.

    flutter doctor -v
    [!] Flutter (Channel stable, 3.13.6, on macOS 14.0 23A344 darwin-arm64, locale en-GB)
        • Flutter version 3.13.6 on channel stable at /Users/nexus/dev/sdks/flutter
        ! Warning: `flutter` on your path resolves to /Users/nexus/dev/sdks/flutters/bin/flutter, which is not inside your current Flutter SDK checkout at /Users/nexus/dev/sdks/flutter. Consider adding /Users/nexus/dev/sdks/flutter/bin to the front of your path.
        ! Warning: `dart` on your path resolves to /Users/nexus/dev/sdks/flutters/bin/dart, which is not inside your current Flutter SDK checkout at /Users/nexus/dev/sdks/flutter. Consider adding /Users/nexus/dev/sdks/flutter/bin to the front of your path.
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision ead455963c (12 days ago), 2023-09-26 18:28:17 -0700
        • Engine revision a794cf2681
        • Dart version 3.1.3
        • DevTools version 2.25.0
        • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
        • Android SDK at /Users/nexus/Library/Android/sdk
        • Platform android-33, build-tools 33.0.1
        • Java binary at: /Users/nexus/Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 15.0)
        • Xcode at /Applications/Xcode-15.0.0-Release.Candidate.app/Contents/Developer
        • Build 15A240d
        • CocoaPods version 1.13.0
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 2022.3)
        • Android Studio at /Users/nexus/Applications/Android Studio.app/Contents
        • Flutter plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/9212-flutter
        • Dart plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/6351-dart
        • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)
    
    [✓] IntelliJ IDEA Ultimate Edition (version 2023.2.2)
        • IntelliJ at /Users/nexus/Applications/IntelliJ IDEA Ultimate.app
        • Flutter plugin version 75.1.4
        • Dart plugin version 232.9559.10
    
    [✓] VS Code (version 1.83.0)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.74.0
    
    [✓] Connected device (5 available)
        • 28291FDH2001SA (mobile) • 28291FDH2001SA            • android-arm    • Android null (API null)
        • Nexus (mobile)          • 00008020-001875E83A38002E • ios            • iOS 17.0.3 21A360
        • Dean’s iPad (mobile)    • 00008103-000825C811E3401E • ios            • iOS 17.0.3 21A360
        • macOS (desktop)         • macos                     • darwin-arm64   • macOS 14.0 23A344 darwin-arm64
        • Chrome (web)            • chrome                    • web-javascript • Google Chrome 117.0.5938.149
    
    [✓] Network resources
        • All expected network resources are available.
    
    ! Doctor found issues in 1 category.
    
    [✓] Flutter (Channel master, 3.16.0-6.0.pre.39, on macOS 14.0 23A344 darwin-arm64, locale en-GB)
        • Flutter version 3.16.0-6.0.pre.39 on channel master at /Users/nexus/dev/sdks/flutters
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision e27dc0a3f5 (6 hours ago), 2023-10-08 22:51:26 -0400
        • Engine revision e58a9b3c54
        • Dart version 3.3.0 (build 3.3.0-1.0.dev)
        • DevTools version 2.28.1
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
        • Android SDK at /Users/nexus/Library/Android/sdk
        • Platform android-33, build-tools 33.0.1
        • Java binary at: /Users/nexus/Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 15.0)
        • Xcode at /Applications/Xcode-15.0.0-Release.Candidate.app/Contents/Developer
        • Build 15A240d
        • CocoaPods version 1.13.0
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 2022.3)
        • Android Studio at /Users/nexus/Applications/Android Studio.app/Contents
        • Flutter plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/9212-flutter
        • Dart plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/6351-dart
        • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)
    
    [✓] IntelliJ IDEA Ultimate Edition (version 2023.2.2)
        • IntelliJ at /Users/nexus/Applications/IntelliJ IDEA Ultimate.app
        • Flutter plugin version 75.1.4
        • Dart plugin version 232.9559.10
    
    [✓] VS Code (version 1.83.0)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.74.0
    
    [✓] Connected device (5 available)
        • 28291FDH2001SA (mobile) • 28291FDH2001SA            • android-arm    • Android null (API null)
        • Nexus (mobile)          • 00008020-001875E83A38002E • ios            • iOS 17.0.3 21A360
        • Dean’s iPad (mobile)    • 00008103-000825C811E3401E • ios            • iOS 17.0.3 21A360
        • macOS (desktop)         • macos                     • darwin-arm64   • macOS 14.0 23A344 darwin-arm64
        • Chrome (web)            • chrome                    • web-javascript • Google Chrome 117.0.5938.149
    
    [✓] Network resources
        • All expected network resources are available.
    
    • No issues found!
    
  2. added
    frameworkflutter/packages/flutter repository. See also f: labels.
    p: material_uimaterial_ui package in flutter/packages
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    team-designOwned by Design Languages team
    and removed
    in triagePresently being triaged by the triage team
    on Oct 9, 2023
  3. changed the title [-]SnackBarBehavior.floating works inproperly with FloatingActionButtonLocation.endContained and M3 theme[/-] [+]SnackBarBehavior.floating works improperly with FloatingActionButtonLocation.endContained and M3 theme[/+] on Oct 11, 2023
  4. added
    P2Important issues not at the top of the work list
    triaged-designTriaged by Design Languages team
    on Oct 11, 2023
  5. added a commit that references this issue on Oct 12, 2023
    6388e3d
  6. github-actions commented on Oct 26, 2023

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  7. locked as resolved and limited conversation to collaborators on Oct 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work listfound in release: 3.13Found to occur in 3.13found in release: 3.16Found to occur in 3.16frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onp: material_uimaterial_ui package in flutter/packagesr: fixedIssue is closed as already fixed in a newer versionteam-designOwned by Design Languages teamtriaged-designTriaged by Design Languages team

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions