Fix SnackBar material clip (#125622)
fixes https://github.com/flutter/flutter/issues/125619 ### Before  ### After 
This commit is contained in:
@@ -728,6 +728,7 @@ class _SnackBarState extends State<SnackBar> {
|
||||
shape: shape,
|
||||
elevation: elevation,
|
||||
color: backgroundColor,
|
||||
clipBehavior: widget.clipBehavior,
|
||||
child: Theme(
|
||||
data: effectiveTheme,
|
||||
child: accessibleNavigation || theme.useMaterial3
|
||||
|
||||
@@ -2857,6 +2857,50 @@ testWidgets('SnackBarAction backgroundColor works as a Color', (WidgetTester tes
|
||||
contains('disabledBackgroundColor must not be provided when background color is a MaterialStateColor'))
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('SnackBar material applies SnackBar.clipBehavior', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: Container(),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
final ScaffoldMessengerState scaffoldMessengerState = tester.state(find.byType(ScaffoldMessenger));
|
||||
scaffoldMessengerState.showSnackBar(
|
||||
const SnackBar(content: Text('I am a snack bar.')),
|
||||
);
|
||||
|
||||
await tester.pumpAndSettle(); // Have the SnackBar fully animate out.
|
||||
|
||||
Material material = tester.widget<Material>(
|
||||
find.descendant(of: find.byType(SnackBar),
|
||||
matching: find.byType(Material))
|
||||
);
|
||||
|
||||
expect(material.clipBehavior, Clip.hardEdge);
|
||||
|
||||
scaffoldMessengerState.hideCurrentSnackBar(); // Hide the SnackBar.
|
||||
|
||||
await tester.pumpAndSettle(); // Have the SnackBar fully animate out.
|
||||
|
||||
scaffoldMessengerState.showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text('I am a snack bar.'),
|
||||
clipBehavior: Clip.antiAlias,
|
||||
),
|
||||
);
|
||||
|
||||
await tester.pumpAndSettle(); // Have the SnackBar fully animate in.
|
||||
|
||||
material = tester.widget<Material>(
|
||||
find.descendant(of: find.byType(SnackBar),
|
||||
matching: find.byType(Material))
|
||||
);
|
||||
|
||||
expect(material.clipBehavior, Clip.antiAlias);
|
||||
});
|
||||
}
|
||||
|
||||
/// Start test for "SnackBar dismiss test".
|
||||
|
||||
Reference in New Issue
Block a user