Skip to content

Commit 9cc72df

Browse files
authored
Use curly_braces_in_flow_control_structures for foundation, gestures, painting, physics (#104610)
* Use `curly_braces_in_flow_control_structures` for `foundation` * Use `curly_braces_in_flow_control_structures` for `gestures` * Use `curly_braces_in_flow_control_structures` for `painting` * Use `curly_braces_in_flow_control_structures` for `physics` * fix comments * remove trailing space * fix TODO style
1 parent 2b14e99 commit 9cc72df

File tree

84 files changed

+1227
-620
lines changed

Some content is hidden

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

84 files changed

+1227
-620
lines changed

packages/flutter/lib/src/foundation/_bitfield_io.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,11 @@ class BitField<T extends dynamic> implements bitfield.BitField<T> {
3737
void operator []=(T index, bool value) {
3838
final int intIndex = index.index as int;
3939
assert(intIndex < _length);
40-
if (value)
40+
if (value) {
4141
_bits = _bits | (1 << intIndex);
42-
else
42+
} else {
4343
_bits = _bits & ~(1 << intIndex);
44+
}
4445
}
4546

4647
@override

packages/flutter/lib/src/foundation/_platform_io.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,14 @@ platform.TargetPlatform get defaultTargetPlatform {
2323
result = platform.TargetPlatform.windows;
2424
}
2525
assert(() {
26-
if (Platform.environment.containsKey('FLUTTER_TEST'))
26+
if (Platform.environment.containsKey('FLUTTER_TEST')) {
2727
result = platform.TargetPlatform.android;
28+
}
2829
return true;
2930
}());
30-
if (platform.debugDefaultTargetPlatformOverride != null)
31+
if (platform.debugDefaultTargetPlatformOverride != null) {
3132
result = platform.debugDefaultTargetPlatformOverride;
33+
}
3234
if (result == null) {
3335
throw FlutterError(
3436
'Unknown platform.\n'

packages/flutter/lib/src/foundation/assertions.dart

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -622,8 +622,9 @@ class FlutterErrorDetails with Diagnosticable {
622622
longMessage = ' $exception';
623623
}
624624
longMessage = longMessage.trimRight();
625-
if (longMessage.isEmpty)
625+
if (longMessage.isEmpty) {
626626
longMessage = ' <no message available>';
627+
}
627628
return longMessage;
628629
}
629630

@@ -690,8 +691,9 @@ class FlutterErrorDetails with Diagnosticable {
690691
// strip out that header when we see it.
691692
final String prefix = '${exception.runtimeType}: ';
692693
String message = exceptionAsString();
693-
if (message.startsWith(prefix))
694+
if (message.startsWith(prefix)) {
694695
message = message.substring(prefix.length);
696+
}
695697
properties.add(ErrorSummary(message));
696698
}
697699
}
@@ -1002,8 +1004,9 @@ class FlutterError extends Error with DiagnosticableTreeMixin implements Asserti
10021004
return true;
10031005
}());
10041006
final bool reportError = isInDebugMode || details.silent != true; // could be null
1005-
if (!reportError && !forceReport)
1007+
if (!reportError && !forceReport) {
10061008
return;
1009+
}
10071010
if (_errorCount == 0 || forceReport) {
10081011
// Diagnostics is only available in debug mode. In profile and release modes fallback to plain print.
10091012
if (isInDebugMode) {
@@ -1115,8 +1118,9 @@ class FlutterError extends Error with DiagnosticableTreeMixin implements Asserti
11151118
if (skipped == 1) {
11161119
result.add('(elided one frame from ${where.single})');
11171120
} else if (skipped > 1) {
1118-
if (where.length > 1)
1121+
if (where.length > 1) {
11191122
where[where.length - 1] = 'and ${where.last}';
1123+
}
11201124
if (where.length > 2) {
11211125
result.add('(elided $skipped frames from ${where.join(", ")})');
11221126
} else {
@@ -1190,8 +1194,9 @@ class FlutterError extends Error with DiagnosticableTreeMixin implements Asserti
11901194
///
11911195
/// The `label` argument, if present, will be printed before the stack.
11921196
void debugPrintStack({StackTrace? stackTrace, String? label, int? maxFrames}) {
1193-
if (label != null)
1197+
if (label != null) {
11941198
debugPrint(label);
1199+
}
11951200
if (stackTrace == null) {
11961201
stackTrace = StackTrace.current;
11971202
} else {
@@ -1208,8 +1213,9 @@ void debugPrintStack({StackTrace? stackTrace, String? label, int? maxFrames}) {
12081213
line.contains('dart:sdk_internal');
12091214
});
12101215
}
1211-
if (maxFrames != null)
1216+
if (maxFrames != null) {
12121217
lines = lines.take(maxFrames);
1218+
}
12131219
debugPrint(FlutterError.defaultStackFilter(lines).join('\n'));
12141220
}
12151221

@@ -1252,8 +1258,9 @@ class DiagnosticsStackTrace extends DiagnosticsBlock {
12521258
StackTrace? stack,
12531259
IterableFilter<String>? stackFilter,
12541260
) {
1255-
if (stack == null)
1261+
if (stack == null) {
12561262
return <DiagnosticsNode>[];
1263+
}
12571264
final IterableFilter<String> filter = stackFilter ?? FlutterError.defaultStackFilter;
12581265
final Iterable<String> frames = filter('${FlutterError.demangleStackTrace(stack)}'.trimRight().split('\n'));
12591266
return frames.map<DiagnosticsNode>(_createStackFrame).toList();

packages/flutter/lib/src/foundation/basic_types.dart

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,9 @@ class CachingIterable<E> extends IterableBase<E> {
191191
}
192192

193193
bool _fillNext() {
194-
if (!_prefillIterator.moveNext())
194+
if (!_prefillIterator.moveNext()) {
195195
return false;
196+
}
196197
_results.add(_prefillIterator.current);
197198
return true;
198199
}
@@ -207,18 +208,21 @@ class _LazyListIterator<E> implements Iterator<E> {
207208
@override
208209
E get current {
209210
assert(_index >= 0); // called "current" before "moveNext()"
210-
if (_index < 0 || _index == _owner._results.length)
211+
if (_index < 0 || _index == _owner._results.length) {
211212
throw StateError('current can not be call after moveNext has returned false');
213+
}
212214
return _owner._results[_index];
213215
}
214216

215217
@override
216218
bool moveNext() {
217-
if (_index >= _owner._results.length)
219+
if (_index >= _owner._results.length) {
218220
return false;
221+
}
219222
_index += 1;
220-
if (_index == _owner._results.length)
223+
if (_index == _owner._results.length) {
221224
return _owner._fillNext();
225+
}
222226
return true;
223227
}
224228
}

packages/flutter/lib/src/foundation/binding.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -827,8 +827,9 @@ abstract class BindingBase {
827827
developer.registerExtension(methodName, (String method, Map<String, String> parameters) async {
828828
assert(method == methodName);
829829
assert(() {
830-
if (debugInstrumentationEnabled)
830+
if (debugInstrumentationEnabled) {
831831
debugPrint('service extension method received: $method($parameters)');
832+
}
832833
return true;
833834
}());
834835

packages/flutter/lib/src/foundation/change_notifier.dart

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -225,20 +225,23 @@ class ChangeNotifier implements Listenable {
225225
final List<VoidCallback?> newListeners = List<VoidCallback?>.filled(_count, null);
226226

227227
// Listeners before the index are at the same place.
228-
for (int i = 0; i < index; i++)
228+
for (int i = 0; i < index; i++) {
229229
newListeners[i] = _listeners[i];
230+
}
230231

231232
// Listeners after the index move towards the start of the list.
232-
for (int i = index; i < _count; i++)
233+
for (int i = index; i < _count; i++) {
233234
newListeners[i] = _listeners[i + 1];
235+
}
234236

235237
_listeners = newListeners;
236238
} else {
237239
// When there are more listeners than half the length of the list, we only
238240
// shift our listeners, so that we avoid to reallocate memory for the
239241
// whole list.
240-
for (int i = index; i < _count; i++)
242+
for (int i = index; i < _count; i++) {
241243
_listeners[i] = _listeners[i + 1];
244+
}
242245
_listeners[_count] = null;
243246
}
244247
}
@@ -319,8 +322,9 @@ class ChangeNotifier implements Listenable {
319322
@pragma('vm:notify-debugger-on-exception')
320323
void notifyListeners() {
321324
assert(debugAssertNotDisposed());
322-
if (_count == 0)
325+
if (_count == 0) {
323326
return;
327+
}
324328

325329
// To make sure that listeners removed during this iteration are not called,
326330
// we set them to null, but we don't shrink the list right away.
@@ -439,8 +443,9 @@ class ValueNotifier<T> extends ChangeNotifier implements ValueListenable<T> {
439443
T get value => _value;
440444
T _value;
441445
set value(T newValue) {
442-
if (_value == newValue)
446+
if (_value == newValue) {
443447
return;
448+
}
444449
_value = newValue;
445450
notifyListeners();
446451
}

packages/flutter/lib/src/foundation/collections.dart

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,19 @@
2020
/// * [listEquals], which does something similar for lists.
2121
/// * [mapEquals], which does something similar for maps.
2222
bool setEquals<T>(Set<T>? a, Set<T>? b) {
23-
if (a == null)
23+
if (a == null) {
2424
return b == null;
25-
if (b == null || a.length != b.length)
25+
}
26+
if (b == null || a.length != b.length) {
2627
return false;
27-
if (identical(a, b))
28+
}
29+
if (identical(a, b)) {
2830
return true;
31+
}
2932
for (final T value in a) {
30-
if (!b.contains(value))
33+
if (!b.contains(value)) {
3134
return false;
35+
}
3236
}
3337
return true;
3438
}
@@ -49,15 +53,19 @@ bool setEquals<T>(Set<T>? a, Set<T>? b) {
4953
/// * [setEquals], which does something similar for sets.
5054
/// * [mapEquals], which does something similar for maps.
5155
bool listEquals<T>(List<T>? a, List<T>? b) {
52-
if (a == null)
56+
if (a == null) {
5357
return b == null;
54-
if (b == null || a.length != b.length)
58+
}
59+
if (b == null || a.length != b.length) {
5560
return false;
56-
if (identical(a, b))
61+
}
62+
if (identical(a, b)) {
5763
return true;
64+
}
5865
for (int index = 0; index < a.length; index += 1) {
59-
if (a[index] != b[index])
66+
if (a[index] != b[index]) {
6067
return false;
68+
}
6169
}
6270
return true;
6371
}
@@ -78,12 +86,15 @@ bool listEquals<T>(List<T>? a, List<T>? b) {
7886
/// * [setEquals], which does something similar for sets.
7987
/// * [listEquals], which does something similar for lists.
8088
bool mapEquals<T, U>(Map<T, U>? a, Map<T, U>? b) {
81-
if (a == null)
89+
if (a == null) {
8290
return b == null;
83-
if (b == null || a.length != b.length)
91+
}
92+
if (b == null || a.length != b.length) {
8493
return false;
85-
if (identical(a, b))
94+
}
95+
if (identical(a, b)) {
8696
return true;
97+
}
8798
for (final T key in a.keys) {
8899
if (!b.containsKey(key) || b[key] != a[key]) {
89100
return false;

packages/flutter/lib/src/foundation/consolidate_response.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,9 @@ Future<Uint8List> consolidateHttpClientResponseBytes(
5454
final _OutputBuffer output = _OutputBuffer();
5555
ByteConversionSink sink = output;
5656
int? expectedContentLength = response.contentLength;
57-
if (expectedContentLength == -1)
57+
if (expectedContentLength == -1) {
5858
expectedContentLength = null;
59+
}
5960
switch (response.compressionState) {
6061
case HttpClientResponseCompressionState.compressed:
6162
if (autoUncompress) {

packages/flutter/lib/src/foundation/debug.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ bool debugAssertAllFoundationVarsUnset(String reason, { DebugPrintCallback debug
2626
if (debugPrint != debugPrintOverride ||
2727
debugDefaultTargetPlatformOverride != null ||
2828
debugDoublePrecision != null ||
29-
debugBrightnessOverride != null)
29+
debugBrightnessOverride != null) {
3030
throw FlutterError(reason);
31+
}
3132
return true;
3233
}());
3334
return true;

0 commit comments

Comments
 (0)