33// found in the LICENSE file.
44
55import 'dart:async' ;
6+ import 'dart:convert' ;
67import 'dart:io' as io;
7- import 'dart:typed_data' show ByteData, Endian, Uint8List;
8+ import 'dart:typed_data' show ByteData, Uint8List;
89import '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' )
289299void 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' )
335345void 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