mirror of
https://github.com/flutter/samples.git
synced 2026-04-05 19:22:08 +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.punctuationStyle, text: '.'),
|
||||||
TextSpan(style: codeStyle.baseStyle, text: 'currentState'),
|
TextSpan(style: codeStyle.baseStyle, text: 'currentState'),
|
||||||
TextSpan(style: codeStyle.punctuationStyle, text: '.'),
|
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.baseStyle, text: 'showSnackBar'),
|
||||||
TextSpan(style: codeStyle.punctuationStyle, text: '('),
|
TextSpan(style: codeStyle.punctuationStyle, text: '('),
|
||||||
TextSpan(style: codeStyle.classStyle, text: 'SnackBar'),
|
TextSpan(style: codeStyle.classStyle, text: 'SnackBar'),
|
||||||
@@ -23656,6 +23662,15 @@ class CodeSegments {
|
|||||||
TextSpan(style: codeStyle.punctuationStyle, text: '('),
|
TextSpan(style: codeStyle.punctuationStyle, text: '('),
|
||||||
TextSpan(style: codeStyle.baseStyle, text: 'context'),
|
TextSpan(style: codeStyle.baseStyle, text: 'context'),
|
||||||
TextSpan(style: codeStyle.punctuationStyle, text: ').'),
|
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.baseStyle, text: 'showSnackBar'),
|
||||||
TextSpan(style: codeStyle.punctuationStyle, text: '('),
|
TextSpan(style: codeStyle.punctuationStyle, text: '('),
|
||||||
TextSpan(style: codeStyle.classStyle, text: 'SnackBar'),
|
TextSpan(style: codeStyle.classStyle, text: 'SnackBar'),
|
||||||
@@ -23715,6 +23730,16 @@ class CodeSegments {
|
|||||||
TextSpan(style: codeStyle.punctuationStyle, text: '('),
|
TextSpan(style: codeStyle.punctuationStyle, text: '('),
|
||||||
TextSpan(style: codeStyle.baseStyle, text: 'context'),
|
TextSpan(style: codeStyle.baseStyle, text: 'context'),
|
||||||
TextSpan(style: codeStyle.punctuationStyle, text: ').'),
|
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.baseStyle, text: 'showSnackBar'),
|
||||||
TextSpan(style: codeStyle.punctuationStyle, text: '('),
|
TextSpan(style: codeStyle.punctuationStyle, text: '('),
|
||||||
TextSpan(style: codeStyle.classStyle, text: 'SnackBar'),
|
TextSpan(style: codeStyle.classStyle, text: 'SnackBar'),
|
||||||
@@ -24560,6 +24585,12 @@ class CodeSegments {
|
|||||||
TextSpan(style: codeStyle.punctuationStyle, text: '.'),
|
TextSpan(style: codeStyle.punctuationStyle, text: '.'),
|
||||||
TextSpan(style: codeStyle.baseStyle, text: 'currentState'),
|
TextSpan(style: codeStyle.baseStyle, text: 'currentState'),
|
||||||
TextSpan(style: codeStyle.punctuationStyle, text: '.'),
|
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.baseStyle, text: 'showSnackBar'),
|
||||||
TextSpan(style: codeStyle.punctuationStyle, text: '('),
|
TextSpan(style: codeStyle.punctuationStyle, text: '('),
|
||||||
TextSpan(style: codeStyle.classStyle, text: 'SnackBar'),
|
TextSpan(style: codeStyle.classStyle, text: 'SnackBar'),
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ class DialogDemo extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
// The value passed to Navigator.pop() or null.
|
// The value passed to Navigator.pop() or null.
|
||||||
if (value != null && value is String) {
|
if (value != null && value is String) {
|
||||||
|
_scaffoldKey.currentState.hideCurrentSnackBar();
|
||||||
_scaffoldKey.currentState.showSnackBar(SnackBar(
|
_scaffoldKey.currentState.showSnackBar(SnackBar(
|
||||||
content:
|
content:
|
||||||
Text(GalleryLocalizations.of(context).dialogSelectedOption(value)),
|
Text(GalleryLocalizations.of(context).dialogSelectedOption(value)),
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ class _MenuDemoState extends State<MenuDemo> {
|
|||||||
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
||||||
|
|
||||||
void showInSnackBar(String value) {
|
void showInSnackBar(String value) {
|
||||||
|
_scaffoldKey.currentState.hideCurrentSnackBar();
|
||||||
_scaffoldKey.currentState.showSnackBar(SnackBar(
|
_scaffoldKey.currentState.showSnackBar(SnackBar(
|
||||||
content: Text(value),
|
content: Text(value),
|
||||||
));
|
));
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ class SnackbarsDemo extends StatelessWidget {
|
|||||||
child: Text(
|
child: Text(
|
||||||
GalleryLocalizations.of(context).demoSnackbarsButtonLabel),
|
GalleryLocalizations.of(context).demoSnackbarsButtonLabel),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
|
Scaffold.of(context).hideCurrentSnackBar();
|
||||||
Scaffold.of(context).showSnackBar(SnackBar(
|
Scaffold.of(context).showSnackBar(SnackBar(
|
||||||
content: Text(
|
content: Text(
|
||||||
GalleryLocalizations.of(context).demoSnackbarsText,
|
GalleryLocalizations.of(context).demoSnackbarsText,
|
||||||
@@ -32,6 +33,7 @@ class SnackbarsDemo extends StatelessWidget {
|
|||||||
label: GalleryLocalizations.of(context)
|
label: GalleryLocalizations.of(context)
|
||||||
.demoSnackbarsActionButtonLabel,
|
.demoSnackbarsActionButtonLabel,
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
|
Scaffold.of(context).hideCurrentSnackBar();
|
||||||
Scaffold.of(context).showSnackBar(SnackBar(
|
Scaffold.of(context).showSnackBar(SnackBar(
|
||||||
content: Text(
|
content: Text(
|
||||||
GalleryLocalizations.of(context).demoSnackbarsAction,
|
GalleryLocalizations.of(context).demoSnackbarsAction,
|
||||||
|
|||||||
@@ -106,6 +106,7 @@ class TextFormFieldDemoState extends State<TextFormFieldDemo> {
|
|||||||
PersonData person = PersonData();
|
PersonData person = PersonData();
|
||||||
|
|
||||||
void showInSnackBar(String value) {
|
void showInSnackBar(String value) {
|
||||||
|
_scaffoldKey.currentState.hideCurrentSnackBar();
|
||||||
_scaffoldKey.currentState.showSnackBar(SnackBar(
|
_scaffoldKey.currentState.showSnackBar(SnackBar(
|
||||||
content: Text(value),
|
content: Text(value),
|
||||||
));
|
));
|
||||||
|
|||||||
@@ -86,8 +86,8 @@ Future<void> verifyCodeSegments() async {
|
|||||||
if (codeSegmentsFormatted.trim() != expectedCodeSegmentsOutput.trim()) {
|
if (codeSegmentsFormatted.trim() != expectedCodeSegmentsOutput.trim()) {
|
||||||
stderr.writeln(
|
stderr.writeln(
|
||||||
'The contents of $codeSegmentsPath are different from that produced by '
|
'The contents of $codeSegmentsPath are different from that produced by '
|
||||||
'codeviewer_cli. Did you forget to run update-code-segments after '
|
'codeviewer_cli. Did you forget to run `flutter pub run grinder '
|
||||||
'updating a demo?',
|
'update-code-segments` after updating a demo?',
|
||||||
);
|
);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user