Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 67b6ae7

Browse files
authored
More diagnostic clean ups (#54265)
Towards flutter/flutter#152636. Almost all changes are `dart --fix`.
1 parent c91b82d commit 67b6ae7

File tree

4 files changed

+71
-62
lines changed

4 files changed

+71
-62
lines changed

lib/snapshot/pubspec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# found in the LICENSE file.
44

55
# This file is needed by Fuchsia's dart_library template.
6+
name: _snapshot_but_this_package_name_is_not_used
67

78
environment:
89
sdk: '>=3.2.0-0 <4.0.0'

runtime/fixtures/split_lib_test.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
library splitlib;
6-
75
int splitAdd(int i, int j) {
86
return i + j;
97
}

shell/platform/darwin/macos/framework/Source/fixtures/flutter_desktop_test.dart

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5+
// ignore_for_file: avoid_print
6+
57
import 'dart:io';
68
import 'dart:typed_data';
79
import 'dart:ui';
810

911
@pragma('vm:external-name', 'SignalNativeTest')
1012
external void signalNativeTest();
1113

12-
void main() {
13-
}
14+
void main() {}
1415

1516
@pragma('vm:entry-point')
16-
void empty() {
17-
}
17+
void empty() {}
1818

1919
/// Notifies the test of a string value.
2020
///
@@ -38,11 +38,11 @@ void canLogToStdout() {
3838
@pragma('vm:entry-point')
3939
void canCompositePlatformViews() {
4040
PlatformDispatcher.instance.onBeginFrame = (Duration duration) {
41-
SceneBuilder builder = SceneBuilder();
42-
builder.addPicture(Offset(1.0, 1.0), _createSimplePicture());
41+
final builder = SceneBuilder();
42+
builder.addPicture(const Offset(1.0, 1.0), _createSimplePicture());
4343
builder.pushOffset(1.0, 2.0);
4444
builder.addPlatformView(42, width: 123.0, height: 456.0);
45-
builder.addPicture(Offset(1.0, 1.0), _createSimplePicture());
45+
builder.addPicture(const Offset(1.0, 1.0), _createSimplePicture());
4646
builder.pop(); // offset
4747
PlatformDispatcher.instance.views.first.render(builder.build());
4848
};
@@ -52,8 +52,8 @@ void canCompositePlatformViews() {
5252
@pragma('vm:entry-point')
5353
void drawIntoAllViews() {
5454
PlatformDispatcher.instance.onBeginFrame = (Duration duration) {
55-
SceneBuilder builder = SceneBuilder();
56-
builder.addPicture(Offset(1.0, 1.0), _createSimplePicture());
55+
final builder = SceneBuilder();
56+
builder.addPicture(const Offset(1.0, 1.0), _createSimplePicture());
5757
for (final FlutterView view in PlatformDispatcher.instance.views) {
5858
view.render(builder.build());
5959
}
@@ -63,10 +63,10 @@ void drawIntoAllViews() {
6363

6464
/// Returns a [Picture] of a simple black square.
6565
Picture _createSimplePicture() {
66-
Paint blackPaint = Paint();
67-
PictureRecorder baseRecorder = PictureRecorder();
68-
Canvas canvas = Canvas(baseRecorder);
69-
canvas.drawRect(Rect.fromLTRB(0.0, 0.0, 1000.0, 1000.0), blackPaint);
66+
final blackPaint = Paint();
67+
final baseRecorder = PictureRecorder();
68+
final canvas = Canvas(baseRecorder);
69+
canvas.drawRect(const Rect.fromLTRB(0.0, 0.0, 1000.0, 1000.0), blackPaint);
7070
return baseRecorder.endRecording();
7171
}
7272

@@ -83,5 +83,6 @@ void backgroundTest() {
8383

8484
@pragma('vm:entry-point')
8585
void sendFooMessage() {
86-
PlatformDispatcher.instance.sendPlatformMessage('foo', null, (ByteData? result) {});
86+
PlatformDispatcher.instance
87+
.sendPlatformMessage('foo', null, (ByteData? result) {});
8788
}

shell/platform/windows/fixtures/main.dart

Lines changed: 55 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
// found in the LICENSE file.
44

55
import 'dart:async';
6+
import 'dart:convert';
67
import 'dart:io' as io;
7-
import 'dart:typed_data' show ByteData, Endian, Uint8List;
8+
import 'dart:typed_data' show ByteData, Uint8List;
89
import 'dart:ui' as ui;
9-
import 'dart:convert';
1010

1111
// Signals a waiting latch in the native test.
1212
@pragma('vm:external-name', 'Signal')
@@ -53,7 +53,7 @@ Future<void> get semanticsChanged {
5353
}
5454

5555
@pragma('vm:entry-point')
56-
void sendAccessibilityAnnouncement() async {
56+
Future<void> sendAccessibilityAnnouncement() async {
5757
// Wait until semantics are enabled.
5858
if (!ui.PlatformDispatcher.instance.semanticsEnabled) {
5959
await semanticsChanged;
@@ -91,7 +91,7 @@ void sendAccessibilityAnnouncement() async {
9191
}
9292

9393
@pragma('vm:entry-point')
94-
void sendAccessibilityTooltipEvent() async {
94+
Future<void> sendAccessibilityTooltipEvent() async {
9595
// Wait until semantics are enabled.
9696
if (!ui.PlatformDispatcher.instance.semanticsEnabled) {
9797
await semanticsChanged;
@@ -129,10 +129,13 @@ void sendAccessibilityTooltipEvent() async {
129129
}
130130

131131
@pragma('vm:entry-point')
132-
void exitTestExit() async {
132+
Future<void> exitTestExit() async {
133133
final Completer<ByteData?> closed = Completer<ByteData?>();
134-
ui.channelBuffers.setListener('flutter/platform', (ByteData? data, ui.PlatformMessageResponseCallback callback) async {
135-
final String jsonString = json.encode(<Map<String, String>>[{'response': 'exit'}]);
134+
ui.channelBuffers.setListener('flutter/platform',
135+
(ByteData? data, ui.PlatformMessageResponseCallback callback) async {
136+
final String jsonString = json.encode(<Map<String, String>>[
137+
{'response': 'exit'}
138+
]);
136139
final ByteData responseData = ByteData.sublistView(utf8.encode(jsonString));
137140
callback(responseData);
138141
closed.complete(data);
@@ -141,10 +144,13 @@ void exitTestExit() async {
141144
}
142145

143146
@pragma('vm:entry-point')
144-
void exitTestCancel() async {
147+
Future<void> exitTestCancel() async {
145148
final Completer<ByteData?> closed = Completer<ByteData?>();
146-
ui.channelBuffers.setListener('flutter/platform', (ByteData? data, ui.PlatformMessageResponseCallback callback) async {
147-
final String jsonString = json.encode(<Map<String, String>>[{'response': 'cancel'}]);
149+
ui.channelBuffers.setListener('flutter/platform',
150+
(ByteData? data, ui.PlatformMessageResponseCallback callback) async {
151+
final String jsonString = json.encode(<Map<String, String>>[
152+
{'response': 'cancel'}
153+
]);
148154
final ByteData responseData = ByteData.sublistView(utf8.encode(jsonString));
149155
callback(responseData);
150156
closed.complete(data);
@@ -155,53 +161,52 @@ void exitTestCancel() async {
155161
final Completer<ByteData?> exited = Completer<ByteData?>();
156162
final String jsonString = json.encode(<String, dynamic>{
157163
'method': 'System.exitApplication',
158-
'args': <String, dynamic>{
159-
'type': 'required', 'exitCode': 0
160-
}
161-
});
164+
'args': <String, dynamic>{'type': 'required', 'exitCode': 0}
165+
});
162166
ui.PlatformDispatcher.instance.sendPlatformMessage(
163-
'flutter/platform',
164-
ByteData.sublistView(utf8.encode(jsonString)),
165-
(ByteData? reply) {
166-
exited.complete(reply);
167-
});
167+
'flutter/platform', ByteData.sublistView(utf8.encode(jsonString)),
168+
(ByteData? reply) {
169+
exited.complete(reply);
170+
});
168171
await exited.future;
169172
}
170173

171174
@pragma('vm:entry-point')
172-
void enableLifecycleTest() async {
175+
Future<void> enableLifecycleTest() async {
173176
final Completer<ByteData?> finished = Completer<ByteData?>();
174-
ui.channelBuffers.setListener('flutter/lifecycle', (ByteData? data, ui.PlatformMessageResponseCallback callback) async {
177+
ui.channelBuffers.setListener('flutter/lifecycle',
178+
(ByteData? data, ui.PlatformMessageResponseCallback callback) async {
175179
if (data != null) {
176-
ui.PlatformDispatcher.instance.sendPlatformMessage(
177-
'flutter/unittest',
178-
data,
179-
(ByteData? reply) {
180-
finished.complete();
181-
});
180+
ui.PlatformDispatcher.instance
181+
.sendPlatformMessage('flutter/unittest', data, (ByteData? reply) {
182+
finished.complete();
183+
});
182184
}
183185
});
184186
await finished.future;
185187
}
186188

187189
@pragma('vm:entry-point')
188-
void enableLifecycleToFrom() async {
189-
ui.channelBuffers.setListener('flutter/lifecycle', (ByteData? data, ui.PlatformMessageResponseCallback callback) async {
190+
Future<void> enableLifecycleToFrom() async {
191+
ui.channelBuffers.setListener('flutter/lifecycle',
192+
(ByteData? data, ui.PlatformMessageResponseCallback callback) async {
190193
if (data != null) {
191-
ui.PlatformDispatcher.instance.sendPlatformMessage(
192-
'flutter/unittest',
193-
data,
194-
(ByteData? reply) {});
194+
ui.PlatformDispatcher.instance
195+
.sendPlatformMessage('flutter/unittest', data, (ByteData? reply) {});
195196
}
196197
});
197198
final Completer<ByteData?> enabledLifecycle = Completer<ByteData?>();
198-
ui.PlatformDispatcher.instance.sendPlatformMessage('flutter/platform', ByteData.sublistView(utf8.encode('{"method":"System.initializationComplete"}')), (ByteData? data) {
199+
ui.PlatformDispatcher.instance.sendPlatformMessage(
200+
'flutter/platform',
201+
ByteData.sublistView(
202+
utf8.encode('{"method":"System.initializationComplete"}')),
203+
(ByteData? data) {
199204
enabledLifecycle.complete(data);
200205
});
201206
}
202207

203208
@pragma('vm:entry-point')
204-
void sendCreatePlatformViewMethod() async {
209+
Future<void> sendCreatePlatformViewMethod() async {
205210
// The platform view method channel uses the standard method codec.
206211
// See https://github.com/flutter/flutter/blob/master/packages/flutter/lib/src/services/message_codecs.dart#L262
207212
// for the implementation of the encoding and magic number identifiers.
@@ -225,14 +230,15 @@ void sendCreatePlatformViewMethod() async {
225230

226231
final Completer<ByteData?> completed = Completer<ByteData?>();
227232
final ByteData bytes = ByteData.sublistView(Uint8List.fromList(data));
228-
ui.PlatformDispatcher.instance.sendPlatformMessage('flutter/platform_views', bytes, (ByteData? response) {
233+
ui.PlatformDispatcher.instance.sendPlatformMessage(
234+
'flutter/platform_views', bytes, (ByteData? response) {
229235
completed.complete(response);
230236
});
231237
await completed.future;
232238
}
233239

234240
@pragma('vm:entry-point')
235-
void sendGetKeyboardState() async {
241+
Future<void> sendGetKeyboardState() async {
236242
// The keyboard method channel uses the standard method codec.
237243
// See https://github.com/flutter/flutter/blob/master/packages/flutter/lib/src/services/message_codecs.dart#L262
238244
// for the implementation of the encoding and magic number identifiers.
@@ -250,7 +256,8 @@ void sendGetKeyboardState() async {
250256

251257
final Completer<void> completer = Completer<void>();
252258
final ByteData bytes = ByteData.sublistView(Uint8List.fromList(data));
253-
ui.PlatformDispatcher.instance.sendPlatformMessage('flutter/keyboard', bytes, (ByteData? response) {
259+
ui.PlatformDispatcher.instance.sendPlatformMessage('flutter/keyboard', bytes,
260+
(ByteData? response) {
254261
// For magic numbers for decoding a reply envelope, see:
255262
// https://github.com/flutter/flutter/blob/67271f69f7f88a4edba6d8023099e3bd27a072d2/packages/flutter/lib/src/services/message_codecs.dart#L577-L587
256263
const int replyEnvelopeSuccess = 0;
@@ -259,11 +266,14 @@ void sendGetKeyboardState() async {
259266
if (response == null) {
260267
signalStringValue('Unexpected null response');
261268
} else if (response.lengthInBytes < 2) {
262-
signalStringValue('Unexpected response length of ${response.lengthInBytes} bytes');
269+
signalStringValue(
270+
'Unexpected response length of ${response.lengthInBytes} bytes');
263271
} else if (response.getUint8(0) != replyEnvelopeSuccess) {
264-
signalStringValue('Unexpected response envelope status: ${response.getUint8(0)}');
272+
signalStringValue(
273+
'Unexpected response envelope status: ${response.getUint8(0)}');
265274
} else if (response.getUint8(1) != valueMap) {
266-
signalStringValue('Unexpected response value magic number: ${response.getUint8(1)}');
275+
signalStringValue(
276+
'Unexpected response value magic number: ${response.getUint8(1)}');
267277
} else {
268278
signalStringValue('Success');
269279
}
@@ -287,7 +297,7 @@ void verifyNativeFunctionWithParameters() {
287297

288298
@pragma('vm:entry-point')
289299
void verifyNativeFunctionWithReturn() {
290-
bool value = signalBoolReturn();
300+
final value = signalBoolReturn();
291301
signalBoolValue(value);
292302
}
293303

@@ -334,15 +344,14 @@ ui.Picture _createColoredBox(ui.Color color, ui.Size size) {
334344
@pragma('vm:entry-point')
335345
void renderImplicitView() {
336346
ui.PlatformDispatcher.instance.onBeginFrame = (Duration duration) {
337-
final ui.Size size = ui.Size(800.0, 600.0);
338-
final ui.Color red = ui.Color.fromARGB(127, 255, 0, 0);
347+
const ui.Size size = ui.Size(800.0, 600.0);
348+
const ui.Color red = ui.Color.fromARGB(127, 255, 0, 0);
339349

340350
final ui.SceneBuilder builder = ui.SceneBuilder();
341351

342352
builder.pushOffset(0.0, 0.0);
343353

344-
builder.addPicture(
345-
ui.Offset(0.0, 0.0), _createColoredBox(red, size));
354+
builder.addPicture(ui.Offset.zero, _createColoredBox(red, size));
346355

347356
builder.pop();
348357

0 commit comments

Comments
 (0)