mirror of
https://github.com/flutter/samples.git
synced 2026-03-22 20:31:48 +00:00
[Gallery] Hide snackbar before showing one (#258)
* Hide snackbar before showing one * Update code_segments.dart * Update grind error message with command
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user