-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Description
Steps to reproduce
There is a very weird behavior when showing a SnackBar from inside the new CupertinoSheet. The snackbar appears to be truncated.
I also noticed that if the showCupertinoSheet is called from a Scaffold, when the SnackBar is on screen(truncated) and we long press anywhere on the sheet, the SnackBar is fully shown as long as we don't release the press.
If the widget where showCupertinoSheet is called doesn't have a Scaffold, the SnackBar is only truncated.
Since it appears it's two bugs (not sure if they are related) I will provide two reproduction steps:
Steps to reproduce Bug 1
- Run sample app
- Press "Show CupertinoSheet" button
- Press "Show SnackBar" button inside the sheet
- SnackBar appears but mostly truncated
Steps to reproduce Bug 2
- Long press anywhere on the sheet while SnackBar is visible but truncated
- SnackBar appears normally
- Release long press
- SnackBar goes back to being mostly truncated
When using showModalBottomSheet, the SnackBar behaves normally.
Reproducible on iPhone Simulator, real physical iPhone. Didn't tried it on Android
Expected results
I expect the SnackBar to appear normally like in any other bottom sheet.
Actual results
SnackBar is truncated.
SnackBar reacts to long press anywhere on the sheet and becomes fully visible (Only when showCupertinoSheet is called from a widget that contains a Scaffold
Code sample
Code sample
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
final scaffoldKey = GlobalKey<ScaffoldMessengerState>();
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
scaffoldMessengerKey: scaffoldKey,
home: const TestHome(),
);
}
}
class TestHome extends StatefulWidget {
const TestHome({super.key});
@override
State<TestHome> createState() => _TestHomeState();
}
class _TestHomeState extends State<TestHome> {
void _onShowCupertinoSheet() {
showCupertinoSheet(
context: context,
pageBuilder: (context) => MySheet("CupertinoSheet"),
);
}
void _onShowModalBottomSheet() {
showModalBottomSheet(
context: context,
builder: (context) => MySheet("ModalBottomSheet"),
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
FilledButton(
onPressed: _onShowCupertinoSheet,
child: Text("Show CupertinoSheet"),
),
FilledButton(
onPressed: _onShowModalBottomSheet,
child: Text("Show ModalBottomSheet"),
),
],
),
),
);
}
}
class MySheet extends StatelessWidget {
const MySheet(this.showing, {super.key});
final String showing;
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text("Showing $showing"),
FilledButton(
onPressed: () {
scaffoldKey.currentState?.showSnackBar(
SnackBar(
content: Text("SnackBar"),
backgroundColor: Colors.red,
),
);
},
child: Text("Show SnackBar"),
),
],
),
),
);
}
}
Screenshots or Video
Screenshots / Video demonstration
SnackBar_Bug.mov
Logs
Logs
[Paste your logs here]Flutter Doctor output
Doctor output
[✓] Flutter (Channel stable, 3.29.0, on macOS 15.3.1 24D70 darwin-arm64, locale en-US) [1,282ms]
• Flutter version 3.29.0 on channel stable at /Users/jamilsaadeh/Documents/dev/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 35c388afb5 (8 days ago), 2025-02-10 12:48:41 -0800
• Engine revision f73bfc4522
• Dart version 3.7.0
• DevTools version 2.42.2
[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0-rc4) [4.2s]
• Android SDK at /Users/jamilsaadeh/Library/Android/sdk
• Platform android-35, build-tools 35.0.0-rc4
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
This is the JDK bundled with the latest Android Studio installation on this machine.
To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
• Java version OpenJDK Runtime Environment (build 21.0.4+-12422083-b607.1)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 16.2) [1,106ms]
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 16C5032a
• CocoaPods version 1.16.2
[✓] Chrome - develop for the web [10ms]
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2024.2) [10ms]
• Android Studio at /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 21.0.4+-12422083-b607.1)
[✓] VS Code (version 1.97.2) [8ms]
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.104.0
[✓] Connected device (4 available) [11.6s]
• iPhone 16 (mobile) • 965615FC-8FBE-49A7-8B99-081DCE7F5247 • ios •
com.apple.CoreSimulator.SimRuntime.iOS-18-0 (simulator)
• macOS (desktop) • macos • darwin-arm64 • macOS 15.3.1 24D70 darwin-arm64
• Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin • macOS 15.3.1 24D70 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 133.0.6943.99
! Error: Browsing on the local area network for J.S. Ensure the device is unlocked and attached with a cable or associated
with the same local area network as this Mac.
The device must be opted into Developer Mode to connect wirelessly. (code -27)
[✓] Network resources [328ms]
• All expected network resources are available.
• No issues found!