Skip to content

Commit 3d70045

Browse files
authored
[Dot shorthands] Finish examples/api migration (flutter#183967)
Migrates code in `examples/api` to use dot shorthands. Part of: flutter#175965 See also: [Dot shorthands style guide](https://github.com/flutter/flutter/blob/master/docs/contributing/Style-guide-for-Flutter-repo.md#use-dot-shorthands-to-reduce-redundant-information) Stacked pull requests: * flutter#183963 * flutter#183964 * flutter#183965 * flutter#183966 * flutter#183967 ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [AI contribution guidelines] and understand my responsibilities, or I am not using AI tools. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [AI contribution guidelines]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#ai-contribution-guidelines [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
1 parent 0fe62a5 commit 3d70045

20 files changed

Lines changed: 88 additions & 100 deletions

File tree

examples/api/lib/animation/animation_controller/animated_digit.0.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class _PlaceholderDigit extends StatelessWidget {
2121
Widget build(BuildContext context) {
2222
final TextStyle textStyle = Theme.of(
2323
context,
24-
).textTheme.displayLarge!.copyWith(fontWeight: FontWeight.w500);
24+
).textTheme.displayLarge!.copyWith(fontWeight: .w500);
2525

2626
final Iterable<Widget> placeholderDigits =
2727
<int>[0, 1, 2, 3, 4, 5, 6, 7, 8, 9].map<Widget>((int n) {

examples/api/lib/animation/curves/curve2_d.0.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ class Curve2DExample extends StatelessWidget {
9898
Widget build(BuildContext context) {
9999
return Container(
100100
color: Colors.white,
101-
alignment: Alignment.center,
101+
alignment: .center,
102102
child: FollowCurve2D(
103103
path: path,
104104
duration: const Duration(seconds: 3),

examples/api/lib/gestures/pointer_signal_resolver/pointer_signal_resolver.0.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class _ColorChangerState extends State<ColorChanger> {
5454
Widget build(BuildContext context) {
5555
return DecoratedBox(
5656
decoration: BoxDecoration(
57-
border: const Border.fromBorderSide(BorderSide()),
57+
border: const .fromBorderSide(BorderSide()),
5858
color: color.toColor(),
5959
),
6060
child: Listener(
@@ -70,7 +70,7 @@ class _ColorChangerState extends State<ColorChanger> {
7070
}
7171
},
7272
child: Stack(
73-
fit: StackFit.expand,
73+
fit: .expand,
7474
children: <Widget>[const AbsorbPointer(), ?widget.child],
7575
),
7676
),
@@ -94,7 +94,7 @@ class _PointerSignalResolverExampleState
9494
Widget build(BuildContext context) {
9595
return Material(
9696
child: Stack(
97-
fit: StackFit.expand,
97+
fit: .expand,
9898
children: <Widget>[
9999
ColorChanger(
100100
initialColor: const HSVColor.fromAHSV(0.2, 120.0, 1, 1),
@@ -109,7 +109,7 @@ class _PointerSignalResolverExampleState
109109
),
110110
),
111111
Align(
112-
alignment: Alignment.topLeft,
112+
alignment: .topLeft,
113113
child: Row(
114114
children: <Widget>[
115115
Switch(
@@ -122,7 +122,7 @@ class _PointerSignalResolverExampleState
122122
),
123123
const Text(
124124
'Use the PointerSignalResolver?',
125-
style: TextStyle(fontWeight: FontWeight.bold),
125+
style: TextStyle(fontWeight: .bold),
126126
),
127127
],
128128
),

examples/api/lib/painting/axis_direction/axis_direction.0.dart

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class _MyWidgetState extends State<MyWidget> {
5454
'Z',
5555
];
5656
final Widget _spacer = const SizedBox.square(dimension: 10);
57-
AxisDirection _axisDirection = AxisDirection.down;
57+
AxisDirection _axisDirection = .down;
5858

5959
Widget _getArrows() {
6060
final Widget arrow = switch (_axisDirection) {
@@ -65,7 +65,7 @@ class _MyWidgetState extends State<MyWidget> {
6565
};
6666
return Flex(
6767
direction: flipAxis(axisDirectionToAxis(_axisDirection)),
68-
mainAxisAlignment: MainAxisAlignment.center,
68+
mainAxisAlignment: .center,
6969
children: <Widget>[arrow, arrow],
7070
);
7171
}
@@ -82,9 +82,9 @@ class _MyWidgetState extends State<MyWidget> {
8282
Widget _getLeading() {
8383
return Container(
8484
color: Colors.blue[100],
85-
padding: const EdgeInsets.all(8.0),
85+
padding: const .all(8.0),
8686
child: Column(
87-
mainAxisAlignment: MainAxisAlignment.spaceBetween,
87+
mainAxisAlignment: .spaceBetween,
8888
children: <Widget>[
8989
Text(axisDirectionToAxis(_axisDirection).toString()),
9090
_spacer,
@@ -100,18 +100,18 @@ class _MyWidgetState extends State<MyWidget> {
100100

101101
Widget _getRadioRow() {
102102
return DefaultTextStyle(
103-
style: const TextStyle(fontWeight: FontWeight.bold, color: Colors.white),
103+
style: const TextStyle(fontWeight: .bold, color: Colors.white),
104104
child: RadioTheme(
105105
data: RadioThemeData(
106106
fillColor: WidgetStateProperty.all<Color>(Colors.white),
107107
),
108108
child: Padding(
109-
padding: const EdgeInsets.all(8.0),
109+
padding: const .all(8.0),
110110
child: RadioGroup<AxisDirection>(
111111
groupValue: _axisDirection,
112112
onChanged: _onAxisDirectionChanged,
113113
child: Row(
114-
mainAxisAlignment: MainAxisAlignment.spaceAround,
114+
mainAxisAlignment: .spaceAround,
115115
children: <Widget>[
116116
Radio<AxisDirection>(value: AxisDirection.up),
117117
const Text('up'),
@@ -140,10 +140,7 @@ class _MyWidgetState extends State<MyWidget> {
140140
title: const Text('AxisDirections'),
141141
bottom: PreferredSize(
142142
preferredSize: const Size.fromHeight(50),
143-
child: Padding(
144-
padding: const EdgeInsets.all(8.0),
145-
child: _getRadioRow(),
146-
),
143+
child: Padding(padding: const .all(8.0), child: _getRadioRow()),
147144
),
148145
),
149146
// Also works for ListView.builder, which creates a SliverList for itself.
@@ -165,11 +162,11 @@ class _MyWidgetState extends State<MyWidget> {
165162
} else {
166163
child = Container(
167164
color: index.isEven ? Colors.amber[100] : Colors.amberAccent,
168-
padding: const EdgeInsets.all(8.0),
165+
padding: const .all(8.0),
169166
child: Center(child: Text(_alphabet[index - 1])),
170167
);
171168
}
172-
return Padding(padding: const EdgeInsets.all(8.0), child: child);
169+
return Padding(padding: const .all(8.0), child: child);
173170
},
174171
),
175172
],

examples/api/lib/painting/borders/border_side.stroke_align.0.dart

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ class StrokeAlignExample extends StatelessWidget {
3131
child: RepeatingAnimationBuilder<double>(
3232
animatable: Tween<double>(begin: -1.0, end: 1.0),
3333
duration: const Duration(seconds: 1),
34-
repeatMode: RepeatMode.reverse,
34+
repeatMode: .reverse,
3535
builder: (BuildContext context, double strokeAlign, Widget? child) {
3636
return Column(
37-
mainAxisAlignment: MainAxisAlignment.spaceAround,
37+
mainAxisAlignment: .spaceAround,
3838
children: <Widget>[
3939
BorderedBox(
4040
shape: StadiumBorder(
@@ -46,7 +46,7 @@ class StrokeAlignExample extends StatelessWidget {
4646
),
4747
),
4848
Row(
49-
mainAxisAlignment: MainAxisAlignment.spaceAround,
49+
mainAxisAlignment: .spaceAround,
5050
children: <Widget>[
5151
BorderedBox(
5252
shape: CircleBorder(
@@ -69,7 +69,7 @@ class StrokeAlignExample extends StatelessWidget {
6969
],
7070
),
7171
Row(
72-
mainAxisAlignment: MainAxisAlignment.spaceAround,
72+
mainAxisAlignment: .spaceAround,
7373
children: <Widget>[
7474
BorderedBox(
7575
shape: BeveledRectangleBorder(
@@ -82,7 +82,7 @@ class StrokeAlignExample extends StatelessWidget {
8282
),
8383
BorderedBox(
8484
shape: BeveledRectangleBorder(
85-
borderRadius: BorderRadius.circular(cornerRadius),
85+
borderRadius: .circular(cornerRadius),
8686
side: BorderSide(
8787
color: borderColor,
8888
width: borderWidth,
@@ -93,7 +93,7 @@ class StrokeAlignExample extends StatelessWidget {
9393
],
9494
),
9595
Row(
96-
mainAxisAlignment: MainAxisAlignment.spaceAround,
96+
mainAxisAlignment: .spaceAround,
9797
children: <Widget>[
9898
BorderedBox(
9999
shape: RoundedRectangleBorder(
@@ -106,7 +106,7 @@ class StrokeAlignExample extends StatelessWidget {
106106
),
107107
BorderedBox(
108108
shape: RoundedRectangleBorder(
109-
borderRadius: BorderRadius.circular(cornerRadius),
109+
borderRadius: .circular(cornerRadius),
110110
side: BorderSide(
111111
color: borderColor,
112112
width: borderWidth,
@@ -117,7 +117,7 @@ class StrokeAlignExample extends StatelessWidget {
117117
],
118118
),
119119
Row(
120-
mainAxisAlignment: MainAxisAlignment.spaceAround,
120+
mainAxisAlignment: .spaceAround,
121121
children: <Widget>[
122122
BorderedBox(
123123
shape: StarBorder(

examples/api/lib/painting/gradient/linear_gradient.0.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class MoodyGradient extends StatelessWidget {
3838
Color(0xfff39060),
3939
Color(0xffffb56b),
4040
], // Gradient from https://learnui.design/tools/gradient-generator.html
41-
tileMode: TileMode.mirror,
41+
tileMode: .mirror,
4242
),
4343
),
4444
child: const Center(

examples/api/lib/painting/linear_border/linear_border.0.dart

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ class ExampleApp extends StatelessWidget {
1717
Widget build(BuildContext context) {
1818
return const MaterialApp(
1919
home: Directionality(
20-
// TRY THIS: Switch to TextDirection.rtl to see how the borders change.
21-
textDirection: TextDirection.ltr,
20+
// TRY THIS: Switch to .rtl to see how the borders change.
21+
textDirection: .ltr,
2222
child: Home(),
2323
),
2424
);
@@ -45,10 +45,10 @@ class SampleCard extends StatelessWidget {
4545

4646
return Card(
4747
child: Padding(
48-
padding: const EdgeInsets.all(16),
48+
padding: const .all(16),
4949
child: Column(
50-
crossAxisAlignment: CrossAxisAlignment.start,
51-
mainAxisSize: MainAxisSize.min,
50+
crossAxisAlignment: .start,
51+
mainAxisSize: .min,
5252
children: <Widget>[
5353
Text(title, style: textTheme.titleMedium),
5454
Text(
@@ -105,9 +105,9 @@ class _HomeState extends State<Home> {
105105
return Scaffold(
106106
body: SingleChildScrollView(
107107
child: Padding(
108-
padding: const EdgeInsets.all(16),
108+
padding: const .all(16),
109109
child: Column(
110-
mainAxisSize: MainAxisSize.min,
110+
mainAxisSize: .min,
111111
children: <Widget>[
112112
// Demonstrates using LinearBorder.bottom() to define
113113
// an underline border for the standard button types.

examples/api/lib/painting/rounded_superellipse_border/rounded_superellipse_border.0.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ class RoundedSuperellipseBorderExampleState
4545
home: CupertinoPageScaffold(
4646
child: Center(
4747
child: Container(
48-
padding: const EdgeInsetsGeometry.all(10),
48+
padding: const .all(10),
4949
constraints: const BoxConstraints(maxWidth: 600),
5050
child: Column(
51-
mainAxisAlignment: MainAxisAlignment.center,
51+
mainAxisAlignment: .center,
5252
spacing: 16,
5353
children: <Widget>[
5454
// The border is drawn by this DecoratedBox.
@@ -62,7 +62,7 @@ class RoundedSuperellipseBorderExampleState
6262
),
6363

6464
Row(
65-
mainAxisAlignment: MainAxisAlignment.center,
65+
mainAxisAlignment: .center,
6666
children: <Widget>[
6767
const Text('Shape: '),
6868
CupertinoSwitch(
@@ -135,7 +135,7 @@ class SliderRow extends StatelessWidget {
135135
Widget build(BuildContext context) {
136136
return Flex(
137137
direction: Axis.horizontal,
138-
mainAxisAlignment: MainAxisAlignment.center,
138+
mainAxisAlignment: .center,
139139
children: <Widget>[
140140
ConstrainedBox(
141141
constraints: const BoxConstraints(minWidth: 50),

examples/api/lib/painting/star_border/star_border.0.dart

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,15 @@ class _StarBorderExampleState extends State<StarBorderExample> {
6262
color: Colors.black,
6363
fontSize: 14.0,
6464
fontFamily: 'Roboto',
65-
fontStyle: FontStyle.normal,
65+
fontStyle: .normal,
6666
),
6767
child: ListView(
6868
children: <Widget>[
6969
ColoredBox(color: Colors.grey.shade200, child: Options(_model)),
7070
Padding(
71-
padding: const EdgeInsets.all(18.0),
71+
padding: const .all(18.0),
7272
child: Row(
73-
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
73+
mainAxisAlignment: .spaceEvenly,
7474
children: <Widget>[
7575
Expanded(
7676
child: ExampleBorder(
@@ -102,21 +102,21 @@ class _StarBorderExampleState extends State<StarBorderExample> {
102102
),
103103
),
104104
Row(
105-
crossAxisAlignment: CrossAxisAlignment.start,
105+
crossAxisAlignment: .start,
106106
children: <Widget>[
107107
Expanded(
108108
child: Container(
109109
color: Colors.black12,
110-
margin: const EdgeInsets.all(16.0),
111-
padding: const EdgeInsets.all(16.0),
110+
margin: const .all(16.0),
111+
padding: const .all(16.0),
112112
child: SelectableText(_model.starCode),
113113
),
114114
),
115115
Expanded(
116116
child: Container(
117117
color: Colors.black12,
118-
margin: const EdgeInsets.all(16.0),
119-
padding: const EdgeInsets.all(16.0),
118+
margin: const .all(16.0),
119+
padding: const .all(16.0),
120120
child: SelectableText(_model.polygonCode),
121121
),
122122
),
@@ -137,8 +137,8 @@ class ExampleBorder extends StatelessWidget {
137137
@override
138138
Widget build(BuildContext context) {
139139
return Container(
140-
alignment: Alignment.center,
141-
padding: const EdgeInsets.all(20),
140+
alignment: .center,
141+
padding: const .all(20),
142142
width: 150,
143143
height: 100,
144144
decoration: ShapeDecoration(color: Colors.blue.shade100, shape: border),
@@ -185,9 +185,9 @@ class _OptionsState extends State<Options> {
185185
@override
186186
Widget build(BuildContext context) {
187187
return Padding(
188-
padding: const EdgeInsets.fromLTRB(5.0, 0.0, 5.0, 10.0),
188+
padding: const .fromLTRB(5.0, 0.0, 5.0, 10.0),
189189
child: Column(
190-
mainAxisSize: MainAxisSize.min,
190+
mainAxisSize: .min,
191191
children: <Widget>[
192192
Row(
193193
children: <Widget>[
@@ -255,7 +255,7 @@ class _OptionsState extends State<Options> {
255255
message:
256256
'Round the number of points to the nearest integer.',
257257
child: Padding(
258-
padding: const EdgeInsets.all(8.0),
258+
padding: const .all(8.0),
259259
child: OutlinedButton(
260260
child: const Text('Nearest'),
261261
onPressed: () {
@@ -413,11 +413,11 @@ class ControlSlider extends StatelessWidget {
413413
@override
414414
Widget build(BuildContext context) {
415415
return Padding(
416-
padding: const EdgeInsets.all(4.0),
416+
padding: const .all(4.0),
417417
child: Row(
418-
mainAxisSize: MainAxisSize.min,
418+
mainAxisSize: .min,
419419
children: <Widget>[
420-
Expanded(flex: 2, child: Text(label, textAlign: TextAlign.end)),
420+
Expanded(flex: 2, child: Text(label, textAlign: .end)),
421421
Expanded(
422422
flex: 5,
423423
child: Slider(

examples/api/lib/rendering/box/parent_data.0.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ class _SampleAppState extends State<SampleApp> {
9191
],
9292
),
9393
body: SingleChildScrollView(
94-
padding: const EdgeInsets.symmetric(horizontal: 30.0, vertical: 20.0),
94+
padding: const .symmetric(horizontal: 30.0, vertical: 20.0),
9595
// CompactLayout and OpenLayout are the two rendering widgets defined below.
9696
child: _compact
9797
? const CompactLayout(children: body)

0 commit comments

Comments
 (0)