forked from firka/flutter
Make Flex,Row,Column const for real (#119673)
* Make Flex,Row,Column const for real * dart fix --apply * fix snippets * fix integration test * add comment
This commit is contained in:
committed by
GitHub
parent
3f986e4238
commit
b0f1714b7b
@@ -25,8 +25,8 @@ class CupertinoIndicatorExample extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return CupertinoPageScaffold(
|
||||
navigationBar: const CupertinoNavigationBar(
|
||||
return const CupertinoPageScaffold(
|
||||
navigationBar: CupertinoNavigationBar(
|
||||
middle: Text('CupertinoActivityIndicator Sample'),
|
||||
),
|
||||
child: Center(
|
||||
@@ -35,7 +35,7 @@ class CupertinoIndicatorExample extends StatelessWidget {
|
||||
children: <Widget>[
|
||||
Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: const <Widget>[
|
||||
children: <Widget>[
|
||||
// Cupertino activity indicator with default properties.
|
||||
CupertinoActivityIndicator(),
|
||||
SizedBox(height: 10),
|
||||
@@ -44,7 +44,7 @@ class CupertinoIndicatorExample extends StatelessWidget {
|
||||
),
|
||||
Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: const <Widget>[
|
||||
children: <Widget>[
|
||||
// Cupertino activity indicator with custom radius and color.
|
||||
CupertinoActivityIndicator(radius: 20.0, color: CupertinoColors.activeBlue),
|
||||
SizedBox(height: 10),
|
||||
@@ -56,7 +56,7 @@ class CupertinoIndicatorExample extends StatelessWidget {
|
||||
),
|
||||
Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: const <Widget>[
|
||||
children: <Widget>[
|
||||
// Cupertino activity indicator with custom radius and disabled
|
||||
// animation.
|
||||
CupertinoActivityIndicator(radius: 20.0, animating: false),
|
||||
|
||||
@@ -56,33 +56,33 @@ class _CupertinoFormRowExampleState extends State<CupertinoFormRowExample> {
|
||||
},
|
||||
),
|
||||
),
|
||||
CupertinoFormRow(
|
||||
prefix: const PrefixWidget(
|
||||
const CupertinoFormRow(
|
||||
prefix: PrefixWidget(
|
||||
icon: CupertinoIcons.wifi,
|
||||
title: 'Wi-Fi',
|
||||
color: CupertinoColors.systemBlue,
|
||||
),
|
||||
error: const Text('Home network unavailable'),
|
||||
error: Text('Home network unavailable'),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: const <Widget>[
|
||||
children: <Widget>[
|
||||
Text('Not connected'),
|
||||
SizedBox(width: 5),
|
||||
Icon(CupertinoIcons.forward)
|
||||
],
|
||||
),
|
||||
),
|
||||
CupertinoFormRow(
|
||||
prefix: const PrefixWidget(
|
||||
const CupertinoFormRow(
|
||||
prefix: PrefixWidget(
|
||||
icon: CupertinoIcons.bluetooth,
|
||||
title: 'Bluetooth',
|
||||
color: CupertinoColors.activeBlue,
|
||||
),
|
||||
helper: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 4.0),
|
||||
padding: EdgeInsets.symmetric(vertical: 4.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: const <Widget>[
|
||||
children: <Widget>[
|
||||
Text('Headphone'),
|
||||
Text('Connected'),
|
||||
],
|
||||
@@ -90,7 +90,7 @@ class _CupertinoFormRowExampleState extends State<CupertinoFormRowExample> {
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: const <Widget>[
|
||||
children: <Widget>[
|
||||
Text('On'),
|
||||
SizedBox(width: 5),
|
||||
Icon(CupertinoIcons.forward)
|
||||
|
||||
@@ -86,10 +86,10 @@ class NextPage extends StatelessWidget {
|
||||
// when the CupertinoSliverNavigationBar is fully expanded.
|
||||
largeTitle: const Text('Family'),
|
||||
),
|
||||
SliverFillRemaining(
|
||||
const SliverFillRemaining(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: const <Widget>[
|
||||
children: <Widget>[
|
||||
Text('Drag me up', textAlign: TextAlign.center),
|
||||
// When the "leading" parameter is omitted on a route that has a previous page,
|
||||
// the back button is automatically added to the leading position.
|
||||
|
||||
@@ -30,10 +30,10 @@ class ButtonTypesExample extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(4.0),
|
||||
return const Padding(
|
||||
padding: EdgeInsets.all(4.0),
|
||||
child: Row(
|
||||
children: const <Widget>[
|
||||
children: <Widget>[
|
||||
Spacer(),
|
||||
ButtonTypesGroup(enabled: true),
|
||||
ButtonTypesGroup(enabled: false),
|
||||
|
||||
@@ -17,8 +17,8 @@ class CardExamplesApp extends StatelessWidget {
|
||||
theme: ThemeData(colorSchemeSeed: const Color(0xff6750a4), useMaterial3: true),
|
||||
home: Scaffold(
|
||||
appBar: AppBar(title: const Text('Card Examples')),
|
||||
body: Column(
|
||||
children: const <Widget>[
|
||||
body: const Column(
|
||||
children: <Widget>[
|
||||
Spacer(),
|
||||
ElevatedCardExample(),
|
||||
FilledCardExample(),
|
||||
|
||||
@@ -28,11 +28,11 @@ class DividerExample extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Center(
|
||||
return const Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
padding: EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
children: const <Widget>[
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: Card(
|
||||
child: SizedBox.expand(),
|
||||
|
||||
@@ -28,11 +28,11 @@ class DividerExample extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Center(
|
||||
return const Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
padding: EdgeInsets.all(16.0),
|
||||
child: Row(
|
||||
children: const <Widget>[
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: Card(
|
||||
child: SizedBox.expand(),
|
||||
|
||||
@@ -30,10 +30,10 @@ class ButtonTypesExample extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(4.0),
|
||||
return const Padding(
|
||||
padding: EdgeInsets.all(4.0),
|
||||
child: Row(
|
||||
children: const <Widget>[
|
||||
children: <Widget>[
|
||||
Spacer(),
|
||||
ButtonTypesGroup(enabled: true),
|
||||
ButtonTypesGroup(enabled: false),
|
||||
|
||||
@@ -38,15 +38,15 @@ class DemoIconToggleButtons extends StatefulWidget {
|
||||
class _DemoIconToggleButtonsState extends State<DemoIconToggleButtons> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
return const Padding(
|
||||
padding: EdgeInsets.all(8.0),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: <Widget>[
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
// Standard IconButton
|
||||
children: const <Widget>[
|
||||
children: <Widget>[
|
||||
DemoIconToggleButton(isEnabled: true),
|
||||
SizedBox(width: 10),
|
||||
DemoIconToggleButton(isEnabled: false),
|
||||
@@ -54,7 +54,7 @@ class _DemoIconToggleButtonsState extends State<DemoIconToggleButtons> {
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: const <Widget>[
|
||||
children: <Widget>[
|
||||
// Filled IconButton
|
||||
DemoIconToggleButton(isEnabled: true, getDefaultStyle: enabledFilledButtonStyle,),
|
||||
SizedBox(width: 10),
|
||||
@@ -63,7 +63,7 @@ class _DemoIconToggleButtonsState extends State<DemoIconToggleButtons> {
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: const <Widget>[
|
||||
children: <Widget>[
|
||||
// Filled Tonal IconButton
|
||||
DemoIconToggleButton(isEnabled: true, getDefaultStyle: enabledFilledTonalButtonStyle,),
|
||||
SizedBox(width: 10),
|
||||
@@ -72,7 +72,7 @@ class _DemoIconToggleButtonsState extends State<DemoIconToggleButtons> {
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: const <Widget>[
|
||||
children: <Widget>[
|
||||
// Outlined IconButton
|
||||
DemoIconToggleButton(isEnabled: true, getDefaultStyle: enabledOutlinedButtonStyle,),
|
||||
SizedBox(width: 10),
|
||||
|
||||
@@ -30,11 +30,11 @@ class MyStatelessWidget extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8.0),
|
||||
return const Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 8.0),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: const <Widget>[
|
||||
children: <Widget>[
|
||||
TextField(
|
||||
decoration: InputDecoration(
|
||||
hintText: 'Normal Icon Constraints',
|
||||
|
||||
@@ -30,11 +30,11 @@ class MyStatelessWidget extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8.0),
|
||||
return const Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 8.0),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: const <Widget>[
|
||||
children: <Widget>[
|
||||
TextField(
|
||||
decoration: InputDecoration(
|
||||
hintText: 'Normal Icon Constraints',
|
||||
|
||||
@@ -17,11 +17,11 @@ class SegmentedButtonApp extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
theme: ThemeData(useMaterial3: true),
|
||||
home: Scaffold(
|
||||
home: const Scaffold(
|
||||
body: Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: const <Widget>[
|
||||
children: <Widget>[
|
||||
Spacer(),
|
||||
Text('Single choice'),
|
||||
SingleChoice(),
|
||||
|
||||
@@ -21,10 +21,10 @@ class MyApp extends StatelessWidget {
|
||||
home: SelectionArea(
|
||||
child: Scaffold(
|
||||
appBar: AppBar(title: const Text(_title)),
|
||||
body: Center(
|
||||
body: const Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: const <Widget>[
|
||||
children: <Widget>[
|
||||
Text('Select this icon', style: TextStyle(fontSize: 30)),
|
||||
SizedBox(height: 10),
|
||||
MySelectableAdapter(child: Icon(Icons.key, size: 30)),
|
||||
|
||||
@@ -20,10 +20,10 @@ class MyApp extends StatelessWidget {
|
||||
home: SelectionArea(
|
||||
child: Scaffold(
|
||||
appBar: AppBar(title: const Text(_title)),
|
||||
body: Center(
|
||||
body: const Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: const <Widget>[
|
||||
children: <Widget>[
|
||||
Text('Row 1'),
|
||||
Text('Row 2'),
|
||||
Text('Row 3'),
|
||||
|
||||
@@ -21,11 +21,11 @@ class MyApp extends StatelessWidget {
|
||||
home: SelectionArea(
|
||||
child: Scaffold(
|
||||
appBar: AppBar(title: const Text(_title)),
|
||||
body: Center(
|
||||
body: const Center(
|
||||
child: SelectionAllOrNoneContainer(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: const <Widget>[
|
||||
children: <Widget>[
|
||||
Text('Row 1'),
|
||||
Text('Row 2'),
|
||||
Text('Row 3'),
|
||||
|
||||
@@ -19,11 +19,11 @@ class MyApp extends StatelessWidget {
|
||||
title: _title,
|
||||
home: Scaffold(
|
||||
appBar: AppBar(title: const Text(_title)),
|
||||
body: Center(
|
||||
body: const Center(
|
||||
child: SelectionArea(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: const <Widget>[
|
||||
children: <Widget>[
|
||||
Text('Selectable text'),
|
||||
SelectionContainer.disabled(child: Text('Non-selectable text')),
|
||||
Text('Selectable text'),
|
||||
|
||||
@@ -17,8 +17,8 @@ class TextFieldExamplesApp extends StatelessWidget {
|
||||
theme: ThemeData(colorSchemeSeed: const Color(0xff6750a4), useMaterial3: true),
|
||||
home: Scaffold(
|
||||
appBar: AppBar(title: const Text('TextField Examples')),
|
||||
body: Column(
|
||||
children: const <Widget>[
|
||||
body: const Column(
|
||||
children: <Widget>[
|
||||
Spacer(),
|
||||
FilledTextFieldExample(),
|
||||
OutlinedTextFieldExample(),
|
||||
|
||||
@@ -64,14 +64,14 @@ class VerificationCodeGenerator extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return Actions(
|
||||
actions: <Type, Action<Intent>> { CopyTextIntent: CallbackAction<CopyTextIntent>(onInvoke: _copy) },
|
||||
child: Column(
|
||||
child: const Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
const Text('Press Ctrl-C to Copy'),
|
||||
const SizedBox(height: 10),
|
||||
Text('Press Ctrl-C to Copy'),
|
||||
SizedBox(height: 10),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: const <Widget>[
|
||||
children: <Widget>[
|
||||
CopyableText(text: '111'),
|
||||
SizedBox(width: 5,),
|
||||
CopyableText(text: '222'),
|
||||
|
||||
@@ -64,25 +64,25 @@ class MyStatelessWidget extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return FocusTraversalGroup(
|
||||
policy: OrderedTraversalPolicy(),
|
||||
child: Column(
|
||||
child: const Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: const <Widget>[
|
||||
children: <Widget>[
|
||||
DemoButton(name: 'Six', order: 6),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: const <Widget>[
|
||||
children: <Widget>[
|
||||
DemoButton(name: 'Five', order: 5),
|
||||
DemoButton(name: 'Four', order: 4),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: const <Widget>[
|
||||
children: <Widget>[
|
||||
DemoButton(name: 'Three', order: 3),
|
||||
DemoButton(name: 'Two', order: 2),
|
||||
DemoButton(name: 'One', order: 1, autofocus: true),
|
||||
|
||||
@@ -90,9 +90,9 @@ class _MyStatefulWidgetState extends State<MyStatefulWidget>
|
||||
Widget build(BuildContext context) {
|
||||
return SpinModel(
|
||||
notifier: _controller,
|
||||
child: Row(
|
||||
child: const Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: const <Widget>[
|
||||
children: <Widget>[
|
||||
Spinner(),
|
||||
Spinner(),
|
||||
Spinner(),
|
||||
|
||||
@@ -61,8 +61,8 @@ class _OverlayExampleState extends State<OverlayExample> {
|
||||
Builder(builder: (BuildContext context) {
|
||||
switch (currentPageIndex) {
|
||||
case 0:
|
||||
return Column(
|
||||
children: const <Widget>[
|
||||
return const Column(
|
||||
children: <Widget>[
|
||||
Text(
|
||||
'Explore page',
|
||||
style: TextStyle(
|
||||
@@ -76,8 +76,8 @@ class _OverlayExampleState extends State<OverlayExample> {
|
||||
],
|
||||
);
|
||||
case 1:
|
||||
return Column(
|
||||
children: const <Widget>[
|
||||
return const Column(
|
||||
children: <Widget>[
|
||||
Text(
|
||||
'Commute page',
|
||||
style: TextStyle(
|
||||
@@ -91,8 +91,8 @@ class _OverlayExampleState extends State<OverlayExample> {
|
||||
],
|
||||
);
|
||||
case 2:
|
||||
return Column(
|
||||
children: const <Widget>[
|
||||
return const Column(
|
||||
children: <Widget>[
|
||||
Text(
|
||||
'Saved page',
|
||||
style: TextStyle(
|
||||
|
||||
@@ -56,10 +56,10 @@ class _MyStatefulWidgetState extends State<MyStatefulWidget> {
|
||||
},
|
||||
),
|
||||
},
|
||||
child: Focus(
|
||||
child: const Focus(
|
||||
autofocus: true,
|
||||
child: Column(
|
||||
children: const <Widget>[
|
||||
children: <Widget>[
|
||||
Text('Press question mark for help'),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -152,9 +152,9 @@ class ListenableBuilderExample extends StatelessWidget {
|
||||
// The container background will change color to this when
|
||||
// the subtree has focus.
|
||||
focusedColor: Colors.blue.shade50,
|
||||
child: Column(
|
||||
child: const Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: const <Widget>[
|
||||
children: <Widget>[
|
||||
Text('Owner:'),
|
||||
MyField(label: 'First Name'),
|
||||
MyField(label: 'Last Name'),
|
||||
|
||||
Reference in New Issue
Block a user