Skip to content

Commit cb9a1d6

Browse files
authored
Use curly_braces_in_flow_control_structures for material (#104499)
* Use `curly_braces_in_flow_control_structures` for `material` * include test/material * add back removed comments
1 parent 97452d1 commit cb9a1d6

File tree

138 files changed

+1436
-759
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

138 files changed

+1436
-759
lines changed

packages/flutter/lib/src/material/animated_icons/animated_icons.dart

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,9 @@ class AnimatedIcon extends StatelessWidget {
110110
final TextDirection textDirection = this.textDirection ?? Directionality.of(context);
111111
final double iconOpacity = iconTheme.opacity!;
112112
Color iconColor = color ?? iconTheme.color!;
113-
if (iconOpacity != 1.0)
113+
if (iconOpacity != 1.0) {
114114
iconColor = iconColor.withOpacity(iconColor.opacity * iconOpacity);
115+
}
115116
return Semantics(
116117
label: semanticLabel,
117118
child: CustomPaint(
@@ -162,8 +163,9 @@ class _AnimatedIconPainter extends CustomPainter {
162163
canvas.scale(scale, scale);
163164

164165
final double clampedProgress = clampDouble(progress.value, 0.0, 1.0);
165-
for (final _PathFrames path in paths)
166+
for (final _PathFrames path in paths) {
166167
path.paint(canvas, color, uiPathFactory, clampedProgress);
168+
}
167169
}
168170

169171

@@ -203,8 +205,9 @@ class _PathFrames {
203205
..style = PaintingStyle.fill
204206
..color = color.withOpacity(color.opacity * opacity);
205207
final ui.Path path = uiPathFactory();
206-
for (final _PathCommand command in commands)
208+
for (final _PathCommand command in commands) {
207209
command.apply(path, progress);
210+
}
208211
canvas.drawPath(path, paint);
209212
}
210213
}
@@ -291,8 +294,9 @@ class _PathClose extends _PathCommand {
291294
T _interpolate<T>(List<T> values, double progress, _Interpolator<T> interpolator) {
292295
assert(progress <= 1.0);
293296
assert(progress >= 0.0);
294-
if (values.length == 1)
297+
if (values.length == 1) {
295298
return values[0];
299+
}
296300
final double targetIdx = lerpDouble(0, values.length -1, progress)!;
297301
final int lowIdx = targetIdx.floor();
298302
final int highIdx = targetIdx.ceil();

packages/flutter/lib/src/material/app.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1000,8 +1000,9 @@ class _MaterialAppState extends State<MaterialApp> {
10001000
result = Focus(
10011001
canRequestFocus: false,
10021002
onKey: (FocusNode node, RawKeyEvent event) {
1003-
if (event is! RawKeyDownEvent || event.logicalKey != LogicalKeyboardKey.escape)
1003+
if (event is! RawKeyDownEvent || event.logicalKey != LogicalKeyboardKey.escape) {
10041004
return KeyEventResult.ignored;
1005+
}
10051006
return Tooltip.dismissAllToolTips() ? KeyEventResult.handled : KeyEventResult.ignored;
10061007
},
10071008
child: result,

packages/flutter/lib/src/material/app_bar.dart

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -803,11 +803,13 @@ class _AppBarState extends State<AppBar> {
803803
@override
804804
void didChangeDependencies() {
805805
super.didChangeDependencies();
806-
if (_scrollNotificationObserver != null)
806+
if (_scrollNotificationObserver != null) {
807807
_scrollNotificationObserver!.removeListener(_handleScrollNotification);
808+
}
808809
_scrollNotificationObserver = ScrollNotificationObserver.of(context);
809-
if (_scrollNotificationObserver != null)
810+
if (_scrollNotificationObserver != null) {
810811
_scrollNotificationObserver!.addListener(_handleScrollNotification);
812+
}
811813
}
812814

813815
@override
@@ -949,10 +951,12 @@ class _AppBarState extends State<AppBar> {
949951

950952
if (widget.toolbarOpacity != 1.0) {
951953
final double opacity = const Interval(0.25, 1.0, curve: Curves.fastOutSlowIn).transform(widget.toolbarOpacity);
952-
if (titleTextStyle?.color != null)
954+
if (titleTextStyle?.color != null) {
953955
titleTextStyle = titleTextStyle!.copyWith(color: titleTextStyle.color!.withOpacity(opacity));
954-
if (toolbarTextStyle?.color != null)
956+
}
957+
if (toolbarTextStyle?.color != null) {
955958
toolbarTextStyle = toolbarTextStyle!.copyWith(color: toolbarTextStyle.color!.withOpacity(opacity));
959+
}
956960
overallIconTheme = overallIconTheme.copyWith(
957961
opacity: opacity * (overallIconTheme.opacity ?? 1.0),
958962
);
@@ -2050,10 +2054,12 @@ class _SliverAppBarState extends State<SliverAppBar> with TickerProviderStateMix
20502054
@override
20512055
void didUpdateWidget(SliverAppBar oldWidget) {
20522056
super.didUpdateWidget(oldWidget);
2053-
if (widget.snap != oldWidget.snap || widget.floating != oldWidget.floating)
2057+
if (widget.snap != oldWidget.snap || widget.floating != oldWidget.floating) {
20542058
_updateSnapConfiguration();
2055-
if (widget.stretch != oldWidget.stretch)
2059+
}
2060+
if (widget.stretch != oldWidget.stretch) {
20562061
_updateStretchConfiguration();
2062+
}
20572063
}
20582064

20592065
@override

packages/flutter/lib/src/material/app_bar_theme.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,10 +353,12 @@ class AppBarTheme with Diagnosticable {
353353

354354
@override
355355
bool operator ==(Object other) {
356-
if (identical(this, other))
356+
if (identical(this, other)) {
357357
return true;
358-
if (other.runtimeType != runtimeType)
358+
}
359+
if (other.runtimeType != runtimeType) {
359360
return false;
361+
}
360362
return other is AppBarTheme
361363
&& other.brightness == brightness
362364
&& other.backgroundColor == backgroundColor

packages/flutter/lib/src/material/arc.dart

Lines changed: 48 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -92,21 +92,25 @@ class MaterialPointArcTween extends Tween<Offset> {
9292
/// The center of the circular arc, null if [begin] and [end] are horizontally or
9393
/// vertically aligned, or if either is null.
9494
Offset? get center {
95-
if (begin == null || end == null)
95+
if (begin == null || end == null) {
9696
return null;
97-
if (_dirty)
97+
}
98+
if (_dirty) {
9899
_initialize();
100+
}
99101
return _center;
100102
}
101103
Offset? _center;
102104

103105
/// The radius of the circular arc, null if [begin] and [end] are horizontally or
104106
/// vertically aligned, or if either is null.
105107
double? get radius {
106-
if (begin == null || end == null)
108+
if (begin == null || end == null) {
107109
return null;
108-
if (_dirty)
110+
}
111+
if (_dirty) {
109112
_initialize();
113+
}
110114
return _radius;
111115
}
112116
double? _radius;
@@ -117,10 +121,12 @@ class MaterialPointArcTween extends Tween<Offset> {
117121
/// This will be null if [begin] and [end] are horizontally or vertically
118122
/// aligned, or if either is null.
119123
double? get beginAngle {
120-
if (begin == null || end == null)
124+
if (begin == null || end == null) {
121125
return null;
122-
if (_dirty)
126+
}
127+
if (_dirty) {
123128
_initialize();
129+
}
124130
return _beginAngle;
125131
}
126132
double? _beginAngle;
@@ -131,10 +137,12 @@ class MaterialPointArcTween extends Tween<Offset> {
131137
/// This will be null if [begin] and [end] are horizontally or vertically
132138
/// aligned, or if either is null.
133139
double? get endAngle {
134-
if (begin == null || end == null)
140+
if (begin == null || end == null) {
135141
return null;
136-
if (_dirty)
142+
}
143+
if (_dirty) {
137144
_initialize();
145+
}
138146
return _beginAngle;
139147
}
140148
double? _endAngle;
@@ -157,14 +165,18 @@ class MaterialPointArcTween extends Tween<Offset> {
157165

158166
@override
159167
Offset lerp(double t) {
160-
if (_dirty)
168+
if (_dirty) {
161169
_initialize();
162-
if (t == 0.0)
170+
}
171+
if (t == 0.0) {
163172
return begin!;
164-
if (t == 1.0)
173+
}
174+
if (t == 1.0) {
165175
return end!;
166-
if (_beginAngle == null || _endAngle == null)
176+
}
177+
if (_beginAngle == null || _endAngle == null) {
167178
return Offset.lerp(begin, end, t)!;
179+
}
168180
final double angle = lerpDouble(_beginAngle, _endAngle, t)!;
169181
final double x = math.cos(angle) * _radius!;
170182
final double y = math.sin(angle) * _radius!;
@@ -279,21 +291,25 @@ class MaterialRectArcTween extends RectTween {
279291
/// The path of the corresponding [begin], [end] rectangle corners that lead
280292
/// the animation.
281293
MaterialPointArcTween? get beginArc {
282-
if (begin == null)
294+
if (begin == null) {
283295
return null;
284-
if (_dirty)
296+
}
297+
if (_dirty) {
285298
_initialize();
299+
}
286300
return _beginArc;
287301
}
288302
late MaterialPointArcTween _beginArc;
289303

290304
/// The path of the corresponding [begin], [end] rectangle corners that trail
291305
/// the animation.
292306
MaterialPointArcTween? get endArc {
293-
if (end == null)
307+
if (end == null) {
294308
return null;
295-
if (_dirty)
309+
}
310+
if (_dirty) {
296311
_initialize();
312+
}
297313
return _endArc;
298314
}
299315
late MaterialPointArcTween _endArc;
@@ -316,12 +332,15 @@ class MaterialRectArcTween extends RectTween {
316332

317333
@override
318334
Rect lerp(double t) {
319-
if (_dirty)
335+
if (_dirty) {
320336
_initialize();
321-
if (t == 0.0)
337+
}
338+
if (t == 0.0) {
322339
return begin!;
323-
if (t == 1.0)
340+
}
341+
if (t == 1.0) {
324342
return end!;
343+
}
325344
return Rect.fromPoints(_beginArc.lerp(t), _endArc.lerp(t));
326345
}
327346

@@ -373,10 +392,12 @@ class MaterialRectCenterArcTween extends RectTween {
373392
/// If [begin] and [end] are non-null, returns a tween that interpolates along
374393
/// a circular arc between [begin]'s [Rect.center] and [end]'s [Rect.center].
375394
MaterialPointArcTween? get centerArc {
376-
if (begin == null || end == null)
395+
if (begin == null || end == null) {
377396
return null;
378-
if (_dirty)
397+
}
398+
if (_dirty) {
379399
_initialize();
400+
}
380401
return _centerArc;
381402
}
382403
late MaterialPointArcTween _centerArc;
@@ -399,12 +420,15 @@ class MaterialRectCenterArcTween extends RectTween {
399420

400421
@override
401422
Rect lerp(double t) {
402-
if (_dirty)
423+
if (_dirty) {
403424
_initialize();
404-
if (t == 0.0)
425+
}
426+
if (t == 0.0) {
405427
return begin!;
406-
if (t == 1.0)
428+
}
429+
if (t == 1.0) {
407430
return end!;
431+
}
408432
final Offset center = _centerArc.lerp(t);
409433
final double width = lerpDouble(begin!.width, end!.width, t)!;
410434
final double height = lerpDouble(begin!.height, end!.height, t)!;

packages/flutter/lib/src/material/banner.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,8 +332,9 @@ class _MaterialBannerState extends State<MaterialBanner> {
332332
);
333333

334334
// This provides a static banner for backwards compatibility.
335-
if (widget.animation == null)
335+
if (widget.animation == null) {
336336
return materialBanner;
337+
}
337338

338339
materialBanner = SafeArea(
339340
child: materialBanner,

packages/flutter/lib/src/material/banner_theme.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,12 @@ class MaterialBannerThemeData with Diagnosticable {
101101

102102
@override
103103
bool operator ==(Object other) {
104-
if (identical(this, other))
104+
if (identical(this, other)) {
105105
return true;
106-
if (other.runtimeType != runtimeType)
106+
}
107+
if (other.runtimeType != runtimeType) {
107108
return false;
109+
}
108110
return other is MaterialBannerThemeData
109111
&& other.backgroundColor == backgroundColor
110112
&& other.contentTextStyle == contentTextStyle

packages/flutter/lib/src/material/bottom_app_bar.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,9 @@ class _BottomAppBarClipper extends CustomClipper<Path> {
180180
// Material widget.
181181
double get bottomNavigationBarTop {
182182
final double? bottomNavigationBarTop = geometry.value.bottomNavigationBarTop;
183-
if (bottomNavigationBarTop != null)
183+
if (bottomNavigationBarTop != null) {
184184
return bottomNavigationBarTop;
185+
}
185186
final RenderBox? box = materialKey.currentContext?.findRenderObject() as RenderBox?;
186187
return box?.localToGlobal(Offset.zero).dy ?? 0;
187188
}

packages/flutter/lib/src/material/bottom_app_bar_theme.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,12 @@ class BottomAppBarTheme with Diagnosticable {
8787

8888
@override
8989
bool operator ==(Object other) {
90-
if (identical(this, other))
90+
if (identical(this, other)) {
9191
return true;
92-
if (other.runtimeType != runtimeType)
92+
}
93+
if (other.runtimeType != runtimeType) {
9394
return false;
95+
}
9496
return other is BottomAppBarTheme
9597
&& other.color == color
9698
&& other.elevation == elevation

0 commit comments

Comments
 (0)