Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
cd60da78
Unverified
Commit
cd60da78
authored
Oct 14, 2020
by
Kate Lovett
Committed by
GitHub
Oct 14, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate Scaffold SnackBars in the framework to ScaffoldMessenger (#67946)
parent
767fb98a
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
79 additions
and
96 deletions
+79
-96
stock_home.dart
dev/benchmarks/test_apps/stocks/lib/stock_home.dart
+1
-1
motion_events_page.dart
...tegration_tests/android_views/lib/motion_events_page.dart
+1
-1
contacts_demo.dart
...gration_tests/flutter_gallery/lib/demo/contacts_demo.dart
+9
-11
bottom_app_bar_demo.dart
...lutter_gallery/lib/demo/material/bottom_app_bar_demo.dart
+53
-49
dialog_demo.dart
..._tests/flutter_gallery/lib/demo/material/dialog_demo.dart
+2
-4
drawer_demo.dart
..._tests/flutter_gallery/lib/demo/material/drawer_demo.dart
+1
-1
leave_behind_demo.dart
.../flutter_gallery/lib/demo/material/leave_behind_demo.dart
+2
-4
menu_demo.dart
...on_tests/flutter_gallery/lib/demo/material/menu_demo.dart
+1
-3
overscroll_demo.dart
...ts/flutter_gallery/lib/demo/material/overscroll_demo.dart
+1
-3
snack_bar_demo.dart
...sts/flutter_gallery/lib/demo/material/snack_bar_demo.dart
+2
-2
text_form_field_demo.dart
...utter_gallery/lib/demo/material/text_form_field_demo.dart
+1
-3
tooltip_demo.dart
...tests/flutter_gallery/lib/demo/material/tooltip_demo.dart
+1
-1
pesto_demo.dart
...ntegration_tests/flutter_gallery/lib/demo/pesto_demo.dart
+2
-6
video_demo.dart
...ntegration_tests/flutter_gallery/lib/demo/video_demo.dart
+1
-6
motion_events_page.dart
...on_tests/hybrid_android_views/lib/motion_events_page.dart
+1
-1
No files found.
dev/benchmarks/test_apps/stocks/lib/stock_home.dart
View file @
cd60da78
...
...
@@ -247,7 +247,7 @@ class StockHomeState extends State<StockHome> {
stock
.
percentChange
=
100.0
*
(
1.0
/
stock
.
lastSale
);
stock
.
lastSale
+=
1.0
;
});
_scaffoldKey
.
currentState
.
showSnackBar
(
SnackBar
(
ScaffoldMessenger
.
of
(
context
)
.
showSnackBar
(
SnackBar
(
content:
Text
(
'Purchased
${stock.symbol}
for
${stock.lastSale}
'
),
action:
SnackBarAction
(
label:
'BUY MORE'
,
...
...
dev/integration_tests/android_views/lib/motion_events_page.dart
View file @
cd60da78
...
...
@@ -187,7 +187,7 @@ class MotionEventsBodyState extends State<MotionEventsBody> {
}
void
showMessage
(
BuildContext
context
,
String
message
)
{
Scaffold
.
of
(
context
).
showSnackBar
(
SnackBar
(
Scaffold
Messenger
.
of
(
context
).
showSnackBar
(
SnackBar
(
content:
Text
(
message
),
duration:
const
Duration
(
seconds:
3
),
));
...
...
dev/integration_tests/flutter_gallery/lib/demo/contacts_demo.dart
View file @
cd60da78
...
...
@@ -95,7 +95,6 @@ class ContactsDemo extends StatefulWidget {
enum
AppBarBehavior
{
normal
,
pinned
,
floating
,
snapping
}
class
ContactsDemoState
extends
State
<
ContactsDemo
>
{
static
final
GlobalKey
<
ScaffoldState
>
_scaffoldKey
=
GlobalKey
<
ScaffoldState
>();
final
double
_appBarHeight
=
256.0
;
AppBarBehavior
_appBarBehavior
=
AppBarBehavior
.
pinned
;
...
...
@@ -109,7 +108,6 @@ class ContactsDemoState extends State<ContactsDemo> {
platform:
Theme
.
of
(
context
).
platform
,
),
child:
Scaffold
(
key:
_scaffoldKey
,
body:
CustomScrollView
(
slivers:
<
Widget
>[
SliverAppBar
(
...
...
@@ -122,7 +120,7 @@ class ContactsDemoState extends State<ContactsDemo> {
icon:
const
Icon
(
Icons
.
create
),
tooltip:
'Edit'
,
onPressed:
()
{
_scaffoldKey
.
currentState
.
showSnackBar
(
const
SnackBar
(
ScaffoldMessenger
.
of
(
context
)
.
showSnackBar
(
const
SnackBar
(
content:
Text
(
"Editing isn't supported in this screen."
),
));
},
...
...
@@ -190,7 +188,7 @@ class ContactsDemoState extends State<ContactsDemo> {
icon:
Icons
.
message
,
tooltip:
'Send message'
,
onPressed:
()
{
_scaffoldKey
.
currentState
.
showSnackBar
(
const
SnackBar
(
ScaffoldMessenger
.
of
(
context
)
.
showSnackBar
(
const
SnackBar
(
content:
Text
(
'Pretend that this opened your SMS application.'
),
));
},
...
...
@@ -203,7 +201,7 @@ class ContactsDemoState extends State<ContactsDemo> {
icon:
Icons
.
message
,
tooltip:
'Send message'
,
onPressed:
()
{
_scaffoldKey
.
currentState
.
showSnackBar
(
const
SnackBar
(
ScaffoldMessenger
.
of
(
context
)
.
showSnackBar
(
const
SnackBar
(
content:
Text
(
'A messaging app appears.'
),
));
},
...
...
@@ -216,7 +214,7 @@ class ContactsDemoState extends State<ContactsDemo> {
icon:
Icons
.
message
,
tooltip:
'Send message'
,
onPressed:
()
{
_scaffoldKey
.
currentState
.
showSnackBar
(
const
SnackBar
(
ScaffoldMessenger
.
of
(
context
)
.
showSnackBar
(
const
SnackBar
(
content:
Text
(
'Imagine if you will, a messaging application.'
),
));
},
...
...
@@ -235,7 +233,7 @@ class ContactsDemoState extends State<ContactsDemo> {
icon:
Icons
.
email
,
tooltip:
'Send personal e-mail'
,
onPressed:
()
{
_scaffoldKey
.
currentState
.
showSnackBar
(
const
SnackBar
(
ScaffoldMessenger
.
of
(
context
)
.
showSnackBar
(
const
SnackBar
(
content:
Text
(
'Here, your e-mail application would open.'
),
));
},
...
...
@@ -248,7 +246,7 @@ class ContactsDemoState extends State<ContactsDemo> {
icon:
Icons
.
email
,
tooltip:
'Send work e-mail'
,
onPressed:
()
{
_scaffoldKey
.
currentState
.
showSnackBar
(
const
SnackBar
(
ScaffoldMessenger
.
of
(
context
)
.
showSnackBar
(
const
SnackBar
(
content:
Text
(
'Summon your favorite e-mail application here.'
),
));
},
...
...
@@ -266,7 +264,7 @@ class ContactsDemoState extends State<ContactsDemo> {
icon:
Icons
.
map
,
tooltip:
'Open map'
,
onPressed:
()
{
_scaffoldKey
.
currentState
.
showSnackBar
(
const
SnackBar
(
ScaffoldMessenger
.
of
(
context
)
.
showSnackBar
(
const
SnackBar
(
content:
Text
(
'This would show a map of San Francisco.'
),
));
},
...
...
@@ -280,7 +278,7 @@ class ContactsDemoState extends State<ContactsDemo> {
icon:
Icons
.
map
,
tooltip:
'Open map'
,
onPressed:
()
{
_scaffoldKey
.
currentState
.
showSnackBar
(
const
SnackBar
(
ScaffoldMessenger
.
of
(
context
)
.
showSnackBar
(
const
SnackBar
(
content:
Text
(
'This would show a map of Mountain View.'
),
));
},
...
...
@@ -294,7 +292,7 @@ class ContactsDemoState extends State<ContactsDemo> {
icon:
Icons
.
map
,
tooltip:
'Open map'
,
onPressed:
()
{
_scaffoldKey
.
currentState
.
showSnackBar
(
const
SnackBar
(
ScaffoldMessenger
.
of
(
context
)
.
showSnackBar
(
const
SnackBar
(
content:
Text
(
'This would also show a map, if this was not a demo.'
),
));
},
...
...
dev/integration_tests/flutter_gallery/lib/demo/material/bottom_app_bar_demo.dart
View file @
cd60da78
...
...
@@ -18,7 +18,7 @@ class BottomAppBarDemo extends StatefulWidget {
// for bottom application bar.
class
_BottomAppBarDemoState
extends
State
<
BottomAppBarDemo
>
{
static
final
GlobalKey
<
Scaffold
State
>
_scaffoldKey
=
GlobalKey
<
Scaffold
State
>();
static
final
GlobalKey
<
Scaffold
MessengerState
>
_scaffoldMessengerKey
=
GlobalKey
<
ScaffoldMessenger
State
>();
// FAB shape
...
...
@@ -92,7 +92,7 @@ class _BottomAppBarDemoState extends State<BottomAppBarDemo> {
"When the Scaffold's floating action button location changes, "
'the floating action button animates to its new position. '
'The BottomAppBar adapts its shape appropriately.'
;
_scaffoldKey
.
currentState
.
showSnackBar
(
_scaffold
Messenger
Key
.
currentState
.
showSnackBar
(
const
SnackBar
(
content:
Text
(
text
)),
);
}
...
...
@@ -139,61 +139,65 @@ class _BottomAppBarDemoState extends State<BottomAppBarDemo> {
@override
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
key:
_scaffoldKey
,
appBar:
AppBar
(
title:
const
Text
(
'Bottom app bar'
),
elevation:
0.0
,
actions:
<
Widget
>[
MaterialDemoDocumentationButton
(
BottomAppBarDemo
.
routeName
),
IconButton
(
icon:
const
Icon
(
Icons
.
sentiment_very_satisfied
,
semanticLabel:
'Update shape'
),
onPressed:
()
{
setState
(()
{
_fabShape
=
_fabShape
==
kCircularFab
?
kDiamondFab
:
kCircularFab
;
});
},
return
ScaffoldMessenger
(
key:
_scaffoldMessengerKey
,
child:
Builder
(
builder:
(
BuildContext
context
)
=>
Scaffold
(
appBar:
AppBar
(
title:
const
Text
(
'Bottom app bar'
),
elevation:
0.0
,
actions:
<
Widget
>[
MaterialDemoDocumentationButton
(
BottomAppBarDemo
.
routeName
),
IconButton
(
icon:
const
Icon
(
Icons
.
sentiment_very_satisfied
,
semanticLabel:
'Update shape'
),
onPressed:
()
{
setState
(()
{
_fabShape
=
_fabShape
==
kCircularFab
?
kDiamondFab
:
kCircularFab
;
});
},
),
],
),
],
),
body:
Scrollbar
(
child:
ListView
(
padding:
const
EdgeInsets
.
only
(
bottom:
88.0
),
children:
<
Widget
>[
const
_Heading
(
'FAB Shape'
),
body:
Scrollbar
(
child:
ListView
(
padding:
const
EdgeInsets
.
only
(
bottom:
88.0
),
children:
<
Widget
>[
const
_Heading
(
'FAB Shape'
),
_RadioItem
<
Widget
>(
kCircularFab
,
_fabShape
,
_onFabShapeChanged
),
_RadioItem
<
Widget
>(
kDiamondFab
,
_fabShape
,
_onFabShapeChanged
),
_RadioItem
<
Widget
>(
kNoFab
,
_fabShape
,
_onFabShapeChanged
),
_RadioItem
<
Widget
>(
kCircularFab
,
_fabShape
,
_onFabShapeChanged
),
_RadioItem
<
Widget
>(
kDiamondFab
,
_fabShape
,
_onFabShapeChanged
),
_RadioItem
<
Widget
>(
kNoFab
,
_fabShape
,
_onFabShapeChanged
),
const
Divider
(),
const
_Heading
(
'Notch'
),
const
Divider
(),
const
_Heading
(
'Notch'
),
_RadioItem
<
bool
>(
kShowNotchTrue
,
_showNotch
,
_onShowNotchChanged
),
_RadioItem
<
bool
>(
kShowNotchFalse
,
_showNotch
,
_onShowNotchChanged
),
_RadioItem
<
bool
>(
kShowNotchTrue
,
_showNotch
,
_onShowNotchChanged
),
_RadioItem
<
bool
>(
kShowNotchFalse
,
_showNotch
,
_onShowNotchChanged
),
const
Divider
(),
const
_Heading
(
'FAB Position'
),
const
Divider
(),
const
_Heading
(
'FAB Position'
),
_RadioItem
<
FloatingActionButtonLocation
>(
kFabEndDocked
,
_fabLocation
,
_onFabLocationChanged
),
_RadioItem
<
FloatingActionButtonLocation
>(
kFabCenterDocked
,
_fabLocation
,
_onFabLocationChanged
),
_RadioItem
<
FloatingActionButtonLocation
>(
kFabEndFloat
,
_fabLocation
,
_onFabLocationChanged
),
_RadioItem
<
FloatingActionButtonLocation
>(
kFabCenterFloat
,
_fabLocation
,
_onFabLocationChanged
),
_RadioItem
<
FloatingActionButtonLocation
>(
kFabEndDocked
,
_fabLocation
,
_onFabLocationChanged
),
_RadioItem
<
FloatingActionButtonLocation
>(
kFabCenterDocked
,
_fabLocation
,
_onFabLocationChanged
),
_RadioItem
<
FloatingActionButtonLocation
>(
kFabEndFloat
,
_fabLocation
,
_onFabLocationChanged
),
_RadioItem
<
FloatingActionButtonLocation
>(
kFabCenterFloat
,
_fabLocation
,
_onFabLocationChanged
),
const
Divider
(),
const
_Heading
(
'App bar color'
),
const
Divider
(),
const
_Heading
(
'App bar color'
),
_ColorsItem
(
kBabColors
,
_babColor
,
_onBabColorChanged
),
],
_ColorsItem
(
kBabColors
,
_babColor
,
_onBabColorChanged
),
],
),
),
floatingActionButton:
_fabShape
.
value
,
floatingActionButtonLocation:
_fabLocation
.
value
,
bottomNavigationBar:
_DemoBottomAppBar
(
color:
_babColor
,
fabLocation:
_fabLocation
.
value
,
shape:
_selectNotch
(),
),
),
),
floatingActionButton:
_fabShape
.
value
,
floatingActionButtonLocation:
_fabLocation
.
value
,
bottomNavigationBar:
_DemoBottomAppBar
(
color:
_babColor
,
fabLocation:
_fabLocation
.
value
,
shape:
_selectNotch
(),
),
);
}
...
...
@@ -364,7 +368,7 @@ class _DemoBottomAppBar extends StatelessWidget {
IconButton
(
icon:
const
Icon
(
Icons
.
search
,
semanticLabel:
'show search action'
,),
onPressed:
()
{
Scaffold
.
of
(
context
).
showSnackBar
(
Scaffold
Messenger
.
of
(
context
).
showSnackBar
(
const
SnackBar
(
content:
Text
(
'This is a dummy search action.'
)),
);
},
...
...
@@ -377,7 +381,7 @@ class _DemoBottomAppBar extends StatelessWidget {
semanticLabel:
'Show menu actions'
,
),
onPressed:
()
{
Scaffold
.
of
(
context
).
showSnackBar
(
Scaffold
Messenger
.
of
(
context
).
showSnackBar
(
const
SnackBar
(
content:
Text
(
'This is a dummy menu action.'
)),
);
},
...
...
dev/integration_tests/flutter_gallery/lib/demo/material/dialog_demo.dart
View file @
cd60da78
...
...
@@ -55,7 +55,6 @@ class DialogDemo extends StatefulWidget {
}
class
DialogDemoState
extends
State
<
DialogDemo
>
{
final
GlobalKey
<
ScaffoldState
>
_scaffoldKey
=
GlobalKey
<
ScaffoldState
>();
TimeOfDay
_selectedTime
;
...
...
@@ -73,7 +72,7 @@ class DialogDemoState extends State<DialogDemo> {
)
.
then
<
void
>((
T
value
)
{
// The value passed to Navigator.pop() or null.
if
(
value
!=
null
)
{
_scaffoldKey
.
currentState
.
showSnackBar
(
SnackBar
(
ScaffoldMessenger
.
of
(
context
)
.
showSnackBar
(
SnackBar
(
content:
Text
(
'You selected:
$value
'
),
));
}
...
...
@@ -86,7 +85,6 @@ class DialogDemoState extends State<DialogDemo> {
final
TextStyle
dialogTextStyle
=
theme
.
textTheme
.
subtitle1
.
copyWith
(
color:
theme
.
textTheme
.
caption
.
color
);
return
Scaffold
(
key:
_scaffoldKey
,
appBar:
AppBar
(
title:
const
Text
(
'Dialogs'
),
actions:
<
Widget
>[
MaterialDemoDocumentationButton
(
DialogDemo
.
routeName
)],
...
...
@@ -183,7 +181,7 @@ class DialogDemoState extends State<DialogDemo> {
.
then
<
void
>((
TimeOfDay
value
)
{
if
(
value
!=
null
&&
value
!=
_selectedTime
)
{
_selectedTime
=
value
;
_scaffoldKey
.
currentState
.
showSnackBar
(
SnackBar
(
ScaffoldMessenger
.
of
(
context
)
.
showSnackBar
(
SnackBar
(
content:
Text
(
'You selected:
${value.format(context)}
'
),
));
}
...
...
dev/integration_tests/flutter_gallery/lib/demo/material/drawer_demo.dart
View file @
cd60da78
...
...
@@ -75,7 +75,7 @@ class _DrawerDemoState extends State<DrawerDemo> with TickerProviderStateMixin {
void
_showNotImplementedMessage
()
{
Navigator
.
pop
(
context
);
// Dismiss the drawer.
_scaffoldKey
.
currentState
.
showSnackBar
(
const
SnackBar
(
ScaffoldMessenger
.
of
(
context
)
.
showSnackBar
(
const
SnackBar
(
content:
Text
(
"The drawer's items don't do anything"
),
));
}
...
...
dev/integration_tests/flutter_gallery/lib/demo/material/leave_behind_demo.dart
View file @
cd60da78
...
...
@@ -42,7 +42,6 @@ class LeaveBehindDemo extends StatefulWidget {
}
class
LeaveBehindDemoState
extends
State
<
LeaveBehindDemo
>
{
static
final
GlobalKey
<
ScaffoldState
>
_scaffoldKey
=
GlobalKey
<
ScaffoldState
>();
DismissDirection
_dismissDirection
=
DismissDirection
.
horizontal
;
bool
_confirmDismiss
=
true
;
List
<
LeaveBehindItem
>
leaveBehindItems
;
...
...
@@ -97,7 +96,7 @@ class LeaveBehindDemoState extends State<LeaveBehindDemo> {
setState
(()
{
leaveBehindItems
.
remove
(
item
);
});
_scaffoldKey
.
currentState
.
showSnackBar
(
SnackBar
(
ScaffoldMessenger
.
of
(
context
)
.
showSnackBar
(
SnackBar
(
content:
Text
(
'You archived item
${item.index}
'
),
action:
SnackBarAction
(
label:
'UNDO'
,
...
...
@@ -110,7 +109,7 @@ class LeaveBehindDemoState extends State<LeaveBehindDemo> {
setState
(()
{
leaveBehindItems
.
remove
(
item
);
});
_scaffoldKey
.
currentState
.
showSnackBar
(
SnackBar
(
ScaffoldMessenger
.
of
(
context
)
.
showSnackBar
(
SnackBar
(
content:
Text
(
'You deleted item
${item.index}
'
),
action:
SnackBarAction
(
label:
'UNDO'
,
...
...
@@ -146,7 +145,6 @@ class LeaveBehindDemoState extends State<LeaveBehindDemo> {
}
return
Scaffold
(
key:
_scaffoldKey
,
appBar:
AppBar
(
title:
const
Text
(
'Swipe to dismiss'
),
actions:
<
Widget
>[
...
...
dev/integration_tests/flutter_gallery/lib/demo/material/menu_demo.dart
View file @
cd60da78
...
...
@@ -16,7 +16,6 @@ class MenuDemo extends StatefulWidget {
}
class
MenuDemoState
extends
State
<
MenuDemo
>
{
final
GlobalKey
<
ScaffoldState
>
_scaffoldKey
=
GlobalKey
<
ScaffoldState
>();
final
String
_simpleValue1
=
'Menu item value one'
;
final
String
_simpleValue2
=
'Menu item value two'
;
...
...
@@ -37,7 +36,7 @@ class MenuDemoState extends State<MenuDemo> {
}
void
showInSnackBar
(
String
value
)
{
_scaffoldKey
.
currentState
.
showSnackBar
(
SnackBar
(
ScaffoldMessenger
.
of
(
context
)
.
showSnackBar
(
SnackBar
(
content:
Text
(
value
),
));
}
...
...
@@ -62,7 +61,6 @@ class MenuDemoState extends State<MenuDemo> {
@override
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
key:
_scaffoldKey
,
appBar:
AppBar
(
title:
const
Text
(
'Menus'
),
actions:
<
Widget
>[
...
...
dev/integration_tests/flutter_gallery/lib/demo/material/overscroll_demo.dart
View file @
cd60da78
...
...
@@ -20,7 +20,6 @@ class OverscrollDemo extends StatefulWidget {
}
class
OverscrollDemoState
extends
State
<
OverscrollDemo
>
{
final
GlobalKey
<
ScaffoldState
>
_scaffoldKey
=
GlobalKey
<
ScaffoldState
>();
final
GlobalKey
<
RefreshIndicatorState
>
_refreshIndicatorKey
=
GlobalKey
<
RefreshIndicatorState
>();
static
final
List
<
String
>
_items
=
<
String
>[
'A'
,
'B'
,
'C'
,
'D'
,
'E'
,
'F'
,
'G'
,
'H'
,
'I'
,
'J'
,
'K'
,
'L'
,
'M'
,
'N'
,
...
...
@@ -30,7 +29,7 @@ class OverscrollDemoState extends State<OverscrollDemo> {
final
Completer
<
void
>
completer
=
Completer
<
void
>();
Timer
(
const
Duration
(
seconds:
3
),
()
{
completer
.
complete
();
});
return
completer
.
future
.
then
<
void
>((
_
)
{
_scaffoldKey
.
currentState
?
.
showSnackBar
(
SnackBar
(
ScaffoldMessenger
.
of
(
context
)
.
showSnackBar
(
SnackBar
(
content:
const
Text
(
'Refresh complete'
),
action:
SnackBarAction
(
label:
'RETRY'
,
...
...
@@ -45,7 +44,6 @@ class OverscrollDemoState extends State<OverscrollDemo> {
@override
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
key:
_scaffoldKey
,
appBar:
AppBar
(
title:
const
Text
(
'Pull to refresh'
),
actions:
<
Widget
>[
...
...
dev/integration_tests/flutter_gallery/lib/demo/material/snack_bar_demo.dart
View file @
cd60da78
...
...
@@ -44,12 +44,12 @@ class _SnackBarDemoState extends State<SnackBarDemo> {
child:
const
Text
(
'SHOW A SNACKBAR'
),
onPressed:
()
{
final
int
thisSnackBarIndex
=
_snackBarIndex
++;
Scaffold
.
of
(
context
).
showSnackBar
(
SnackBar
(
Scaffold
Messenger
.
of
(
context
).
showSnackBar
(
SnackBar
(
content:
Text
(
'This is snackbar #
$thisSnackBarIndex
.'
),
action:
SnackBarAction
(
label:
'ACTION'
,
onPressed:
()
{
Scaffold
.
of
(
context
).
showSnackBar
(
SnackBar
(
Scaffold
Messenger
.
of
(
context
).
showSnackBar
(
SnackBar
(
content:
Text
(
"You pressed snackbar
$thisSnackBarIndex
's action."
),
));
},
...
...
dev/integration_tests/flutter_gallery/lib/demo/material/text_form_field_demo.dart
View file @
cd60da78
...
...
@@ -83,12 +83,11 @@ class _PasswordFieldState extends State<PasswordField> {
}
class
TextFormFieldDemoState
extends
State
<
TextFormFieldDemo
>
{
final
GlobalKey
<
ScaffoldState
>
_scaffoldKey
=
GlobalKey
<
ScaffoldState
>();
PersonData
person
=
PersonData
();
void
showInSnackBar
(
String
value
)
{
_scaffoldKey
.
currentState
.
showSnackBar
(
SnackBar
(
ScaffoldMessenger
.
of
(
context
)
.
showSnackBar
(
SnackBar
(
content:
Text
(
value
),
));
}
...
...
@@ -168,7 +167,6 @@ class TextFormFieldDemoState extends State<TextFormFieldDemo> {
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
drawerDragStartBehavior:
DragStartBehavior
.
down
,
key:
_scaffoldKey
,
appBar:
AppBar
(
title:
const
Text
(
'Text fields'
),
actions:
<
Widget
>[
MaterialDemoDocumentationButton
(
TextFormFieldDemo
.
routeName
)],
...
...
dev/integration_tests/flutter_gallery/lib/demo/material/tooltip_demo.dart
View file @
cd60da78
...
...
@@ -52,7 +52,7 @@ class TooltipDemo extends StatelessWidget {
color:
theme
.
iconTheme
.
color
,
tooltip:
'Place a phone call'
,
onPressed:
()
{
Scaffold
.
of
(
context
).
showSnackBar
(
const
SnackBar
(
Scaffold
Messenger
.
of
(
context
).
showSnackBar
(
const
SnackBar
(
content:
Text
(
'That was an ordinary tap.'
),
));
},
...
...
dev/integration_tests/flutter_gallery/lib/demo/pesto_demo.dart
View file @
cd60da78
...
...
@@ -73,7 +73,6 @@ class RecipeGridPage extends StatefulWidget {
}
class
_RecipeGridPageState
extends
State
<
RecipeGridPage
>
{
final
GlobalKey
<
ScaffoldState
>
scaffoldKey
=
GlobalKey
<
ScaffoldState
>();
@override
Widget
build
(
BuildContext
context
)
{
...
...
@@ -81,11 +80,10 @@ class _RecipeGridPageState extends State<RecipeGridPage> {
return
Theme
(
data:
_kTheme
.
copyWith
(
platform:
Theme
.
of
(
context
).
platform
),
child:
Scaffold
(
key:
scaffoldKey
,
floatingActionButton:
FloatingActionButton
(
child:
const
Icon
(
Icons
.
edit
),
onPressed:
()
{
scaffoldKey
.
currentState
.
showSnackBar
(
const
SnackBar
(
ScaffoldMessenger
.
of
(
context
)
.
showSnackBar
(
const
SnackBar
(
content:
Text
(
'Not supported.'
),
));
},
...
...
@@ -110,7 +108,7 @@ class _RecipeGridPageState extends State<RecipeGridPage> {
icon:
const
Icon
(
Icons
.
search
),
tooltip:
'Search'
,
onPressed:
()
{
scaffoldKey
.
currentState
.
showSnackBar
(
const
SnackBar
(
ScaffoldMessenger
.
of
(
context
)
.
showSnackBar
(
const
SnackBar
(
content:
Text
(
'Not supported.'
),
));
},
...
...
@@ -322,7 +320,6 @@ class RecipePage extends StatefulWidget {
}
class
_RecipePageState
extends
State
<
RecipePage
>
{
final
GlobalKey
<
ScaffoldState
>
_scaffoldKey
=
GlobalKey
<
ScaffoldState
>();
final
TextStyle
menuItemStyle
=
const
PestoStyle
(
fontSize:
15.0
,
color:
Colors
.
black54
,
height:
24.0
/
15.0
);
double
_getAppBarHeight
(
BuildContext
context
)
=>
MediaQuery
.
of
(
context
).
size
.
height
*
0.3
;
...
...
@@ -337,7 +334,6 @@ class _RecipePageState extends State<RecipePage> {
final
bool
fullWidth
=
screenSize
.
width
<
_kRecipePageMaxWidth
;
final
bool
isFavorite
=
_favoriteRecipes
.
contains
(
widget
.
recipe
);
return
Scaffold
(
key:
_scaffoldKey
,
body:
Stack
(
children:
<
Widget
>[
Positioned
(
...
...
dev/integration_tests/flutter_gallery/lib/demo/video_demo.dart
View file @
cd60da78
...
...
@@ -266,12 +266,10 @@ class ConnectivityOverlay extends StatefulWidget {
const
ConnectivityOverlay
({
this
.
child
,
this
.
connectedCompleter
,
this
.
scaffoldKey
,
});
final
Widget
child
;
final
Completer
<
void
>
connectedCompleter
;
final
GlobalKey
<
ScaffoldState
>
scaffoldKey
;
@override
_ConnectivityOverlayState
createState
()
=>
_ConnectivityOverlayState
();
...
...
@@ -321,7 +319,7 @@ class _ConnectivityOverlayState extends State<ConnectivityOverlay> {
return
;
}
if
(
connectivityResult
==
ConnectivityResult
.
none
)
{
widget
.
scaffoldKey
.
currentState
.
showSnackBar
(
errorSnackBar
);
ScaffoldMessenger
.
of
(
context
)
.
showSnackBar
(
errorSnackBar
);
}
else
{
if
(!
widget
.
connectedCompleter
.
isCompleted
)
{
widget
.
connectedCompleter
.
complete
(
null
);
...
...
@@ -368,7 +366,6 @@ class _VideoDemoState extends State<VideoDemo> with SingleTickerProviderStateMix
static
const
String
beeUri
=
'https://flutter.github.io/assets-for-api-docs/assets/videos/bee.mp4'
;
final
VideoPlayerController
beeController
=
VideoPlayerController
.
network
(
beeUri
);
final
GlobalKey
<
ScaffoldState
>
scaffoldKey
=
GlobalKey
<
ScaffoldState
>();
final
Completer
<
void
>
connectedCompleter
=
Completer
<
void
>();
bool
isSupported
=
true
;
bool
isDisposed
=
false
;
...
...
@@ -410,7 +407,6 @@ class _VideoDemoState extends State<VideoDemo> with SingleTickerProviderStateMix
@override
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
key:
scaffoldKey
,
appBar:
AppBar
(
title:
const
Text
(
'Videos'
),
),
...
...
@@ -433,7 +429,6 @@ class _VideoDemoState extends State<VideoDemo> with SingleTickerProviderStateMix
),
),
connectedCompleter:
connectedCompleter
,
scaffoldKey:
scaffoldKey
,
)
:
const
Center
(
child:
Text
(
...
...
dev/integration_tests/hybrid_android_views/lib/motion_events_page.dart
View file @
cd60da78
...
...
@@ -169,7 +169,7 @@ class MotionEventsBodyState extends State<MotionEventsBody> {
}
void
showMessage
(
BuildContext
context
,
String
message
)
{
Scaffold
.
of
(
context
).
showSnackBar
(
SnackBar
(
Scaffold
Messenger
.
of
(
context
).
showSnackBar
(
SnackBar
(
content:
Text
(
message
),
duration:
const
Duration
(
seconds:
3
),
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment