Unverified Commit 135bb5d4 authored by Kate Lovett's avatar Kate Lovett Committed by GitHub

Remove deprecated Scaffold SnackBar API (#98549)

parent 1cf5c740
......@@ -122,7 +122,7 @@ class _SnackBarActionState extends State<SnackBarAction> {
_haveTriggeredAction = true;
});
widget.onPressed();
Scaffold.of(context).hideCurrentSnackBar(reason: SnackBarClosedReason.action);
ScaffoldMessenger.of(context).hideCurrentSnackBar(reason: SnackBarClosedReason.action);
}
@override
......@@ -583,14 +583,14 @@ class _SnackBarState extends State<SnackBar> {
container: true,
liveRegion: true,
onDismiss: () {
Scaffold.of(context).removeCurrentSnackBar(reason: SnackBarClosedReason.dismiss);
ScaffoldMessenger.of(context).removeCurrentSnackBar(reason: SnackBarClosedReason.dismiss);
},
child: Dismissible(
key: const Key('dismissible'),
direction: widget.dismissDirection,
resizeDuration: null,
onDismissed: (DismissDirection direction) {
Scaffold.of(context).removeCurrentSnackBar(reason: SnackBarClosedReason.swipe);
ScaffoldMessenger.of(context).removeCurrentSnackBar(reason: SnackBarClosedReason.swipe);
},
child: snackBar,
),
......
......@@ -263,8 +263,10 @@ void main() {
),
),
));
// The Scaffold should assert we still have an ancestor ScaffoldMessenger in
// order to dismiss the SnackBar from the ScaffoldMessenger.
// Tap SnackBarAction to dismiss.
// The SnackBarAction should assert we still have an ancestor
// ScaffoldMessenger in order to dismiss the SnackBar from the
// Scaffold.
await tester.tap(find.text('Test'));
FlutterError.onError = oldHandler;
......@@ -286,11 +288,67 @@ void main() {
expect(error.toStringDeep(), equalsIgnoringHashCodes(
'FlutterError\n'
' No ScaffoldMessenger widget found.\n'
' Scaffold widgets require a ScaffoldMessenger widget ancestor.\n'
' SnackBarAction widgets require a ScaffoldMessenger widget\n'
' ancestor.\n'
' The specific widget that could not find a ScaffoldMessenger\n'
' ancestor was:\n'
' Scaffold-[LabeledGlobalKey<ScaffoldState>#00829]\n'
' SnackBarAction\n'
' The ancestors of this widget were:\n'
' TextButtonTheme\n'
' Padding\n'
' Row\n'
' Padding\n'
' MediaQuery\n'
' Padding\n'
' SafeArea\n'
' FadeTransition\n'
' IconTheme\n'
' IconTheme\n'
' _InheritedCupertinoTheme\n'
' CupertinoTheme\n'
' _InheritedTheme\n'
' Theme\n'
' DefaultTextStyle\n'
' AnimatedDefaultTextStyle\n'
' _InkFeatures-[GlobalKey#00000 ink renderer]\n'
' NotificationListener<LayoutChangedNotification>\n'
' PhysicalModel\n'
' AnimatedPhysicalModel\n'
' Material\n'
' FractionalTranslation\n'
' SlideTransition\n'
' Listener\n'
' _GestureSemantics\n'
' RawGestureDetector\n'
' GestureDetector\n'
" Dismissible-[<'dismissible'>]\n"
' Semantics\n'
' Align\n'
' AnimatedBuilder\n'
' ClipRect\n'
' KeyedSubtree-[GlobalKey#00000]\n'
' _EffectiveTickerMode\n'
' TickerMode\n'
' Offstage\n'
' SizedBox\n'
' Hero\n'
' SnackBar-[#00000]\n'
' MediaQuery\n'
' LayoutId-[<_ScaffoldSlot.snackBar>]\n'
' CustomMultiChildLayout\n'
' AnimatedBuilder\n'
' DefaultTextStyle\n'
' AnimatedDefaultTextStyle\n'
' _InkFeatures-[GlobalKey#00000 ink renderer]\n'
' NotificationListener<LayoutChangedNotification>\n'
' PhysicalModel\n'
' AnimatedPhysicalModel\n'
' Material\n'
' _ScrollMetricsNotificationObserverScope\n'
' NotificationListener<ScrollMetricsNotification>\n'
' ScrollMetricsNotificationObserver\n'
' _ScaffoldScope\n'
' Scaffold-[LabeledGlobalKey<ScaffoldState>#00000]\n'
' MediaQuery\n'
' Directionality\n'
' [root]\n'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment