make some widgets const (#9477)
This commit is contained in:
committed by
GitHub
parent
cbb49179c9
commit
03c54abd5f
@@ -128,15 +128,15 @@ class ContactsDemoState extends State<ContactsDemo> {
|
||||
});
|
||||
},
|
||||
itemBuilder: (BuildContext context) => <PopupMenuItem<AppBarBehavior>>[
|
||||
new PopupMenuItem<AppBarBehavior>(
|
||||
const PopupMenuItem<AppBarBehavior>(
|
||||
value: AppBarBehavior.normal,
|
||||
child: const Text('App bar scrolls away')
|
||||
),
|
||||
new PopupMenuItem<AppBarBehavior>(
|
||||
const PopupMenuItem<AppBarBehavior>(
|
||||
value: AppBarBehavior.pinned,
|
||||
child: const Text('App bar stays put')
|
||||
),
|
||||
new PopupMenuItem<AppBarBehavior>(
|
||||
const PopupMenuItem<AppBarBehavior>(
|
||||
value: AppBarBehavior.floating,
|
||||
child: const Text('App bar floats')
|
||||
),
|
||||
|
||||
@@ -192,11 +192,11 @@ class _BottomNavigationDemoState extends State<BottomNavigationDemo>
|
||||
});
|
||||
},
|
||||
itemBuilder: (BuildContext context) => <PopupMenuItem<BottomNavigationBarType>>[
|
||||
new PopupMenuItem<BottomNavigationBarType>(
|
||||
const PopupMenuItem<BottomNavigationBarType>(
|
||||
value: BottomNavigationBarType.fixed,
|
||||
child: const Text('Fixed'),
|
||||
),
|
||||
new PopupMenuItem<BottomNavigationBarType>(
|
||||
const PopupMenuItem<BottomNavigationBarType>(
|
||||
value: BottomNavigationBarType.shifting,
|
||||
child: const Text('Shifting'),
|
||||
)
|
||||
|
||||
@@ -317,15 +317,15 @@ class GridListDemoState extends State<GridListDemo> {
|
||||
new PopupMenuButton<GridDemoTileStyle>(
|
||||
onSelected: changeTileStyle,
|
||||
itemBuilder: (BuildContext context) => <PopupMenuItem<GridDemoTileStyle>>[
|
||||
new PopupMenuItem<GridDemoTileStyle>(
|
||||
const PopupMenuItem<GridDemoTileStyle>(
|
||||
value: GridDemoTileStyle.imageOnly,
|
||||
child: const Text('Image only'),
|
||||
),
|
||||
new PopupMenuItem<GridDemoTileStyle>(
|
||||
const PopupMenuItem<GridDemoTileStyle>(
|
||||
value: GridDemoTileStyle.oneLine,
|
||||
child: const Text('One line'),
|
||||
),
|
||||
new PopupMenuItem<GridDemoTileStyle>(
|
||||
const PopupMenuItem<GridDemoTileStyle>(
|
||||
value: GridDemoTileStyle.twoLine,
|
||||
child: const Text('Two line'),
|
||||
),
|
||||
|
||||
@@ -137,11 +137,11 @@ class LeaveBehindDemoState extends State<LeaveBehindDemo> {
|
||||
new PopupMenuButton<LeaveBehindDemoAction>(
|
||||
onSelected: handleDemoAction,
|
||||
itemBuilder: (BuildContext context) => <PopupMenuEntry<LeaveBehindDemoAction>>[
|
||||
new PopupMenuItem<LeaveBehindDemoAction>(
|
||||
const PopupMenuItem<LeaveBehindDemoAction>(
|
||||
value: LeaveBehindDemoAction.reset,
|
||||
child: const Text('Reset the list')
|
||||
),
|
||||
new PopupMenuDivider(), // ignore: list_element_type_not_assignable, https://github.com/flutter/flutter/issues/5771
|
||||
const PopupMenuDivider(), // ignore: list_element_type_not_assignable, https://github.com/flutter/flutter/issues/5771
|
||||
new CheckedPopupMenuItem<LeaveBehindDemoAction>(
|
||||
value: LeaveBehindDemoAction.horizontalSwipe,
|
||||
checked: _dismissDirection == DismissDirection.horizontal,
|
||||
|
||||
@@ -67,15 +67,15 @@ class MenuDemoState extends State<MenuDemo> {
|
||||
new PopupMenuButton<String>(
|
||||
onSelected: showMenuSelection,
|
||||
itemBuilder: (BuildContext context) => <PopupMenuItem<String>>[
|
||||
new PopupMenuItem<String>(
|
||||
const PopupMenuItem<String>(
|
||||
value: 'Toolbar menu',
|
||||
child: const Text('Toolbar menu')
|
||||
),
|
||||
new PopupMenuItem<String>(
|
||||
const PopupMenuItem<String>(
|
||||
value: 'Right here',
|
||||
child: const Text('Right here')
|
||||
),
|
||||
new PopupMenuItem<String>(
|
||||
const PopupMenuItem<String>(
|
||||
value: 'Hooray!',
|
||||
child: const Text('Hooray!')
|
||||
),
|
||||
@@ -99,7 +99,7 @@ class MenuDemoState extends State<MenuDemo> {
|
||||
value: _simpleValue1,
|
||||
child: const Text('Context menu item one')
|
||||
),
|
||||
new PopupMenuItem<String>(
|
||||
const PopupMenuItem<String>(
|
||||
enabled: false,
|
||||
child: const Text('A disabled menu item')
|
||||
),
|
||||
@@ -140,7 +140,7 @@ class MenuDemoState extends State<MenuDemo> {
|
||||
title: const Text('Get link')
|
||||
)
|
||||
),
|
||||
new PopupMenuDivider(), // ignore: list_element_type_not_assignable, https://github.com/flutter/flutter/issues/5771
|
||||
const PopupMenuDivider(), // ignore: list_element_type_not_assignable, https://github.com/flutter/flutter/issues/5771
|
||||
new PopupMenuItem<String>(
|
||||
value: 'Remove',
|
||||
child: new ListTile(
|
||||
|
||||
@@ -63,17 +63,17 @@ class _ProgressIndicatorDemoState extends State<ProgressIndicatorDemo> with Sing
|
||||
|
||||
Widget _buildIndicators(BuildContext context, Widget child) {
|
||||
final List<Widget> indicators = <Widget>[
|
||||
new SizedBox(
|
||||
const SizedBox(
|
||||
width: 200.0,
|
||||
child: new LinearProgressIndicator()
|
||||
child: const LinearProgressIndicator()
|
||||
),
|
||||
new LinearProgressIndicator(),
|
||||
new LinearProgressIndicator(),
|
||||
const LinearProgressIndicator(),
|
||||
const LinearProgressIndicator(),
|
||||
new LinearProgressIndicator(value: _animation.value),
|
||||
new Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: <Widget>[
|
||||
new CircularProgressIndicator(),
|
||||
const CircularProgressIndicator(),
|
||||
new SizedBox(
|
||||
width: 20.0,
|
||||
height: 20.0,
|
||||
|
||||
@@ -64,15 +64,15 @@ class ScrollableTabsDemoState extends State<ScrollableTabsDemo> with SingleTicke
|
||||
new PopupMenuButton<TabsDemoStyle>(
|
||||
onSelected: changeDemoStyle,
|
||||
itemBuilder: (BuildContext context) => <PopupMenuItem<TabsDemoStyle>>[
|
||||
new PopupMenuItem<TabsDemoStyle>(
|
||||
const PopupMenuItem<TabsDemoStyle>(
|
||||
value: TabsDemoStyle.iconsAndText,
|
||||
child: const Text('Icons and text')
|
||||
),
|
||||
new PopupMenuItem<TabsDemoStyle>(
|
||||
const PopupMenuItem<TabsDemoStyle>(
|
||||
value: TabsDemoStyle.iconsOnly,
|
||||
child: const Text('Icons only')
|
||||
),
|
||||
new PopupMenuItem<TabsDemoStyle>(
|
||||
const PopupMenuItem<TabsDemoStyle>(
|
||||
value: TabsDemoStyle.textOnly,
|
||||
child: const Text('Text only')
|
||||
),
|
||||
|
||||
@@ -174,8 +174,8 @@ class _SelectionControlsDemoState extends State<SelectionControlsDemo> {
|
||||
}
|
||||
),
|
||||
// Disabled switches
|
||||
new Switch(value: true, onChanged: null),
|
||||
new Switch(value: false, onChanged: null)
|
||||
const Switch(value: true, onChanged: null),
|
||||
const Switch(value: false, onChanged: null)
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
@@ -113,15 +113,15 @@ class ShrinePageState extends State<ShrinePage> {
|
||||
),
|
||||
new PopupMenuButton<ShrineAction>(
|
||||
itemBuilder: (BuildContext context) => <PopupMenuItem<ShrineAction>>[
|
||||
new PopupMenuItem<ShrineAction>(
|
||||
const PopupMenuItem<ShrineAction>(
|
||||
value: ShrineAction.sortByPrice,
|
||||
child: const Text('Sort by price')
|
||||
),
|
||||
new PopupMenuItem<ShrineAction>(
|
||||
const PopupMenuItem<ShrineAction>(
|
||||
value: ShrineAction.sortByProduct,
|
||||
child: const Text('Sort by product')
|
||||
),
|
||||
new PopupMenuItem<ShrineAction>(
|
||||
const PopupMenuItem<ShrineAction>(
|
||||
value: ShrineAction.emptyCart,
|
||||
child: const Text('Empty shopping cart')
|
||||
)
|
||||
|
||||
@@ -128,8 +128,8 @@ class FullScreenCodeDialogState extends State<FullScreenCodeDialog> {
|
||||
|
||||
Widget body;
|
||||
if (_exampleCode == null) {
|
||||
body = new Center(
|
||||
child: new CircularProgressIndicator()
|
||||
body = const Center(
|
||||
child: const CircularProgressIndicator()
|
||||
);
|
||||
} else {
|
||||
body = new SingleChildScrollView(
|
||||
|
||||
@@ -192,7 +192,7 @@ new Switch(
|
||||
// Create a disabled switch.
|
||||
// Switches are disabled when onChanged isn't
|
||||
// specified or null.
|
||||
new Switch(value: false, onChanged: null);
|
||||
const Switch(value: false, onChanged: null);
|
||||
// END
|
||||
}
|
||||
}
|
||||
|
||||
@@ -209,15 +209,15 @@ class StockHomeState extends State<StockHome> {
|
||||
checked: _autorefresh,
|
||||
child: const Text('Autorefresh'),
|
||||
),
|
||||
new PopupMenuItem<_StockMenuItem>(
|
||||
const PopupMenuItem<_StockMenuItem>(
|
||||
value: _StockMenuItem.refresh,
|
||||
child: const Text('Refresh'),
|
||||
),
|
||||
new PopupMenuItem<_StockMenuItem>(
|
||||
const PopupMenuItem<_StockMenuItem>(
|
||||
value: _StockMenuItem.speedUp,
|
||||
child: const Text('Increase animation speed'),
|
||||
),
|
||||
new PopupMenuItem<_StockMenuItem>(
|
||||
const PopupMenuItem<_StockMenuItem>(
|
||||
value: _StockMenuItem.speedDown,
|
||||
child: const Text('Decrease animation speed'),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user