diff --git a/gallery/gallery/lib/codeviewer/code_segments.dart b/gallery/gallery/lib/codeviewer/code_segments.dart index 32c27cc03..7ac1b9aae 100644 --- a/gallery/gallery/lib/codeviewer/code_segments.dart +++ b/gallery/gallery/lib/codeviewer/code_segments.dart @@ -16737,6 +16737,12 @@ class CodeSegments { TextSpan(style: codeStyle.punctuationStyle, text: '.'), TextSpan(style: codeStyle.baseStyle, text: 'currentState'), TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'hideCurrentSnackBar'), + TextSpan(style: codeStyle.punctuationStyle, text: '();'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a _scaffoldKey'), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'currentState'), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), TextSpan(style: codeStyle.baseStyle, text: 'showSnackBar'), TextSpan(style: codeStyle.punctuationStyle, text: '('), TextSpan(style: codeStyle.classStyle, text: 'SnackBar'), @@ -23656,6 +23662,15 @@ class CodeSegments { TextSpan(style: codeStyle.punctuationStyle, text: '('), TextSpan(style: codeStyle.baseStyle, text: 'context'), TextSpan(style: codeStyle.punctuationStyle, text: ').'), + TextSpan(style: codeStyle.baseStyle, text: 'hideCurrentSnackBar'), + TextSpan(style: codeStyle.punctuationStyle, text: '();'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.classStyle, text: 'Scaffold'), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'of'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan(style: codeStyle.baseStyle, text: 'context'), + TextSpan(style: codeStyle.punctuationStyle, text: ').'), TextSpan(style: codeStyle.baseStyle, text: 'showSnackBar'), TextSpan(style: codeStyle.punctuationStyle, text: '('), TextSpan(style: codeStyle.classStyle, text: 'SnackBar'), @@ -23715,6 +23730,16 @@ class CodeSegments { TextSpan(style: codeStyle.punctuationStyle, text: '('), TextSpan(style: codeStyle.baseStyle, text: 'context'), TextSpan(style: codeStyle.punctuationStyle, text: ').'), + TextSpan(style: codeStyle.baseStyle, text: 'hideCurrentSnackBar'), + TextSpan(style: codeStyle.punctuationStyle, text: '();'), + TextSpan( + style: codeStyle.baseStyle, text: '\u000a '), + TextSpan(style: codeStyle.classStyle, text: 'Scaffold'), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'of'), + TextSpan(style: codeStyle.punctuationStyle, text: '('), + TextSpan(style: codeStyle.baseStyle, text: 'context'), + TextSpan(style: codeStyle.punctuationStyle, text: ').'), TextSpan(style: codeStyle.baseStyle, text: 'showSnackBar'), TextSpan(style: codeStyle.punctuationStyle, text: '('), TextSpan(style: codeStyle.classStyle, text: 'SnackBar'), @@ -24560,6 +24585,12 @@ class CodeSegments { TextSpan(style: codeStyle.punctuationStyle, text: '.'), TextSpan(style: codeStyle.baseStyle, text: 'currentState'), TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'hideCurrentSnackBar'), + TextSpan(style: codeStyle.punctuationStyle, text: '();'), + TextSpan(style: codeStyle.baseStyle, text: '\u000a _scaffoldKey'), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), + TextSpan(style: codeStyle.baseStyle, text: 'currentState'), + TextSpan(style: codeStyle.punctuationStyle, text: '.'), TextSpan(style: codeStyle.baseStyle, text: 'showSnackBar'), TextSpan(style: codeStyle.punctuationStyle, text: '('), TextSpan(style: codeStyle.classStyle, text: 'SnackBar'), diff --git a/gallery/gallery/lib/demos/material/dialog_demo.dart b/gallery/gallery/lib/demos/material/dialog_demo.dart index 0342ce2d1..0c92649b3 100644 --- a/gallery/gallery/lib/demos/material/dialog_demo.dart +++ b/gallery/gallery/lib/demos/material/dialog_demo.dart @@ -49,6 +49,7 @@ class DialogDemo extends StatelessWidget { ); // The value passed to Navigator.pop() or null. if (value != null && value is String) { + _scaffoldKey.currentState.hideCurrentSnackBar(); _scaffoldKey.currentState.showSnackBar(SnackBar( content: Text(GalleryLocalizations.of(context).dialogSelectedOption(value)), diff --git a/gallery/gallery/lib/demos/material/menu_demo.dart b/gallery/gallery/lib/demos/material/menu_demo.dart index 7d77a3220..a1f4814bd 100644 --- a/gallery/gallery/lib/demos/material/menu_demo.dart +++ b/gallery/gallery/lib/demos/material/menu_demo.dart @@ -39,6 +39,7 @@ class _MenuDemoState extends State { final GlobalKey _scaffoldKey = GlobalKey(); void showInSnackBar(String value) { + _scaffoldKey.currentState.hideCurrentSnackBar(); _scaffoldKey.currentState.showSnackBar(SnackBar( content: Text(value), )); diff --git a/gallery/gallery/lib/demos/material/snackbar_demo.dart b/gallery/gallery/lib/demos/material/snackbar_demo.dart index 512999d51..0d83d0940 100644 --- a/gallery/gallery/lib/demos/material/snackbar_demo.dart +++ b/gallery/gallery/lib/demos/material/snackbar_demo.dart @@ -24,6 +24,7 @@ class SnackbarsDemo extends StatelessWidget { child: Text( GalleryLocalizations.of(context).demoSnackbarsButtonLabel), onPressed: () { + Scaffold.of(context).hideCurrentSnackBar(); Scaffold.of(context).showSnackBar(SnackBar( content: Text( GalleryLocalizations.of(context).demoSnackbarsText, @@ -32,6 +33,7 @@ class SnackbarsDemo extends StatelessWidget { label: GalleryLocalizations.of(context) .demoSnackbarsActionButtonLabel, onPressed: () { + Scaffold.of(context).hideCurrentSnackBar(); Scaffold.of(context).showSnackBar(SnackBar( content: Text( GalleryLocalizations.of(context).demoSnackbarsAction, diff --git a/gallery/gallery/lib/demos/material/text_field_demo.dart b/gallery/gallery/lib/demos/material/text_field_demo.dart index d7f3cc91f..5413549fa 100644 --- a/gallery/gallery/lib/demos/material/text_field_demo.dart +++ b/gallery/gallery/lib/demos/material/text_field_demo.dart @@ -106,6 +106,7 @@ class TextFormFieldDemoState extends State { PersonData person = PersonData(); void showInSnackBar(String value) { + _scaffoldKey.currentState.hideCurrentSnackBar(); _scaffoldKey.currentState.showSnackBar(SnackBar( content: Text(value), )); diff --git a/gallery/gallery/tool/grind.dart b/gallery/gallery/tool/grind.dart index 2043c5bd0..37863631f 100644 --- a/gallery/gallery/tool/grind.dart +++ b/gallery/gallery/tool/grind.dart @@ -86,8 +86,8 @@ Future verifyCodeSegments() async { if (codeSegmentsFormatted.trim() != expectedCodeSegmentsOutput.trim()) { stderr.writeln( 'The contents of $codeSegmentsPath are different from that produced by ' - 'codeviewer_cli. Did you forget to run update-code-segments after ' - 'updating a demo?', + 'codeviewer_cli. Did you forget to run `flutter pub run grinder ' + 'update-code-segments` after updating a demo?', ); exit(1); }