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> {
...
@@ -247,7 +247,7 @@ class StockHomeState extends State<StockHome> {
stock
.
percentChange
=
100.0
*
(
1.0
/
stock
.
lastSale
);
stock
.
percentChange
=
100.0
*
(
1.0
/
stock
.
lastSale
);
stock
.
lastSale
+=
1.0
;
stock
.
lastSale
+=
1.0
;
});
});
_scaffoldKey
.
currentState
.
showSnackBar
(
SnackBar
(
ScaffoldMessenger
.
of
(
context
)
.
showSnackBar
(
SnackBar
(
content:
Text
(
'Purchased
${stock.symbol}
for
${stock.lastSale}
'
),
content:
Text
(
'Purchased
${stock.symbol}
for
${stock.lastSale}
'
),
action:
SnackBarAction
(
action:
SnackBarAction
(
label:
'BUY MORE'
,
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> {
...
@@ -187,7 +187,7 @@ class MotionEventsBodyState extends State<MotionEventsBody> {
}
}
void
showMessage
(
BuildContext
context
,
String
message
)
{
void
showMessage
(
BuildContext
context
,
String
message
)
{
Scaffold
.
of
(
context
).
showSnackBar
(
SnackBar
(
Scaffold
Messenger
.
of
(
context
).
showSnackBar
(
SnackBar
(
content:
Text
(
message
),
content:
Text
(
message
),
duration:
const
Duration
(
seconds:
3
),
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 {
...
@@ -95,7 +95,6 @@ class ContactsDemo extends StatefulWidget {
enum
AppBarBehavior
{
normal
,
pinned
,
floating
,
snapping
}
enum
AppBarBehavior
{
normal
,
pinned
,
floating
,
snapping
}
class
ContactsDemoState
extends
State
<
ContactsDemo
>
{
class
ContactsDemoState
extends
State
<
ContactsDemo
>
{
static
final
GlobalKey
<
ScaffoldState
>
_scaffoldKey
=
GlobalKey
<
ScaffoldState
>();
final
double
_appBarHeight
=
256.0
;
final
double
_appBarHeight
=
256.0
;
AppBarBehavior
_appBarBehavior
=
AppBarBehavior
.
pinned
;
AppBarBehavior
_appBarBehavior
=
AppBarBehavior
.
pinned
;
...
@@ -109,7 +108,6 @@ class ContactsDemoState extends State<ContactsDemo> {
...
@@ -109,7 +108,6 @@ class ContactsDemoState extends State<ContactsDemo> {
platform:
Theme
.
of
(
context
).
platform
,
platform:
Theme
.
of
(
context
).
platform
,
),
),
child:
Scaffold
(
child:
Scaffold
(
key:
_scaffoldKey
,
body:
CustomScrollView
(
body:
CustomScrollView
(
slivers:
<
Widget
>[
slivers:
<
Widget
>[
SliverAppBar
(
SliverAppBar
(
...
@@ -122,7 +120,7 @@ class ContactsDemoState extends State<ContactsDemo> {
...
@@ -122,7 +120,7 @@ class ContactsDemoState extends State<ContactsDemo> {
icon:
const
Icon
(
Icons
.
create
),
icon:
const
Icon
(
Icons
.
create
),
tooltip:
'Edit'
,
tooltip:
'Edit'
,
onPressed:
()
{
onPressed:
()
{
_scaffoldKey
.
currentState
.
showSnackBar
(
const
SnackBar
(
ScaffoldMessenger
.
of
(
context
)
.
showSnackBar
(
const
SnackBar
(
content:
Text
(
"Editing isn't supported in this screen."
),
content:
Text
(
"Editing isn't supported in this screen."
),
));
));
},
},
...
@@ -190,7 +188,7 @@ class ContactsDemoState extends State<ContactsDemo> {
...
@@ -190,7 +188,7 @@ class ContactsDemoState extends State<ContactsDemo> {
icon:
Icons
.
message
,
icon:
Icons
.
message
,
tooltip:
'Send message'
,
tooltip:
'Send message'
,
onPressed:
()
{
onPressed:
()
{
_scaffoldKey
.
currentState
.
showSnackBar
(
const
SnackBar
(
ScaffoldMessenger
.
of
(
context
)
.
showSnackBar
(
const
SnackBar
(
content:
Text
(
'Pretend that this opened your SMS application.'
),
content:
Text
(
'Pretend that this opened your SMS application.'
),
));
));
},
},
...
@@ -203,7 +201,7 @@ class ContactsDemoState extends State<ContactsDemo> {
...
@@ -203,7 +201,7 @@ class ContactsDemoState extends State<ContactsDemo> {
icon:
Icons
.
message
,
icon:
Icons
.
message
,
tooltip:
'Send message'
,
tooltip:
'Send message'
,
onPressed:
()
{
onPressed:
()
{
_scaffoldKey
.
currentState
.
showSnackBar
(
const
SnackBar
(
ScaffoldMessenger
.
of
(
context
)
.
showSnackBar
(
const
SnackBar
(
content:
Text
(
'A messaging app appears.'
),
content:
Text
(
'A messaging app appears.'
),
));
));
},
},
...
@@ -216,7 +214,7 @@ class ContactsDemoState extends State<ContactsDemo> {
...
@@ -216,7 +214,7 @@ class ContactsDemoState extends State<ContactsDemo> {
icon:
Icons
.
message
,
icon:
Icons
.
message
,
tooltip:
'Send message'
,
tooltip:
'Send message'
,
onPressed:
()
{
onPressed:
()
{
_scaffoldKey
.
currentState
.
showSnackBar
(
const
SnackBar
(
ScaffoldMessenger
.
of
(
context
)
.
showSnackBar
(
const
SnackBar
(
content:
Text
(
'Imagine if you will, a messaging application.'
),
content:
Text
(
'Imagine if you will, a messaging application.'
),
));
));
},
},
...
@@ -235,7 +233,7 @@ class ContactsDemoState extends State<ContactsDemo> {
...
@@ -235,7 +233,7 @@ class ContactsDemoState extends State<ContactsDemo> {
icon:
Icons
.
email
,
icon:
Icons
.
email
,
tooltip:
'Send personal e-mail'
,
tooltip:
'Send personal e-mail'
,
onPressed:
()
{
onPressed:
()
{
_scaffoldKey
.
currentState
.
showSnackBar
(
const
SnackBar
(
ScaffoldMessenger
.
of
(
context
)
.
showSnackBar
(
const
SnackBar
(
content:
Text
(
'Here, your e-mail application would open.'
),
content:
Text
(
'Here, your e-mail application would open.'
),
));
));
},
},
...
@@ -248,7 +246,7 @@ class ContactsDemoState extends State<ContactsDemo> {
...
@@ -248,7 +246,7 @@ class ContactsDemoState extends State<ContactsDemo> {
icon:
Icons
.
email
,
icon:
Icons
.
email
,
tooltip:
'Send work e-mail'
,
tooltip:
'Send work e-mail'
,
onPressed:
()
{
onPressed:
()
{
_scaffoldKey
.
currentState
.
showSnackBar
(
const
SnackBar
(
ScaffoldMessenger
.
of
(
context
)
.
showSnackBar
(
const
SnackBar
(
content:
Text
(
'Summon your favorite e-mail application here.'
),
content:
Text
(
'Summon your favorite e-mail application here.'
),
));
));
},
},
...
@@ -266,7 +264,7 @@ class ContactsDemoState extends State<ContactsDemo> {
...
@@ -266,7 +264,7 @@ class ContactsDemoState extends State<ContactsDemo> {
icon:
Icons
.
map
,
icon:
Icons
.
map
,
tooltip:
'Open map'
,
tooltip:
'Open map'
,
onPressed:
()
{
onPressed:
()
{
_scaffoldKey
.
currentState
.
showSnackBar
(
const
SnackBar
(
ScaffoldMessenger
.
of
(
context
)
.
showSnackBar
(
const
SnackBar
(
content:
Text
(
'This would show a map of San Francisco.'
),
content:
Text
(
'This would show a map of San Francisco.'
),
));
));
},
},
...
@@ -280,7 +278,7 @@ class ContactsDemoState extends State<ContactsDemo> {
...
@@ -280,7 +278,7 @@ class ContactsDemoState extends State<ContactsDemo> {
icon:
Icons
.
map
,
icon:
Icons
.
map
,
tooltip:
'Open map'
,
tooltip:
'Open map'
,
onPressed:
()
{
onPressed:
()
{
_scaffoldKey
.
currentState
.
showSnackBar
(
const
SnackBar
(
ScaffoldMessenger
.
of
(
context
)
.
showSnackBar
(
const
SnackBar
(
content:
Text
(
'This would show a map of Mountain View.'
),
content:
Text
(
'This would show a map of Mountain View.'
),
));
));
},
},
...
@@ -294,7 +292,7 @@ class ContactsDemoState extends State<ContactsDemo> {
...
@@ -294,7 +292,7 @@ class ContactsDemoState extends State<ContactsDemo> {
icon:
Icons
.
map
,
icon:
Icons
.
map
,
tooltip:
'Open map'
,
tooltip:
'Open map'
,
onPressed:
()
{
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.'
),
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 {
...
@@ -18,7 +18,7 @@ class BottomAppBarDemo extends StatefulWidget {
// for bottom application bar.
// for bottom application bar.
class
_BottomAppBarDemoState
extends
State
<
BottomAppBarDemo
>
{
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
// FAB shape
...
@@ -92,7 +92,7 @@ class _BottomAppBarDemoState extends State<BottomAppBarDemo> {
...
@@ -92,7 +92,7 @@ class _BottomAppBarDemoState extends State<BottomAppBarDemo> {
"When the Scaffold's floating action button location changes, "
"When the Scaffold's floating action button location changes, "
'the floating action button animates to its new position. '
'the floating action button animates to its new position. '
'The BottomAppBar adapts its shape appropriately.'
;
'The BottomAppBar adapts its shape appropriately.'
;
_scaffoldKey
.
currentState
.
showSnackBar
(
_scaffold
Messenger
Key
.
currentState
.
showSnackBar
(
const
SnackBar
(
content:
Text
(
text
)),
const
SnackBar
(
content:
Text
(
text
)),
);
);
}
}
...
@@ -139,61 +139,65 @@ class _BottomAppBarDemoState extends State<BottomAppBarDemo> {
...
@@ -139,61 +139,65 @@ class _BottomAppBarDemoState extends State<BottomAppBarDemo> {
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
return
ScaffoldMessenger
(
key:
_scaffoldKey
,
key:
_scaffoldMessengerKey
,
appBar:
AppBar
(
child:
Builder
(
title:
const
Text
(
'Bottom app bar'
),
builder:
(
BuildContext
context
)
=>
Scaffold
(
elevation:
0.0
,
appBar:
AppBar
(
actions:
<
Widget
>[
title:
const
Text
(
'Bottom app bar'
),
MaterialDemoDocumentationButton
(
BottomAppBarDemo
.
routeName
),
elevation:
0.0
,
IconButton
(
actions:
<
Widget
>[
icon:
const
Icon
(
Icons
.
sentiment_very_satisfied
,
semanticLabel:
'Update shape'
),
MaterialDemoDocumentationButton
(
BottomAppBarDemo
.
routeName
),
onPressed:
()
{
IconButton
(
setState
(()
{
icon:
const
Icon
(
Icons
.
sentiment_very_satisfied
,
semanticLabel:
'Update shape'
),
_fabShape
=
_fabShape
==
kCircularFab
?
kDiamondFab
:
kCircularFab
;
onPressed:
()
{
});
setState
(()
{
},
_fabShape
=
_fabShape
==
kCircularFab
?
kDiamondFab
:
kCircularFab
;
});
},
),
],
),
),
],
body:
Scrollbar
(
),
child:
ListView
(
body:
Scrollbar
(
padding:
const
EdgeInsets
.
only
(
bottom:
88.0
),
child:
ListView
(
children:
<
Widget
>[
padding:
const
EdgeInsets
.
only
(
bottom:
88.0
),
const
_Heading
(
'FAB Shape'
),
children:
<
Widget
>[
const
_Heading
(
'FAB Shape'
),
_RadioItem
<
Widget
>(
kCircularFab
,
_fabShape
,
_onFabShapeChanged
),
_RadioItem
<
Widget
>(
kCircularFab
,
_fabShape
,
_onFabShapeChanged
),
_RadioItem
<
Widget
>(
kDiamondFab
,
_fabShape
,
_onFabShapeChanged
),
_RadioItem
<
Widget
>(
kDiamondFab
,
_fabShape
,
_onFabShapeChanged
),
_RadioItem
<
Widget
>(
kNoFab
,
_fabShape
,
_onFabShapeChanged
),
_RadioItem
<
Widget
>(
kNoFab
,
_fabShape
,
_onFabShapeChanged
),
const
Divider
(),
const
Divider
(),
const
_Heading
(
'Notch'
),
const
_Heading
(
'Notch'
),
_RadioItem
<
bool
>(
kShowNotchTrue
,
_showNotch
,
_onShowNotchChanged
),
_RadioItem
<
bool
>(
kShowNotchTrue
,
_showNotch
,
_onShowNotchChanged
),
_RadioItem
<
bool
>(
kShowNotchFalse
,
_showNotch
,
_onShowNotchChanged
),
_RadioItem
<
bool
>(
kShowNotchFalse
,
_showNotch
,
_onShowNotchChanged
),
const
Divider
(),
const
Divider
(),
const
_Heading
(
'FAB Position'
),
const
_Heading
(
'FAB Position'
),
_RadioItem
<
FloatingActionButtonLocation
>(
kFabEndDocked
,
_fabLocation
,
_onFabLocationChanged
),
_RadioItem
<
FloatingActionButtonLocation
>(
kFabEndDocked
,
_fabLocation
,
_onFabLocationChanged
),
_RadioItem
<
FloatingActionButtonLocation
>(
kFabCenterDocked
,
_fabLocation
,
_onFabLocationChanged
),
_RadioItem
<
FloatingActionButtonLocation
>(
kFabCenterDocked
,
_fabLocation
,
_onFabLocationChanged
),
_RadioItem
<
FloatingActionButtonLocation
>(
kFabEndFloat
,
_fabLocation
,
_onFabLocationChanged
),
_RadioItem
<
FloatingActionButtonLocation
>(
kFabEndFloat
,
_fabLocation
,
_onFabLocationChanged
),
_RadioItem
<
FloatingActionButtonLocation
>(
kFabCenterFloat
,
_fabLocation
,
_onFabLocationChanged
),
_RadioItem
<
FloatingActionButtonLocation
>(
kFabCenterFloat
,
_fabLocation
,
_onFabLocationChanged
),
const
Divider
(),
const
Divider
(),
const
_Heading
(
'App bar color'
),
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 {
...
@@ -364,7 +368,7 @@ class _DemoBottomAppBar extends StatelessWidget {
IconButton
(
IconButton
(
icon:
const
Icon
(
Icons
.
search
,
semanticLabel:
'show search action'
,),
icon:
const
Icon
(
Icons
.
search
,
semanticLabel:
'show search action'
,),
onPressed:
()
{
onPressed:
()
{
Scaffold
.
of
(
context
).
showSnackBar
(
Scaffold
Messenger
.
of
(
context
).
showSnackBar
(
const
SnackBar
(
content:
Text
(
'This is a dummy search action.'
)),
const
SnackBar
(
content:
Text
(
'This is a dummy search action.'
)),
);
);
},
},
...
@@ -377,7 +381,7 @@ class _DemoBottomAppBar extends StatelessWidget {
...
@@ -377,7 +381,7 @@ class _DemoBottomAppBar extends StatelessWidget {
semanticLabel:
'Show menu actions'
,
semanticLabel:
'Show menu actions'
,
),
),
onPressed:
()
{
onPressed:
()
{
Scaffold
.
of
(
context
).
showSnackBar
(
Scaffold
Messenger
.
of
(
context
).
showSnackBar
(
const
SnackBar
(
content:
Text
(
'This is a dummy menu action.'
)),
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 {
...
@@ -55,7 +55,6 @@ class DialogDemo extends StatefulWidget {
}
}
class
DialogDemoState
extends
State
<
DialogDemo
>
{
class
DialogDemoState
extends
State
<
DialogDemo
>
{
final
GlobalKey
<
ScaffoldState
>
_scaffoldKey
=
GlobalKey
<
ScaffoldState
>();
TimeOfDay
_selectedTime
;
TimeOfDay
_selectedTime
;
...
@@ -73,7 +72,7 @@ class DialogDemoState extends State<DialogDemo> {
...
@@ -73,7 +72,7 @@ class DialogDemoState extends State<DialogDemo> {
)
)
.
then
<
void
>((
T
value
)
{
// The value passed to Navigator.pop() or null.
.
then
<
void
>((
T
value
)
{
// The value passed to Navigator.pop() or null.
if
(
value
!=
null
)
{
if
(
value
!=
null
)
{
_scaffoldKey
.
currentState
.
showSnackBar
(
SnackBar
(
ScaffoldMessenger
.
of
(
context
)
.
showSnackBar
(
SnackBar
(
content:
Text
(
'You selected:
$value
'
),
content:
Text
(
'You selected:
$value
'
),
));
));
}
}
...
@@ -86,7 +85,6 @@ class DialogDemoState extends State<DialogDemo> {
...
@@ -86,7 +85,6 @@ class DialogDemoState extends State<DialogDemo> {
final
TextStyle
dialogTextStyle
=
theme
.
textTheme
.
subtitle1
.
copyWith
(
color:
theme
.
textTheme
.
caption
.
color
);
final
TextStyle
dialogTextStyle
=
theme
.
textTheme
.
subtitle1
.
copyWith
(
color:
theme
.
textTheme
.
caption
.
color
);
return
Scaffold
(
return
Scaffold
(
key:
_scaffoldKey
,
appBar:
AppBar
(
appBar:
AppBar
(
title:
const
Text
(
'Dialogs'
),
title:
const
Text
(
'Dialogs'
),
actions:
<
Widget
>[
MaterialDemoDocumentationButton
(
DialogDemo
.
routeName
)],
actions:
<
Widget
>[
MaterialDemoDocumentationButton
(
DialogDemo
.
routeName
)],
...
@@ -183,7 +181,7 @@ class DialogDemoState extends State<DialogDemo> {
...
@@ -183,7 +181,7 @@ class DialogDemoState extends State<DialogDemo> {
.
then
<
void
>((
TimeOfDay
value
)
{
.
then
<
void
>((
TimeOfDay
value
)
{
if
(
value
!=
null
&&
value
!=
_selectedTime
)
{
if
(
value
!=
null
&&
value
!=
_selectedTime
)
{
_selectedTime
=
value
;
_selectedTime
=
value
;
_scaffoldKey
.
currentState
.
showSnackBar
(
SnackBar
(
ScaffoldMessenger
.
of
(
context
)
.
showSnackBar
(
SnackBar
(
content:
Text
(
'You selected:
${value.format(context)}
'
),
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 {
...
@@ -75,7 +75,7 @@ class _DrawerDemoState extends State<DrawerDemo> with TickerProviderStateMixin {
void
_showNotImplementedMessage
()
{
void
_showNotImplementedMessage
()
{
Navigator
.
pop
(
context
);
// Dismiss the drawer.
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"
),
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 {
...
@@ -42,7 +42,6 @@ class LeaveBehindDemo extends StatefulWidget {
}
}
class
LeaveBehindDemoState
extends
State
<
LeaveBehindDemo
>
{
class
LeaveBehindDemoState
extends
State
<
LeaveBehindDemo
>
{
static
final
GlobalKey
<
ScaffoldState
>
_scaffoldKey
=
GlobalKey
<
ScaffoldState
>();
DismissDirection
_dismissDirection
=
DismissDirection
.
horizontal
;
DismissDirection
_dismissDirection
=
DismissDirection
.
horizontal
;
bool
_confirmDismiss
=
true
;
bool
_confirmDismiss
=
true
;
List
<
LeaveBehindItem
>
leaveBehindItems
;
List
<
LeaveBehindItem
>
leaveBehindItems
;
...
@@ -97,7 +96,7 @@ class LeaveBehindDemoState extends State<LeaveBehindDemo> {
...
@@ -97,7 +96,7 @@ class LeaveBehindDemoState extends State<LeaveBehindDemo> {
setState
(()
{
setState
(()
{
leaveBehindItems
.
remove
(
item
);
leaveBehindItems
.
remove
(
item
);
});
});
_scaffoldKey
.
currentState
.
showSnackBar
(
SnackBar
(
ScaffoldMessenger
.
of
(
context
)
.
showSnackBar
(
SnackBar
(
content:
Text
(
'You archived item
${item.index}
'
),
content:
Text
(
'You archived item
${item.index}
'
),
action:
SnackBarAction
(
action:
SnackBarAction
(
label:
'UNDO'
,
label:
'UNDO'
,
...
@@ -110,7 +109,7 @@ class LeaveBehindDemoState extends State<LeaveBehindDemo> {
...
@@ -110,7 +109,7 @@ class LeaveBehindDemoState extends State<LeaveBehindDemo> {
setState
(()
{
setState
(()
{
leaveBehindItems
.
remove
(
item
);
leaveBehindItems
.
remove
(
item
);
});
});
_scaffoldKey
.
currentState
.
showSnackBar
(
SnackBar
(
ScaffoldMessenger
.
of
(
context
)
.
showSnackBar
(
SnackBar
(
content:
Text
(
'You deleted item
${item.index}
'
),
content:
Text
(
'You deleted item
${item.index}
'
),
action:
SnackBarAction
(
action:
SnackBarAction
(
label:
'UNDO'
,
label:
'UNDO'
,
...
@@ -146,7 +145,6 @@ class LeaveBehindDemoState extends State<LeaveBehindDemo> {
...
@@ -146,7 +145,6 @@ class LeaveBehindDemoState extends State<LeaveBehindDemo> {
}
}
return
Scaffold
(
return
Scaffold
(
key:
_scaffoldKey
,
appBar:
AppBar
(
appBar:
AppBar
(
title:
const
Text
(
'Swipe to dismiss'
),
title:
const
Text
(
'Swipe to dismiss'
),
actions:
<
Widget
>[
actions:
<
Widget
>[
...
...
dev/integration_tests/flutter_gallery/lib/demo/material/menu_demo.dart
View file @
cd60da78
...
@@ -16,7 +16,6 @@ class MenuDemo extends StatefulWidget {
...
@@ -16,7 +16,6 @@ class MenuDemo extends StatefulWidget {
}
}
class
MenuDemoState
extends
State
<
MenuDemo
>
{
class
MenuDemoState
extends
State
<
MenuDemo
>
{
final
GlobalKey
<
ScaffoldState
>
_scaffoldKey
=
GlobalKey
<
ScaffoldState
>();
final
String
_simpleValue1
=
'Menu item value one'
;
final
String
_simpleValue1
=
'Menu item value one'
;
final
String
_simpleValue2
=
'Menu item value two'
;
final
String
_simpleValue2
=
'Menu item value two'
;
...
@@ -37,7 +36,7 @@ class MenuDemoState extends State<MenuDemo> {
...
@@ -37,7 +36,7 @@ class MenuDemoState extends State<MenuDemo> {
}
}
void
showInSnackBar
(
String
value
)
{
void
showInSnackBar
(
String
value
)
{
_scaffoldKey
.
currentState
.
showSnackBar
(
SnackBar
(
ScaffoldMessenger
.
of
(
context
)
.
showSnackBar
(
SnackBar
(
content:
Text
(
value
),
content:
Text
(
value
),
));
));
}
}
...
@@ -62,7 +61,6 @@ class MenuDemoState extends State<MenuDemo> {
...
@@ -62,7 +61,6 @@ class MenuDemoState extends State<MenuDemo> {
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
return
Scaffold
(
key:
_scaffoldKey
,
appBar:
AppBar
(
appBar:
AppBar
(
title:
const
Text
(
'Menus'
),
title:
const
Text
(
'Menus'
),
actions:
<
Widget
>[
actions:
<
Widget
>[
...
...
dev/integration_tests/flutter_gallery/lib/demo/material/overscroll_demo.dart
View file @
cd60da78
...
@@ -20,7 +20,6 @@ class OverscrollDemo extends StatefulWidget {
...
@@ -20,7 +20,6 @@ class OverscrollDemo extends StatefulWidget {
}
}
class
OverscrollDemoState
extends
State
<
OverscrollDemo
>
{
class
OverscrollDemoState
extends
State
<
OverscrollDemo
>
{
final
GlobalKey
<
ScaffoldState
>
_scaffoldKey
=
GlobalKey
<
ScaffoldState
>();
final
GlobalKey
<
RefreshIndicatorState
>
_refreshIndicatorKey
=
GlobalKey
<
RefreshIndicatorState
>();
final
GlobalKey
<
RefreshIndicatorState
>
_refreshIndicatorKey
=
GlobalKey
<
RefreshIndicatorState
>();
static
final
List
<
String
>
_items
=
<
String
>[
static
final
List
<
String
>
_items
=
<
String
>[
'A'
,
'B'
,
'C'
,
'D'
,
'E'
,
'F'
,
'G'
,
'H'
,
'I'
,
'J'
,
'K'
,
'L'
,
'M'
,
'N'
,
'A'
,
'B'
,
'C'
,
'D'
,
'E'
,
'F'
,
'G'
,
'H'
,
'I'
,
'J'
,
'K'
,
'L'
,
'M'
,
'N'
,
...
@@ -30,7 +29,7 @@ class OverscrollDemoState extends State<OverscrollDemo> {
...
@@ -30,7 +29,7 @@ class OverscrollDemoState extends State<OverscrollDemo> {
final
Completer
<
void
>
completer
=
Completer
<
void
>();
final
Completer
<
void
>
completer
=
Completer
<
void
>();
Timer
(
const
Duration
(
seconds:
3
),
()
{
completer
.
complete
();
});
Timer
(
const
Duration
(
seconds:
3
),
()
{
completer
.
complete
();
});
return
completer
.
future
.
then
<
void
>((
_
)
{
return
completer
.
future
.
then
<
void
>((
_
)
{
_scaffoldKey
.
currentState
?
.
showSnackBar
(
SnackBar
(
ScaffoldMessenger
.
of
(
context
)
.
showSnackBar
(
SnackBar
(
content:
const
Text
(
'Refresh complete'
),
content:
const
Text
(
'Refresh complete'
),
action:
SnackBarAction
(
action:
SnackBarAction
(
label:
'RETRY'
,
label:
'RETRY'
,
...
@@ -45,7 +44,6 @@ class OverscrollDemoState extends State<OverscrollDemo> {
...
@@ -45,7 +44,6 @@ class OverscrollDemoState extends State<OverscrollDemo> {
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
return
Scaffold
(
key:
_scaffoldKey
,
appBar:
AppBar
(
appBar:
AppBar
(
title:
const
Text
(
'Pull to refresh'
),
title:
const
Text
(
'Pull to refresh'
),
actions:
<
Widget
>[
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> {
...
@@ -44,12 +44,12 @@ class _SnackBarDemoState extends State<SnackBarDemo> {
child:
const
Text
(
'SHOW A SNACKBAR'
),
child:
const
Text
(
'SHOW A SNACKBAR'
),
onPressed:
()
{
onPressed:
()
{
final
int
thisSnackBarIndex
=
_snackBarIndex
++;
final
int
thisSnackBarIndex
=
_snackBarIndex
++;
Scaffold
.
of
(
context
).
showSnackBar
(
SnackBar
(
Scaffold
Messenger
.
of
(
context
).
showSnackBar
(
SnackBar
(
content:
Text
(
'This is snackbar #
$thisSnackBarIndex
.'
),
content:
Text
(
'This is snackbar #
$thisSnackBarIndex
.'
),
action:
SnackBarAction
(
action:
SnackBarAction
(
label:
'ACTION'
,
label:
'ACTION'
,
onPressed:
()
{
onPressed:
()
{
Scaffold
.
of
(
context
).
showSnackBar
(
SnackBar
(
Scaffold
Messenger
.
of
(
context
).
showSnackBar
(
SnackBar
(
content:
Text
(
"You pressed snackbar
$thisSnackBarIndex
's action."
),
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> {
...
@@ -83,12 +83,11 @@ class _PasswordFieldState extends State<PasswordField> {
}
}
class
TextFormFieldDemoState
extends
State
<
TextFormFieldDemo
>
{
class
TextFormFieldDemoState
extends
State
<
TextFormFieldDemo
>
{
final
GlobalKey
<
ScaffoldState
>
_scaffoldKey
=
GlobalKey
<
ScaffoldState
>();
PersonData
person
=
PersonData
();
PersonData
person
=
PersonData
();
void
showInSnackBar
(
String
value
)
{
void
showInSnackBar
(
String
value
)
{
_scaffoldKey
.
currentState
.
showSnackBar
(
SnackBar
(
ScaffoldMessenger
.
of
(
context
)
.
showSnackBar
(
SnackBar
(
content:
Text
(
value
),
content:
Text
(
value
),
));
));
}
}
...
@@ -168,7 +167,6 @@ class TextFormFieldDemoState extends State<TextFormFieldDemo> {
...
@@ -168,7 +167,6 @@ class TextFormFieldDemoState extends State<TextFormFieldDemo> {
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
return
Scaffold
(
drawerDragStartBehavior:
DragStartBehavior
.
down
,
drawerDragStartBehavior:
DragStartBehavior
.
down
,
key:
_scaffoldKey
,
appBar:
AppBar
(
appBar:
AppBar
(
title:
const
Text
(
'Text fields'
),
title:
const
Text
(
'Text fields'
),
actions:
<
Widget
>[
MaterialDemoDocumentationButton
(
TextFormFieldDemo
.
routeName
)],
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 {
...
@@ -52,7 +52,7 @@ class TooltipDemo extends StatelessWidget {
color:
theme
.
iconTheme
.
color
,
color:
theme
.
iconTheme
.
color
,
tooltip:
'Place a phone call'
,
tooltip:
'Place a phone call'
,
onPressed:
()
{
onPressed:
()
{
Scaffold
.
of
(
context
).
showSnackBar
(
const
SnackBar
(
Scaffold
Messenger
.
of
(
context
).
showSnackBar
(
const
SnackBar
(
content:
Text
(
'That was an ordinary tap.'
),
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 {
...
@@ -73,7 +73,6 @@ class RecipeGridPage extends StatefulWidget {
}
}
class
_RecipeGridPageState
extends
State
<
RecipeGridPage
>
{
class
_RecipeGridPageState
extends
State
<
RecipeGridPage
>
{
final
GlobalKey
<
ScaffoldState
>
scaffoldKey
=
GlobalKey
<
ScaffoldState
>();
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
...
@@ -81,11 +80,10 @@ class _RecipeGridPageState extends State<RecipeGridPage> {
...
@@ -81,11 +80,10 @@ class _RecipeGridPageState extends State<RecipeGridPage> {
return
Theme
(
return
Theme
(
data:
_kTheme
.
copyWith
(
platform:
Theme
.
of
(
context
).
platform
),
data:
_kTheme
.
copyWith
(
platform:
Theme
.
of
(
context
).
platform
),
child:
Scaffold
(
child:
Scaffold
(
key:
scaffoldKey
,
floatingActionButton:
FloatingActionButton
(
floatingActionButton:
FloatingActionButton
(
child:
const
Icon
(
Icons
.
edit
),
child:
const
Icon
(
Icons
.
edit
),
onPressed:
()
{
onPressed:
()
{
scaffoldKey
.
currentState
.
showSnackBar
(
const
SnackBar
(
ScaffoldMessenger
.
of
(
context
)
.
showSnackBar
(
const
SnackBar
(
content:
Text
(
'Not supported.'
),
content:
Text
(
'Not supported.'
),
));
));
},
},
...
@@ -110,7 +108,7 @@ class _RecipeGridPageState extends State<RecipeGridPage> {
...
@@ -110,7 +108,7 @@ class _RecipeGridPageState extends State<RecipeGridPage> {
icon:
const
Icon
(
Icons
.
search
),
icon:
const
Icon
(
Icons
.
search
),
tooltip:
'Search'
,
tooltip:
'Search'
,
onPressed:
()
{
onPressed:
()
{
scaffoldKey
.
currentState
.
showSnackBar
(
const
SnackBar
(
ScaffoldMessenger
.
of
(
context
)
.
showSnackBar
(
const
SnackBar
(
content:
Text
(
'Not supported.'
),
content:
Text
(
'Not supported.'
),
));
));
},
},
...
@@ -322,7 +320,6 @@ class RecipePage extends StatefulWidget {
...
@@ -322,7 +320,6 @@ class RecipePage extends StatefulWidget {
}
}
class
_RecipePageState
extends
State
<
RecipePage
>
{
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
);
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
;
double
_getAppBarHeight
(
BuildContext
context
)
=>
MediaQuery
.
of
(
context
).
size
.
height
*
0.3
;
...
@@ -337,7 +334,6 @@ class _RecipePageState extends State<RecipePage> {
...
@@ -337,7 +334,6 @@ class _RecipePageState extends State<RecipePage> {
final
bool
fullWidth
=
screenSize
.
width
<
_kRecipePageMaxWidth
;
final
bool
fullWidth
=
screenSize
.
width
<
_kRecipePageMaxWidth
;
final
bool
isFavorite
=
_favoriteRecipes
.
contains
(
widget
.
recipe
);
final
bool
isFavorite
=
_favoriteRecipes
.
contains
(
widget
.
recipe
);
return
Scaffold
(
return
Scaffold
(
key:
_scaffoldKey
,
body:
Stack
(
body:
Stack
(
children:
<
Widget
>[
children:
<
Widget
>[
Positioned
(
Positioned
(
...
...
dev/integration_tests/flutter_gallery/lib/demo/video_demo.dart
View file @
cd60da78
...
@@ -266,12 +266,10 @@ class ConnectivityOverlay extends StatefulWidget {
...
@@ -266,12 +266,10 @@ class ConnectivityOverlay extends StatefulWidget {
const
ConnectivityOverlay
({
const
ConnectivityOverlay
({
this
.
child
,
this
.
child
,
this
.
connectedCompleter
,
this
.
connectedCompleter
,
this
.
scaffoldKey
,
});
});
final
Widget
child
;
final
Widget
child
;
final
Completer
<
void
>
connectedCompleter
;
final
Completer
<
void
>
connectedCompleter
;
final
GlobalKey
<
ScaffoldState
>
scaffoldKey
;
@override
@override
_ConnectivityOverlayState
createState
()
=>
_ConnectivityOverlayState
();
_ConnectivityOverlayState
createState
()
=>
_ConnectivityOverlayState
();
...
@@ -321,7 +319,7 @@ class _ConnectivityOverlayState extends State<ConnectivityOverlay> {
...
@@ -321,7 +319,7 @@ class _ConnectivityOverlayState extends State<ConnectivityOverlay> {
return
;
return
;
}
}
if
(
connectivityResult
==
ConnectivityResult
.
none
)
{
if
(
connectivityResult
==
ConnectivityResult
.
none
)
{
widget
.
scaffoldKey
.
currentState
.
showSnackBar
(
errorSnackBar
);
ScaffoldMessenger
.
of
(
context
)
.
showSnackBar
(
errorSnackBar
);
}
else
{
}
else
{
if
(!
widget
.
connectedCompleter
.
isCompleted
)
{
if
(!
widget
.
connectedCompleter
.
isCompleted
)
{
widget
.
connectedCompleter
.
complete
(
null
);
widget
.
connectedCompleter
.
complete
(
null
);
...
@@ -368,7 +366,6 @@ class _VideoDemoState extends State<VideoDemo> with SingleTickerProviderStateMix
...
@@ -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'
;
static
const
String
beeUri
=
'https://flutter.github.io/assets-for-api-docs/assets/videos/bee.mp4'
;
final
VideoPlayerController
beeController
=
VideoPlayerController
.
network
(
beeUri
);
final
VideoPlayerController
beeController
=
VideoPlayerController
.
network
(
beeUri
);
final
GlobalKey
<
ScaffoldState
>
scaffoldKey
=
GlobalKey
<
ScaffoldState
>();
final
Completer
<
void
>
connectedCompleter
=
Completer
<
void
>();
final
Completer
<
void
>
connectedCompleter
=
Completer
<
void
>();
bool
isSupported
=
true
;
bool
isSupported
=
true
;
bool
isDisposed
=
false
;
bool
isDisposed
=
false
;
...
@@ -410,7 +407,6 @@ class _VideoDemoState extends State<VideoDemo> with SingleTickerProviderStateMix
...
@@ -410,7 +407,6 @@ class _VideoDemoState extends State<VideoDemo> with SingleTickerProviderStateMix
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
return
Scaffold
(
key:
scaffoldKey
,
appBar:
AppBar
(
appBar:
AppBar
(
title:
const
Text
(
'Videos'
),
title:
const
Text
(
'Videos'
),
),
),
...
@@ -433,7 +429,6 @@ class _VideoDemoState extends State<VideoDemo> with SingleTickerProviderStateMix
...
@@ -433,7 +429,6 @@ class _VideoDemoState extends State<VideoDemo> with SingleTickerProviderStateMix
),
),
),
),
connectedCompleter:
connectedCompleter
,
connectedCompleter:
connectedCompleter
,
scaffoldKey:
scaffoldKey
,
)
)
:
const
Center
(
:
const
Center
(
child:
Text
(
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> {
...
@@ -169,7 +169,7 @@ class MotionEventsBodyState extends State<MotionEventsBody> {
}
}
void
showMessage
(
BuildContext
context
,
String
message
)
{
void
showMessage
(
BuildContext
context
,
String
message
)
{
Scaffold
.
of
(
context
).
showSnackBar
(
SnackBar
(
Scaffold
Messenger
.
of
(
context
).
showSnackBar
(
SnackBar
(
content:
Text
(
message
),
content:
Text
(
message
),
duration:
const
Duration
(
seconds:
3
),
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