Skip to content

Can't click on the items under the snackbar with margin #78537

@lsaudon

Description

@lsaudon

Steps to Reproduce

import 'package:flutter/material.dart';

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

class MyApp extends StatefulWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  final GlobalKey<ScaffoldMessengerState> scaffoldMessengerKey =
      GlobalKey<ScaffoldMessengerState>();

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData(useMaterial3: true),
      home: ScaffoldMessenger(
        key: scaffoldMessengerKey,
        child: Scaffold(
          appBar: AppBar(),
          body: Center(
            child: Column(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              crossAxisAlignment: CrossAxisAlignment.stretch,
              children: [
                ElevatedButton(
                  onPressed: () {
                    scaffoldMessengerKey.currentState!.showSnackBar(
                      const SnackBar(
                        behavior: SnackBarBehavior.floating,
                        width: 300,
                        content: Text('Snackbar with width'),
                      ),
                    );
                  },
                  child: const Text('Show snackbar with width'),
                ),
                ElevatedButton(
                  onPressed: () {
                    scaffoldMessengerKey.currentState!.showSnackBar(
                      const SnackBar(
                        behavior: SnackBarBehavior.floating,
                        margin: EdgeInsets.fromLTRB(0, 0, 300, 0),
                        content: Text('Snackbar with margin'),
                      ),
                    );
                  },
                  child: const Text('Show snackbar with margin'),
                ),
                ElevatedButton(
                  onPressed: () {
                    print('onPressed');
                  },
                  child: const Text('Try press me'),
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}

Expected results:

The button below the snackbar cannot be clicked when decreasing the size of the snackbar via the margin.
This works when you decrease the size with the width.

Actual results:

Be able to click on the button below the snackbar when decreasing the size of the snackbar via the margin.
This works when you decrease the size with the width.

Logs
[+10475 ms] I/ViewRootImpl@1de61f0[MainActivity]( 4048): ViewPostIme pointer 0
[ +105 ms] I/ViewRootImpl@1de61f0[MainActivity]( 4048): ViewPostIme pointer 1
[ +995 ms] I/ViewRootImpl@1de61f0[MainActivity]( 4048): ViewPostIme pointer 0
[ +171 ms] I/ViewRootImpl@1de61f0[MainActivity]( 4048): ViewPostIme pointer 1
[ +445 ms] I/ViewRootImpl@1de61f0[MainActivity]( 4048): ViewPostIme pointer 0
[ +114 ms] I/ViewRootImpl@1de61f0[MainActivity]( 4048): ViewPostIme pointer 1
[+1059 ms] I/ViewRootImpl@1de61f0[MainActivity]( 4048): ViewPostIme pointer 0
[ +149 ms] I/ViewRootImpl@1de61f0[MainActivity]( 4048): ViewPostIme pointer 1
Analyzing poc...                                                        
No issues found! (ran in 2.0s)
[✓] Flutter (Channel stable, 1.22.6, on macOS 11.2.3 20D91 darwin-x64, locale fr-FR)
    • Flutter version 1.22.6 at /Users/lsaudon/development/flutter
    • Framework revision 9b2d32b605 (il y a 8 semaines), 2021-01-22 14:36:39 -0800
    • Engine revision 2f0af37152
    • Dart version 2.10.5

 
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at /Users/lsaudon/Library/Android/sdk
    • Platform android-30, build-tools 30.0.2
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 12.4)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.4, Build version 12D4e
    • CocoaPods version 1.9.3

[!] Android Studio (version 4.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)

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

[✓] Connected device (1 available)
    • SM T500 (mobile) • R9WNB0YFZCJ • android-arm64 • Android 10 (API 29)

! Doctor found issues in 1 category.

Metadata

Metadata

Assignees

No one assigned

    Labels

    f: material designflutter/packages/flutter/material repository.found in release: 3.0Found to occur in 3.0found in release: 3.1Found to occur in 3.1frameworkflutter/packages/flutter repository. See also f: labels.has partial patchThere is a PR awaiting someone to take it across the finish linehas reproducible stepsThe issue has been confirmed reproducible and is ready to work onr: 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