snackBar should paint above the bottomSheet (#73558)
This commit is contained in:
@@ -3031,6 +3031,25 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin, Resto
|
||||
'the preferred API instead of the Scaffold methods.'
|
||||
);
|
||||
|
||||
if (_currentBottomSheet != null || _dismissedBottomSheets.isNotEmpty) {
|
||||
final Widget stack = Stack(
|
||||
alignment: Alignment.bottomCenter,
|
||||
children: <Widget>[
|
||||
..._dismissedBottomSheets,
|
||||
if (_currentBottomSheet != null) _currentBottomSheet!._widget,
|
||||
],
|
||||
);
|
||||
_addIfNonNull(
|
||||
children,
|
||||
stack,
|
||||
_ScaffoldSlot.bottomSheet,
|
||||
removeLeftPadding: false,
|
||||
removeTopPadding: true,
|
||||
removeRightPadding: false,
|
||||
removeBottomPadding: _resizeToAvoidBottomInset,
|
||||
);
|
||||
}
|
||||
|
||||
// SnackBar set by ScaffoldMessenger
|
||||
if (_messengerSnackBar != null) {
|
||||
final SnackBarBehavior snackBarBehavior = _messengerSnackBar?._widget.behavior
|
||||
@@ -3110,25 +3129,6 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin, Resto
|
||||
);
|
||||
}
|
||||
|
||||
if (_currentBottomSheet != null || _dismissedBottomSheets.isNotEmpty) {
|
||||
final Widget stack = Stack(
|
||||
alignment: Alignment.bottomCenter,
|
||||
children: <Widget>[
|
||||
..._dismissedBottomSheets,
|
||||
if (_currentBottomSheet != null) _currentBottomSheet!._widget,
|
||||
],
|
||||
);
|
||||
_addIfNonNull(
|
||||
children,
|
||||
stack,
|
||||
_ScaffoldSlot.bottomSheet,
|
||||
removeLeftPadding: false,
|
||||
removeTopPadding: true,
|
||||
removeRightPadding: false,
|
||||
removeBottomPadding: _resizeToAvoidBottomInset,
|
||||
);
|
||||
}
|
||||
|
||||
_addIfNonNull(
|
||||
children,
|
||||
_FloatingActionButtonTransition(
|
||||
|
||||
@@ -2266,4 +2266,29 @@ void main() {
|
||||
final AssertionError error = exceptions.first as AssertionError;
|
||||
expect(error.message, contains('Only one API should be used to manage SnackBars.'));
|
||||
});
|
||||
|
||||
testWidgets('SnackBars should be shown above the bottomSheet', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(const MaterialApp(
|
||||
home: Scaffold(
|
||||
bottomSheet: SizedBox(
|
||||
width: 200,
|
||||
height: 50,
|
||||
child: ColoredBox(
|
||||
color: Colors.pink,
|
||||
),
|
||||
),
|
||||
),
|
||||
));
|
||||
|
||||
final ScaffoldMessengerState scaffoldMessengerState = tester.state(find.byType(ScaffoldMessenger));
|
||||
scaffoldMessengerState.showSnackBar(SnackBar(
|
||||
content: const Text('I love Flutter!'),
|
||||
duration: const Duration(seconds: 2),
|
||||
action: SnackBarAction(label: 'ACTION', onPressed: () {}),
|
||||
behavior: SnackBarBehavior.floating,
|
||||
));
|
||||
await tester.pumpAndSettle(); // Have the SnackBar fully animate out.
|
||||
|
||||
await expectLater(find.byType(MaterialApp), matchesGoldenFile('snack_bar.goldenTest.workWithBottomSheet.png'));
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user