[Gallery] Hide snackbar before showing one (#258)

* Hide snackbar before showing one

* Update code_segments.dart

* Update grind error message with command
pull/261/head
Pierre-Louis 5 years ago committed by GitHub
parent becb9db7da
commit 9f0a977d80
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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'),

@ -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)),

@ -39,6 +39,7 @@ class _MenuDemoState extends State<MenuDemo> {
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
void showInSnackBar(String value) {
_scaffoldKey.currentState.hideCurrentSnackBar();
_scaffoldKey.currentState.showSnackBar(SnackBar(
content: Text(value),
));

@ -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,

@ -106,6 +106,7 @@ class TextFormFieldDemoState extends State<TextFormFieldDemo> {
PersonData person = PersonData();
void showInSnackBar(String value) {
_scaffoldKey.currentState.hideCurrentSnackBar();
_scaffoldKey.currentState.showSnackBar(SnackBar(
content: Text(value),
));

@ -86,8 +86,8 @@ Future<void> 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);
}

Loading…
Cancel
Save