From 3a829b81ada50ae9a2e241e1928121dc661e3b3a Mon Sep 17 00:00:00 2001 From: Matan Lurey Date: Wed, 31 Jul 2024 15:48:00 -0700 Subject: [PATCH] Remove pre-existing diagnostics with no behavioral changes. (flutter/engine#54264) Towards https://github.com/flutter/flutter/issues/152636. Most of these were via `dart --fix`. --- .../platform/embedder/fixtures/main.dart | 390 ++++++++++-------- 1 file changed, 227 insertions(+), 163 deletions(-) diff --git a/engine/src/flutter/shell/platform/embedder/fixtures/main.dart b/engine/src/flutter/shell/platform/embedder/fixtures/main.dart index 96cee3274a..6f3986b5eb 100644 --- a/engine/src/flutter/shell/platform/embedder/fixtures/main.dart +++ b/engine/src/flutter/shell/platform/embedder/fixtures/main.dart @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// ignore_for_file: avoid_print + import 'dart:async'; import 'dart:convert'; import 'dart:core'; @@ -37,7 +39,7 @@ external void sayHiFromCustomEntrypoint3(); @pragma('vm:entry-point') void terminateExitCodeHandler() { - final ProcessResult result = Process.runSync('ls', []); + Process.runSync('ls', []); } @pragma('vm:entry-point') @@ -125,6 +127,7 @@ Future get semanticsActionEvent { } @pragma('vm:entry-point') +// ignore: non_constant_identifier_names Future a11y_main() async { // 1: Return initial state (semantics disabled). notifySemanticsEnabled(PlatformDispatcher.instance.semanticsEnabled); @@ -149,7 +152,7 @@ Future a11y_main() async { identifier: '', label: 'A: root', labelAttributes: [], - rect: Rect.fromLTRB(0.0, 0.0, 10.0, 10.0), + rect: const Rect.fromLTRB(0.0, 0.0, 10.0, 10.0), transform: kTestTransform, childrenInTraversalOrder: Int32List.fromList([84, 96]), childrenInHitTestOrder: Int32List.fromList([96, 84]), @@ -178,15 +181,13 @@ Future a11y_main() async { tooltip: 'tooltip', textDirection: TextDirection.ltr, additionalActions: Int32List(0), - headingLevel: 0, - linkUrl: '', ) ..updateNode( id: 84, identifier: '', label: 'B: leaf', labelAttributes: [], - rect: Rect.fromLTRB(40.0, 40.0, 80.0, 80.0), + rect: const Rect.fromLTRB(40.0, 40.0, 80.0, 80.0), transform: kTestTransform, actions: 0, flags: 0, @@ -215,15 +216,13 @@ Future a11y_main() async { additionalActions: Int32List(0), childrenInHitTestOrder: Int32List(0), childrenInTraversalOrder: Int32List(0), - headingLevel: 0, - linkUrl: '', ) ..updateNode( id: 96, identifier: '', label: 'C: branch', labelAttributes: [], - rect: Rect.fromLTRB(40.0, 40.0, 80.0, 80.0), + rect: const Rect.fromLTRB(40.0, 40.0, 80.0, 80.0), transform: kTestTransform, childrenInTraversalOrder: Int32List.fromList([128]), childrenInHitTestOrder: Int32List.fromList([128]), @@ -252,15 +251,13 @@ Future a11y_main() async { tooltip: 'tooltip', textDirection: TextDirection.ltr, additionalActions: Int32List(0), - headingLevel: 0, - linkUrl: '', ) ..updateNode( id: 128, identifier: '', label: 'D: leaf', labelAttributes: [], - rect: Rect.fromLTRB(40.0, 40.0, 80.0, 80.0), + rect: const Rect.fromLTRB(40.0, 40.0, 80.0, 80.0), transform: kTestTransform, additionalActions: Int32List.fromList([21]), platformViewId: 0x3f3, @@ -289,8 +286,6 @@ Future a11y_main() async { textDirection: TextDirection.ltr, childrenInHitTestOrder: Int32List(0), childrenInTraversalOrder: Int32List(0), - headingLevel: 0, - linkUrl: '', ) ..updateCustomAction( id: 21, @@ -316,6 +311,7 @@ Future a11y_main() async { } @pragma('vm:entry-point') +// ignore: non_constant_identifier_names Future a11y_string_attributes() async { // 1: Wait until semantics are enabled. if (!PlatformDispatcher.instance.semanticsEnabled) { @@ -330,14 +326,15 @@ Future a11y_string_attributes() async { label: 'What is the meaning of life?', labelAttributes: [ LocaleStringAttribute( - range: TextRange(start: 0, end: 'What is the meaning of life?'.length), - locale: Locale('en'), + range: const TextRange( + start: 0, end: 'What is the meaning of life?'.length), + locale: const Locale('en'), ), SpellOutStringAttribute( - range: TextRange(start: 0, end: 1), + range: const TextRange(start: 0, end: 1), ), ], - rect: Rect.fromLTRB(0.0, 0.0, 10.0, 10.0), + rect: const Rect.fromLTRB(0.0, 0.0, 10.0, 10.0), transform: kTestTransform, childrenInTraversalOrder: Int32List.fromList([84, 96]), childrenInHitTestOrder: Int32List.fromList([96, 84]), @@ -358,28 +355,28 @@ Future a11y_string_attributes() async { hint: "It's a number", hintAttributes: [ LocaleStringAttribute( - range: TextRange(start: 0, end: 1), - locale: Locale('en'), + range: const TextRange(start: 0, end: 1), + locale: const Locale('en'), ), LocaleStringAttribute( - range: TextRange(start: 2, end: 3), - locale: Locale('fr'), + range: const TextRange(start: 2, end: 3), + locale: const Locale('fr'), ), ], value: '42', valueAttributes: [ LocaleStringAttribute( - range: TextRange(start: 0, end: '42'.length), - locale: Locale('en', 'US'), + range: const TextRange(start: 0, end: '42'.length), + locale: const Locale('en', 'US'), ), ], increasedValue: '43', increasedValueAttributes: [ SpellOutStringAttribute( - range: TextRange(start: 0, end: 1), + range: const TextRange(start: 0, end: 1), ), SpellOutStringAttribute( - range: TextRange(start: 1, end: 2), + range: const TextRange(start: 1, end: 2), ), ], decreasedValue: '41', @@ -387,8 +384,6 @@ Future a11y_string_attributes() async { tooltip: 'tooltip', textDirection: TextDirection.ltr, additionalActions: Int32List(0), - headingLevel: 0, - linkUrl: '', ); PlatformDispatcher.instance.views.first.updateSemantics(builder.build()); @@ -396,6 +391,7 @@ Future a11y_string_attributes() async { } @pragma('vm:entry-point') +// ignore: non_constant_identifier_names void platform_messages_response() { PlatformDispatcher.instance.onPlatformMessage = (String name, ByteData? data, PlatformMessageResponseCallback? callback) { @@ -405,10 +401,12 @@ void platform_messages_response() { } @pragma('vm:entry-point') +// ignore: non_constant_identifier_names void platform_messages_no_response() { PlatformDispatcher.instance.onPlatformMessage = (String name, ByteData? data, PlatformMessageResponseCallback? callback) { - final Uint8List list = data!.buffer.asUint8List(data.offsetInBytes, data.lengthInBytes); + final Uint8List list = + data!.buffer.asUint8List(data.offsetInBytes, data.lengthInBytes); signalNativeMessage(utf8.decode(list)); // This does nothing because no one is listening on the other side. But complete the loop anyway // to make sure all null checking on response handles in the engine is in place. @@ -418,6 +416,7 @@ void platform_messages_no_response() { } @pragma('vm:entry-point') +// ignore: non_constant_identifier_names void null_platform_messages() { PlatformDispatcher.instance.onPlatformMessage = (String name, ByteData? data, PlatformMessageResponseCallback? callback) { @@ -428,24 +427,26 @@ void null_platform_messages() { signalNativeTest(); } -Picture CreateSimplePicture() { +Picture createSimplePicture() { final Paint blackPaint = Paint(); - final Paint whitePaint = Paint()..color = Color.fromARGB(255, 255, 255, 255); + final Paint whitePaint = Paint() + ..color = const Color.fromARGB(255, 255, 255, 255); final PictureRecorder baseRecorder = PictureRecorder(); final Canvas canvas = Canvas(baseRecorder); - canvas.drawRect(Rect.fromLTRB(0.0, 0.0, 1000.0, 1000.0), blackPaint); - canvas.drawRect(Rect.fromLTRB(10.0, 10.0, 990.0, 990.0), whitePaint); + canvas.drawRect(const Rect.fromLTRB(0.0, 0.0, 1000.0, 1000.0), blackPaint); + canvas.drawRect(const Rect.fromLTRB(10.0, 10.0, 990.0, 990.0), whitePaint); return baseRecorder.endRecording(); } @pragma('vm:entry-point') +// ignore: non_constant_identifier_names void can_composite_platform_views() { PlatformDispatcher.instance.onBeginFrame = (Duration duration) { final SceneBuilder builder = SceneBuilder(); - builder.addPicture(Offset(1.0, 1.0), CreateSimplePicture()); + builder.addPicture(const Offset(1.0, 1.0), createSimplePicture()); builder.pushOffset(1.0, 2.0); builder.addPlatformView(42, width: 123.0, height: 456.0); - builder.addPicture(Offset(1.0, 1.0), CreateSimplePicture()); + builder.addPicture(const Offset(1.0, 1.0), createSimplePicture()); builder.pop(); // offset signalNativeTest(); // Signal 2 PlatformDispatcher.instance.views.first.render(builder.build()); @@ -455,6 +456,7 @@ void can_composite_platform_views() { } @pragma('vm:entry-point') +// ignore: non_constant_identifier_names void can_composite_platform_views_with_opacity() { PlatformDispatcher.instance.onBeginFrame = (Duration duration) { final SceneBuilder builder = SceneBuilder(); @@ -464,7 +466,7 @@ void can_composite_platform_views_with_opacity() { // First sibling layer (no platform view, should be cached) builder.pushOpacity(127); - builder.addPicture(Offset(1.0, 1.0), CreateSimplePicture()); + builder.addPicture(const Offset(1.0, 1.0), createSimplePicture()); builder.pop(); // Second sibling layer (platform view, should not be cached) @@ -474,7 +476,7 @@ void can_composite_platform_views_with_opacity() { // Third sibling layer (no platform view, should be cached) builder.pushOpacity(127); - builder.addPicture(Offset(2.0, 1.0), CreateSimplePicture()); + builder.addPicture(const Offset(2.0, 1.0), createSimplePicture()); builder.pop(); signalNativeTest(); // Signal 2 @@ -485,11 +487,12 @@ void can_composite_platform_views_with_opacity() { } @pragma('vm:entry-point') +// ignore: non_constant_identifier_names void can_composite_with_opacity() { PlatformDispatcher.instance.onBeginFrame = (Duration duration) { final SceneBuilder builder = SceneBuilder(); builder.pushOpacity(127); - builder.addPicture(Offset(1.0, 1.0), CreateSimplePicture()); + builder.addPicture(const Offset(1.0, 1.0), createSimplePicture()); builder.pop(); // offset signalNativeTest(); // Signal 2 PlatformDispatcher.instance.views.first.render(builder.build()); @@ -498,7 +501,7 @@ void can_composite_with_opacity() { PlatformDispatcher.instance.scheduleFrame(); } -Picture CreateColoredBox(Color color, Size size) { +Picture createColoredBox(Color color, Size size) { final Paint paint = Paint(); paint.color = color; final PictureRecorder baseRecorder = PictureRecorder(); @@ -508,20 +511,21 @@ Picture CreateColoredBox(Color color, Size size) { } @pragma('vm:entry-point') +// ignore: non_constant_identifier_names void can_composite_platform_views_with_known_scene() { PlatformDispatcher.instance.onBeginFrame = (Duration duration) { - final Color red = Color.fromARGB(127, 255, 0, 0); - final Color blue = Color.fromARGB(127, 0, 0, 255); - final Color gray = Color.fromARGB(127, 127, 127, 127); + const Color red = Color.fromARGB(127, 255, 0, 0); + const Color blue = Color.fromARGB(127, 0, 0, 255); + const Color gray = Color.fromARGB(127, 127, 127, 127); - final Size size = Size(50.0, 150.0); + const Size size = Size(50.0, 150.0); final SceneBuilder builder = SceneBuilder(); builder.pushOffset(0.0, 0.0); // 10 (Index 0) builder.addPicture( - Offset(10.0, 10.0), CreateColoredBox(red, size)); // red - flutter + const Offset(10.0, 10.0), createColoredBox(red, size)); // red - flutter builder.pushOffset(20.0, 20.0); // 20 (Index 1) @@ -530,8 +534,8 @@ void can_composite_platform_views_with_known_scene() { builder.pop(); // 30 (Index 2) - builder.addPicture( - Offset(30.0, 30.0), CreateColoredBox(blue, size)); // blue - flutter + builder.addPicture(const Offset(30.0, 30.0), + createColoredBox(blue, size)); // blue - flutter builder.pushOffset(40.0, 40.0); // 40 (Index 3) @@ -540,8 +544,8 @@ void can_composite_platform_views_with_known_scene() { builder.pop(); // 50 (Index 4) - builder.addPicture( - Offset(50.0, 50.0), CreateColoredBox(gray, size)); // gray - flutter + builder.addPicture(const Offset(50.0, 50.0), + createColoredBox(gray, size)); // gray - flutter builder.pop(); @@ -554,20 +558,20 @@ void can_composite_platform_views_with_known_scene() { } @pragma('vm:entry-point') +// ignore: non_constant_identifier_names void can_composite_platform_views_transparent_overlay() { PlatformDispatcher.instance.onBeginFrame = (Duration duration) { - final Color red = Color.fromARGB(127, 255, 0, 0); - final Color blue = Color.fromARGB(127, 0, 0, 255); - final Color transparent = Color(0xFFFFFF); + const Color red = Color.fromARGB(127, 255, 0, 0); + const Color transparent = Color(0x00ffffff); - final Size size = Size(50.0, 150.0); + const Size size = Size(50.0, 150.0); final SceneBuilder builder = SceneBuilder(); builder.pushOffset(0.0, 0.0); // 10 (Index 0) builder.addPicture( - Offset(10.0, 10.0), CreateColoredBox(red, size)); // red - flutter + const Offset(10.0, 10.0), createColoredBox(red, size)); // red - flutter builder.pushOffset(20.0, 20.0); // 20 (Index 1) @@ -577,7 +581,9 @@ void can_composite_platform_views_transparent_overlay() { // 30 (Index 2) builder.addPicture( - Offset(30.0, 30.0), CreateColoredBox(transparent, size)); // transparent picture, no layer should be created. + const Offset(30.0, 30.0), + createColoredBox(transparent, + size)); // transparent picture, no layer should be created. builder.pop(); @@ -590,19 +596,18 @@ void can_composite_platform_views_transparent_overlay() { } @pragma('vm:entry-point') +// ignore: non_constant_identifier_names void can_composite_platform_views_no_overlay() { PlatformDispatcher.instance.onBeginFrame = (Duration duration) { - final Color red = Color.fromARGB(127, 255, 0, 0); - final Color blue = Color.fromARGB(127, 0, 0, 255); - - final Size size = Size(50.0, 150.0); + const Color red = Color.fromARGB(127, 255, 0, 0); + const Size size = Size(50.0, 150.0); final SceneBuilder builder = SceneBuilder(); builder.pushOffset(0.0, 0.0); // 10 (Index 0) builder.addPicture( - Offset(10.0, 10.0), CreateColoredBox(red, size)); // red - flutter + const Offset(10.0, 10.0), createColoredBox(red, size)); // red - flutter builder.pushOffset(20.0, 20.0); // 20 (Index 1) @@ -619,19 +624,19 @@ void can_composite_platform_views_no_overlay() { PlatformDispatcher.instance.scheduleFrame(); } - @pragma('vm:entry-point') +// ignore: non_constant_identifier_names void can_composite_platform_views_with_root_layer_only() { PlatformDispatcher.instance.onBeginFrame = (Duration duration) { - final Color red = Color.fromARGB(127, 255, 0, 0); - final Size size = Size(50.0, 150.0); + const Color red = Color.fromARGB(127, 255, 0, 0); + const Size size = Size(50.0, 150.0); final SceneBuilder builder = SceneBuilder(); builder.pushOffset(0.0, 0.0); // 10 (Index 0) builder.addPicture( - Offset(10.0, 10.0), CreateColoredBox(red, size)); // red - flutter + const Offset(10.0, 10.0), createColoredBox(red, size)); // red - flutter builder.pop(); PlatformDispatcher.instance.views.first.render(builder.build()); @@ -643,17 +648,18 @@ void can_composite_platform_views_with_root_layer_only() { } @pragma('vm:entry-point') +// ignore: non_constant_identifier_names void can_composite_platform_views_with_platform_layer_on_bottom() { PlatformDispatcher.instance.onBeginFrame = (Duration duration) { - final Color red = Color.fromARGB(127, 255, 0, 0); - final Size size = Size(50.0, 150.0); + const Color red = Color.fromARGB(127, 255, 0, 0); + const Size size = Size(50.0, 150.0); final SceneBuilder builder = SceneBuilder(); builder.pushOffset(0.0, 0.0); // 10 (Index 0) builder.addPicture( - Offset(10.0, 10.0), CreateColoredBox(red, size)); // red - flutter + const Offset(10.0, 10.0), createColoredBox(red, size)); // red - flutter builder.pushOffset(20.0, 20.0); // 20 (Index 1) @@ -671,53 +677,56 @@ void can_composite_platform_views_with_platform_layer_on_bottom() { } @pragma('vm:external-name', 'SignalBeginFrame') +// ignore: unreachable_from_main external void signalBeginFrame(); @pragma('vm:entry-point') -Future texture_destruction_callback_called_without_custom_compositor() async { +Future + // ignore: non_constant_identifier_names + texture_destruction_callback_called_without_custom_compositor() async { PlatformDispatcher.instance.onBeginFrame = (Duration duration) { - final Color red = Color.fromARGB(127, 255, 0, 0); - final Size size = Size(50.0, 150.0); + const Color red = Color.fromARGB(127, 255, 0, 0); + const Size size = Size(50.0, 150.0); final SceneBuilder builder = SceneBuilder(); builder.pushOffset(0.0, 0.0); builder.addPicture( - Offset(10.0, 10.0), CreateColoredBox(red, size)); // red - flutter + const Offset(10.0, 10.0), createColoredBox(red, size)); // red - flutter builder.pop(); PlatformDispatcher.instance.views.first.render(builder.build()); }; PlatformDispatcher.instance.scheduleFrame(); } - @pragma('vm:entry-point') +// ignore: non_constant_identifier_names void can_render_scene_without_custom_compositor() { PlatformDispatcher.instance.onBeginFrame = (Duration duration) { - final Color red = Color.fromARGB(127, 255, 0, 0); - final Color green = Color.fromARGB(127, 0, 255, 0); - final Color blue = Color.fromARGB(127, 0, 0, 255); - final Color magenta = Color.fromARGB(127, 255, 0, 255); - final Color gray = Color.fromARGB(127, 127, 127, 127); + const Color red = Color.fromARGB(127, 255, 0, 0); + const Color green = Color.fromARGB(127, 0, 255, 0); + const Color blue = Color.fromARGB(127, 0, 0, 255); + const Color magenta = Color.fromARGB(127, 255, 0, 255); + const Color gray = Color.fromARGB(127, 127, 127, 127); - final Size size = Size(50.0, 150.0); + const Size size = Size(50.0, 150.0); final SceneBuilder builder = SceneBuilder(); builder.pushOffset(0.0, 0.0); builder.addPicture( - Offset(10.0, 10.0), CreateColoredBox(red, size)); // red - flutter + const Offset(10.0, 10.0), createColoredBox(red, size)); // red - flutter - builder.addPicture( - Offset(20.0, 20.0), CreateColoredBox(green, size)); // green - flutter + builder.addPicture(const Offset(20.0, 20.0), + createColoredBox(green, size)); // green - flutter - builder.addPicture( - Offset(30.0, 30.0), CreateColoredBox(blue, size)); // blue - flutter + builder.addPicture(const Offset(30.0, 30.0), + createColoredBox(blue, size)); // blue - flutter - builder.addPicture(Offset(40.0, 40.0), - CreateColoredBox(magenta, size)); // magenta - flutter + builder.addPicture(const Offset(40.0, 40.0), + createColoredBox(magenta, size)); // magenta - flutter - builder.addPicture( - Offset(50.0, 50.0), CreateColoredBox(gray, size)); // gray - flutter + builder.addPicture(const Offset(50.0, 50.0), + createColoredBox(gray, size)); // gray - flutter builder.pop(); @@ -726,16 +735,16 @@ void can_render_scene_without_custom_compositor() { PlatformDispatcher.instance.scheduleFrame(); } -Picture CreateGradientBox(Size size) { +Picture createGradientBox(Size size) { final Paint paint = Paint(); final List rainbow = [ - Color.fromARGB(255, 255, 0, 0), // red - Color.fromARGB(255, 255, 165, 0), // orange - Color.fromARGB(255, 255, 255, 0), // yellow - Color.fromARGB(255, 0, 255, 0), // green - Color.fromARGB(255, 0, 0, 255), // blue - Color.fromARGB(255, 75, 0, 130), // indigo - Color.fromARGB(255, 238, 130, 238), // violet + const Color.fromARGB(255, 255, 0, 0), // red + const Color.fromARGB(255, 255, 165, 0), // orange + const Color.fromARGB(255, 255, 255, 0), // yellow + const Color.fromARGB(255, 0, 255, 0), // green + const Color.fromARGB(255, 0, 0, 255), // blue + const Color.fromARGB(255, 75, 0, 130), // indigo + const Color.fromARGB(255, 238, 130, 238), // violet ]; final List stops = [ (1.0 / 7.0), @@ -747,7 +756,7 @@ Picture CreateGradientBox(Size size) { (7.0 / 7.0), ]; paint.shader = Gradient.linear( - Offset(0.0, 0.0), Offset(size.width, size.height), rainbow, stops); + Offset.zero, Offset(size.width, size.height), rainbow, stops); final PictureRecorder baseRecorder = PictureRecorder(); final Canvas canvas = Canvas(baseRecorder); canvas.drawRect(Rect.fromLTRB(0.0, 0.0, size.width, size.height), paint); @@ -794,6 +803,7 @@ int _serializeKeyEventDeviceType(KeyEventDeviceType deviceType) { // Echo the event data with `_echoKeyEvent`, and returns synthesized as handled. @pragma('vm:entry-point') +// ignore: non_constant_identifier_names Future key_data_echo() async { PlatformDispatcher.instance.onKeyData = (KeyData data) { _echoKeyEvent( @@ -813,6 +823,7 @@ Future key_data_echo() async { // After platform channel 'test/starts_echo' receives a message, starts echoing // the event data with `_echoKeyEvent`, and returns synthesized as handled. @pragma('vm:entry-point') +// ignore: non_constant_identifier_names Future key_data_late_echo() async { channelBuffers.setListener('test/starts_echo', (ByteData? data, PlatformMessageResponseCallback callback) { @@ -834,17 +845,17 @@ Future key_data_late_echo() async { } @pragma('vm:entry-point') +// ignore: non_constant_identifier_names void render_implicit_view() { PlatformDispatcher.instance.onBeginFrame = (Duration duration) { - final Size size = Size(800.0, 600.0); - final Color red = Color.fromARGB(127, 255, 0, 0); + const Size size = Size(800.0, 600.0); + const Color red = Color.fromARGB(127, 255, 0, 0); final SceneBuilder builder = SceneBuilder(); builder.pushOffset(0.0, 0.0); - builder.addPicture( - Offset(0.0, 0.0), CreateColoredBox(red, size)); + builder.addPicture(Offset.zero, createColoredBox(red, size)); builder.pop(); @@ -854,18 +865,18 @@ void render_implicit_view() { } @pragma('vm:entry-point') +// ignore: non_constant_identifier_names void render_all_views() { PlatformDispatcher.instance.onBeginFrame = (Duration duration) { for (final FlutterView view in PlatformDispatcher.instance.views) { - final Size size = Size(800.0, 600.0); - final Color red = Color.fromARGB(127, 255, 0, 0); + const Size size = Size(800.0, 600.0); + const Color red = Color.fromARGB(127, 255, 0, 0); final SceneBuilder builder = SceneBuilder(); builder.pushOffset(0.0, 0.0); - builder.addPicture( - Offset(0.0, 0.0), CreateColoredBox(red, size)); + builder.addPicture(Offset.zero, createColoredBox(red, size)); builder.pop(); @@ -876,16 +887,17 @@ void render_all_views() { } @pragma('vm:entry-point') +// ignore: non_constant_identifier_names void render_gradient() { PlatformDispatcher.instance.onBeginFrame = (Duration duration) { - final Size size = Size(800.0, 600.0); + const Size size = Size(800.0, 600.0); final SceneBuilder builder = SceneBuilder(); builder.pushOffset(0.0, 0.0); builder.addPicture( - Offset(0.0, 0.0), CreateGradientBox(size)); // gradient - flutter + Offset.zero, createGradientBox(size)); // gradient - flutter builder.pop(); @@ -895,9 +907,10 @@ void render_gradient() { } @pragma('vm:entry-point') +// ignore: non_constant_identifier_names void render_texture() { PlatformDispatcher.instance.onBeginFrame = (Duration duration) { - final Size size = Size(800.0, 600.0); + const Size size = Size(800.0, 600.0); final SceneBuilder builder = SceneBuilder(); @@ -913,10 +926,11 @@ void render_texture() { } @pragma('vm:entry-point') +// ignore: non_constant_identifier_names void render_gradient_on_non_root_backing_store() { PlatformDispatcher.instance.onBeginFrame = (Duration duration) { - final Size size = Size(800.0, 600.0); - final Color red = Color.fromARGB(127, 255, 0, 0); + const Size size = Size(800.0, 600.0); + const Color red = Color.fromARGB(127, 255, 0, 0); final SceneBuilder builder = SceneBuilder(); @@ -924,12 +938,12 @@ void render_gradient_on_non_root_backing_store() { // Even though this is occluded, add something so it is not elided. builder.addPicture( - Offset(10.0, 10.0), CreateColoredBox(red, size)); // red - flutter + const Offset(10.0, 10.0), createColoredBox(red, size)); // red - flutter builder.addPlatformView(1, width: 100, height: 200); // undefined - platform builder.addPicture( - Offset(0.0, 0.0), CreateGradientBox(size)); // gradient - flutter + Offset.zero, createGradientBox(size)); // gradient - flutter builder.pop(); @@ -939,13 +953,14 @@ void render_gradient_on_non_root_backing_store() { } @pragma('vm:entry-point') +// ignore: non_constant_identifier_names void verify_b141980393() { PlatformDispatcher.instance.onBeginFrame = (Duration duration) { // The platform view in the test case is screen sized but with margins of 31 // and 37 points from the top and bottom. const double topMargin = 31.0; const double bottomMargin = 37.0; - final Size platformViewSize = Size(800.0, 600.0 - topMargin - bottomMargin); + const Size platformViewSize = Size(800.0, 600.0 - topMargin - bottomMargin); final SceneBuilder builder = SceneBuilder(); @@ -966,6 +981,7 @@ void verify_b141980393() { } @pragma('vm:entry-point') +// ignore: non_constant_identifier_names void can_display_platform_view_with_pixel_ratio() { PlatformDispatcher.instance.onBeginFrame = (Duration duration) { final SceneBuilder builder = SceneBuilder(); @@ -987,12 +1003,15 @@ void can_display_platform_view_with_pixel_ratio() { 0.0, 1.0 ])); // base - builder.addPicture(Offset(0.0, 0.0), CreateGradientBox(Size(400.0, 300.0))); + builder.addPicture( + Offset.zero, createGradientBox(const Size(400.0, 300.0))); builder.pushOffset(0.0, 20.0); // offset builder.addPlatformView(42, width: 400.0, height: 280.0); builder.pop(); // offset - builder.addPicture(Offset(0.0, 0.0), - CreateColoredBox(Color.fromARGB(128, 255, 0, 0), Size(400.0, 300.0))); + builder.addPicture( + Offset.zero, + createColoredBox( + const Color.fromARGB(128, 255, 0, 0), const Size(400.0, 300.0))); builder.pop(); // base PlatformDispatcher.instance.views.first.render(builder.build()); }; @@ -1000,6 +1019,7 @@ void can_display_platform_view_with_pixel_ratio() { } @pragma('vm:entry-point') +// ignore: non_constant_identifier_names void can_receive_locale_updates() { PlatformDispatcher.instance.onLocaleChanged = () { signalNativeCount(PlatformDispatcher.instance.locales.length); @@ -1009,6 +1029,7 @@ void can_receive_locale_updates() { // Verifies behavior tracked in https://github.com/flutter/flutter/issues/43732 @pragma('vm:entry-point') +// ignore: non_constant_identifier_names void verify_b143464703() { PlatformDispatcher.instance.onBeginFrame = (Duration duration) { final SceneBuilder builder = SceneBuilder(); @@ -1016,13 +1037,15 @@ void verify_b143464703() { // Background builder.addPicture( - Offset(0.0, 0.0), - CreateColoredBox( - Color.fromARGB(255, 128, 128, 128), Size(1024.0, 600.0))); + Offset.zero, + createColoredBox(const Color.fromARGB(255, 128, 128, 128), + const Size(1024.0, 600.0))); builder.pushOpacity(128); - builder.addPicture(Offset(10.0, 10.0), - CreateColoredBox(Color.fromARGB(255, 0, 0, 255), Size(25.0, 25.0))); + builder.addPicture( + const Offset(10.0, 10.0), + createColoredBox( + const Color.fromARGB(255, 0, 0, 255), const Size(25.0, 25.0))); builder.pop(); // opacity 128 // The top bar and the platform view are pushed to the side. @@ -1035,7 +1058,8 @@ void verify_b143464703() { builder.pop(); // 2 // Top bar - builder.addPicture(Offset(0.0, 0.0), CreateGradientBox(Size(1024.0, 60.0))); + builder.addPicture( + Offset.zero, createGradientBox(const Size(1024.0, 60.0))); builder.pop(); // opacity builder.pop(); // 1 @@ -1047,14 +1071,15 @@ void verify_b143464703() { } @pragma('vm:entry-point') +// ignore: non_constant_identifier_names void push_frames_over_and_over() { PlatformDispatcher.instance.onBeginFrame = (Duration duration) { final SceneBuilder builder = SceneBuilder(); builder.pushOffset(0.0, 0.0); builder.addPicture( - Offset(0.0, 0.0), - CreateColoredBox( - Color.fromARGB(255, 128, 128, 128), Size(1024.0, 600.0))); + Offset.zero, + createColoredBox(const Color.fromARGB(255, 128, 128, 128), + const Size(1024.0, 600.0))); builder.pushOpacity(128); builder.addPlatformView(42, width: 1024.0, height: 540.0); builder.pop(); @@ -1067,16 +1092,19 @@ void push_frames_over_and_over() { } @pragma('vm:entry-point') +// ignore: non_constant_identifier_names void platform_view_mutators() { PlatformDispatcher.instance.onBeginFrame = (Duration duration) { final SceneBuilder builder = SceneBuilder(); builder.pushOffset(0.0, 0.0); // base - builder.addPicture(Offset(0.0, 0.0), CreateGradientBox(Size(800.0, 600.0))); + builder.addPicture( + Offset.zero, createGradientBox(const Size(800.0, 600.0))); builder.pushOpacity(128); - builder.pushClipRect(Rect.fromLTWH(10.0, 10.0, 800.0 - 20.0, 600.0 - 20.0)); + builder.pushClipRect( + const Rect.fromLTWH(10.0, 10.0, 800.0 - 20.0, 600.0 - 20.0)); builder.pushClipRRect(RRect.fromLTRBR( - 10.0, 10.0, 800.0 - 10.0, 600.0 - 10.0, Radius.circular(14.0))); + 10.0, 10.0, 800.0 - 10.0, 600.0 - 10.0, const Radius.circular(14.0))); builder.addPlatformView(42, width: 800.0, height: 600.0); builder.pop(); // clip rrect builder.pop(); // clip rect @@ -1089,16 +1117,19 @@ void platform_view_mutators() { } @pragma('vm:entry-point') +// ignore: non_constant_identifier_names void platform_view_mutators_with_pixel_ratio() { PlatformDispatcher.instance.onBeginFrame = (Duration duration) { final SceneBuilder builder = SceneBuilder(); builder.pushOffset(0.0, 0.0); // base - builder.addPicture(Offset(0.0, 0.0), CreateGradientBox(Size(400.0, 300.0))); + builder.addPicture( + Offset.zero, createGradientBox(const Size(400.0, 300.0))); builder.pushOpacity(128); - builder.pushClipRect(Rect.fromLTWH(5.0, 5.0, 400.0 - 10.0, 300.0 - 10.0)); + builder.pushClipRect( + const Rect.fromLTWH(5.0, 5.0, 400.0 - 10.0, 300.0 - 10.0)); builder.pushClipRRect(RRect.fromLTRBR( - 5.0, 5.0, 400.0 - 5.0, 300.0 - 5.0, Radius.circular(7.0))); + 5.0, 5.0, 400.0 - 5.0, 300.0 - 5.0, const Radius.circular(7.0))); builder.addPlatformView(42, width: 400.0, height: 300.0); builder.pop(); // clip rrect builder.pop(); // clip rect @@ -1111,6 +1142,7 @@ void platform_view_mutators_with_pixel_ratio() { } @pragma('vm:entry-point') +// ignore: non_constant_identifier_names void empty_scene() { PlatformDispatcher.instance.onBeginFrame = (Duration duration) { PlatformDispatcher.instance.views.first.render(SceneBuilder().build()); @@ -1120,17 +1152,19 @@ void empty_scene() { } @pragma('vm:entry-point') +// ignore: non_constant_identifier_names void scene_with_no_container() { PlatformDispatcher.instance.onBeginFrame = (Duration duration) { final SceneBuilder builder = SceneBuilder(); - builder.addPicture(Offset(0.0, 0.0), CreateGradientBox(Size(400.0, 300.0))); + builder.addPicture( + Offset.zero, createGradientBox(const Size(400.0, 300.0))); PlatformDispatcher.instance.views.first.render(builder.build()); signalNativeTest(); }; PlatformDispatcher.instance.scheduleFrame(); } -Picture CreateArcEndCapsPicture() { +Picture createArcEndCapsPicture() { final PictureRecorder baseRecorder = PictureRecorder(); final Canvas canvas = Canvas(baseRecorder); @@ -1140,49 +1174,53 @@ Picture CreateArcEndCapsPicture() { ..strokeCap = StrokeCap.round ..strokeJoin = StrokeJoin.miter; - style.color = Color.fromARGB(255, 255, 0, 0); + style.color = const Color.fromARGB(255, 255, 0, 0); canvas.drawArc( - Rect.fromLTRB(0.0, 0.0, 500.0, 500.0), 1.57, 1.0, false, style); + const Rect.fromLTRB(0.0, 0.0, 500.0, 500.0), 1.57, 1.0, false, style); return baseRecorder.endRecording(); } @pragma('vm:entry-point') +// ignore: non_constant_identifier_names void arc_end_caps_correct() { PlatformDispatcher.instance.onBeginFrame = (Duration duration) { final SceneBuilder builder = SceneBuilder(); - builder.addPicture(Offset(0.0, 0.0), CreateArcEndCapsPicture()); + builder.addPicture(Offset.zero, createArcEndCapsPicture()); PlatformDispatcher.instance.views.first.render(builder.build()); }; PlatformDispatcher.instance.scheduleFrame(); } @pragma('vm:entry-point') +// ignore: non_constant_identifier_names void scene_builder_with_clips() { PlatformDispatcher.instance.onBeginFrame = (Duration duration) { final SceneBuilder builder = SceneBuilder(); - builder.pushClipRect(Rect.fromLTRB(10.0, 10.0, 390.0, 290.0)); + builder.pushClipRect(const Rect.fromLTRB(10.0, 10.0, 390.0, 290.0)); builder.addPlatformView(42, width: 400.0, height: 300.0); - builder.addPicture(Offset(0.0, 0.0), CreateGradientBox(Size(400.0, 300.0))); + builder.addPicture( + Offset.zero, createGradientBox(const Size(400.0, 300.0))); PlatformDispatcher.instance.views.first.render(builder.build()); }; PlatformDispatcher.instance.scheduleFrame(); } @pragma('vm:entry-point') +// ignore: non_constant_identifier_names void scene_builder_with_complex_clips() { PlatformDispatcher.instance.onBeginFrame = (Duration duration) { final SceneBuilder builder = SceneBuilder(); - builder.pushClipRect(Rect.fromLTRB(0.0, 0.0, 1024.0, 600.0)); + builder.pushClipRect(const Rect.fromLTRB(0.0, 0.0, 1024.0, 600.0)); builder.pushOffset(512.0, 0.0); - builder.pushClipRect(Rect.fromLTRB(0.0, 0.0, 512.0, 600.0)); + builder.pushClipRect(const Rect.fromLTRB(0.0, 0.0, 512.0, 600.0)); builder.pushOffset(-256.0, 0.0); - builder.pushClipRect(Rect.fromLTRB(0.0, 0.0, 1024.0, 600.0)); + builder.pushClipRect(const Rect.fromLTRB(0.0, 0.0, 1024.0, 600.0)); builder.addPlatformView(42, width: 1024.0, height: 600.0); builder.addPicture( - Offset(0.0, 0.0), CreateGradientBox(Size(1024.0, 600.0))); + Offset.zero, createGradientBox(const Size(1024.0, 600.0))); PlatformDispatcher.instance.views.first.render(builder.build()); }; PlatformDispatcher.instance.scheduleFrame(); @@ -1192,6 +1230,7 @@ void scene_builder_with_complex_clips() { external void sendObjectToNativeCode(dynamic object); @pragma('vm:entry-point') +// ignore: non_constant_identifier_names void objects_can_be_posted() { final ReceivePort port = ReceivePort(); port.listen((dynamic message) { @@ -1201,17 +1240,19 @@ void objects_can_be_posted() { } @pragma('vm:entry-point') +// ignore: non_constant_identifier_names void empty_scene_posts_zero_layers_to_compositor() { PlatformDispatcher.instance.onBeginFrame = (Duration duration) { final SceneBuilder builder = SceneBuilder(); // Should not render anything. - builder.pushClipRect(Rect.fromLTRB(0.0, 0.0, 300.0, 200.0)); + builder.pushClipRect(const Rect.fromLTRB(0.0, 0.0, 300.0, 200.0)); PlatformDispatcher.instance.views.first.render(builder.build()); }; PlatformDispatcher.instance.scheduleFrame(); } @pragma('vm:entry-point') +// ignore: non_constant_identifier_names void compositor_can_post_only_platform_views() { PlatformDispatcher.instance.onBeginFrame = (Duration duration) { final SceneBuilder builder = SceneBuilder(); @@ -1223,12 +1264,14 @@ void compositor_can_post_only_platform_views() { } @pragma('vm:entry-point') +// ignore: non_constant_identifier_names void render_targets_are_recycled() { int frameCount = 0; PlatformDispatcher.instance.onBeginFrame = (Duration duration) { final SceneBuilder builder = SceneBuilder(); for (int i = 0; i < 10; i++) { - builder.addPicture(Offset(0.0, 0.0), CreateGradientBox(Size(30.0, 20.0))); + builder.addPicture( + Offset.zero, createGradientBox(const Size(30.0, 20.0))); builder.addPlatformView(42 + i, width: 30.0, height: 20.0); } PlatformDispatcher.instance.views.first.render(builder.build()); @@ -1243,12 +1286,14 @@ void render_targets_are_recycled() { } @pragma('vm:entry-point') +// ignore: non_constant_identifier_names void render_targets_are_in_stable_order() { int frameCount = 0; PlatformDispatcher.instance.onBeginFrame = (Duration duration) { final SceneBuilder builder = SceneBuilder(); for (int i = 0; i < 10; i++) { - builder.addPicture(Offset(0.0, 0.0), CreateGradientBox(Size(30.0, 20.0))); + builder.addPicture( + Offset.zero, createGradientBox(const Size(30.0, 20.0))); builder.addPlatformView(42 + i, width: 30.0, height: 20.0); } PlatformDispatcher.instance.views.first.render(builder.build()); @@ -1265,11 +1310,13 @@ void render_targets_are_in_stable_order() { external void nativeArgumentsCallback(List args); @pragma('vm:entry-point') +// ignore: non_constant_identifier_names void custom_logger(List args) { print('hello world'); } @pragma('vm:entry-point') +// ignore: non_constant_identifier_names void dart_entrypoint_args(List args) { nativeArgumentsCallback(args); } @@ -1278,19 +1325,20 @@ void dart_entrypoint_args(List args) { external void snapshotsCallback(Image bigImage, Image smallImage); @pragma('vm:entry-point') +// ignore: non_constant_identifier_names Future snapshot_large_scene(int maxSize) async { // Set width to double the max size, which will result in height being half the max size after scaling. - double width = maxSize * 2.0, height = maxSize.toDouble(); + final width = maxSize * 2.0, height = maxSize.toDouble(); PictureRecorder recorder = PictureRecorder(); { final Canvas canvas = Canvas(recorder, Rect.fromLTWH(0, 0, width, height)); final Paint paint = Paint(); // Bottom left - paint.color = Color.fromARGB(255, 100, 255, 100); + paint.color = const Color.fromARGB(255, 100, 255, 100); canvas.drawRect(Rect.fromLTWH(0, height / 2, width / 2, height / 2), paint); // Top right - paint.color = Color.fromARGB(255, 100, 100, 255); + paint.color = const Color.fromARGB(255, 100, 100, 255); canvas.drawRect(Rect.fromLTWH(width / 2, 0, width / 2, height / 2), paint); } Picture picture = recorder.endRecording(); @@ -1298,30 +1346,36 @@ Future snapshot_large_scene(int maxSize) async { // The max size varies across hardware/drivers, so normalize the result to a smaller target size in // order to reliably test against an image fixture. - double smallWidth = 128, smallHeight = 64; + const smallWidth = 128.0; + const smallHeight = 64.0; recorder = PictureRecorder(); { - final Canvas canvas = - Canvas(recorder, Rect.fromLTWH(0, 0, smallWidth, smallHeight)); + final Canvas canvas = Canvas( + recorder, + const Rect.fromLTWH(0, 0, smallWidth, smallHeight), + ); canvas.scale(smallWidth / bigImage.width); canvas.drawImage(bigImage, Offset.zero, Paint()); } picture = recorder.endRecording(); - final Image smallImage = - await picture.toImage(smallWidth.toInt(), smallHeight.toInt()); + final Image smallImage = await picture.toImage( + smallWidth.toInt(), + smallHeight.toInt(), + ); snapshotsCallback(bigImage, smallImage); } @pragma('vm:entry-point') +// ignore: non_constant_identifier_names void invalid_backingstore() { PlatformDispatcher.instance.onBeginFrame = (Duration duration) { - final Color red = Color.fromARGB(127, 255, 0, 0); - final Size size = Size(50.0, 150.0); + const Color red = Color.fromARGB(127, 255, 0, 0); + const Size size = Size(50.0, 150.0); final SceneBuilder builder = SceneBuilder(); builder.pushOffset(0.0, 0.0); builder.addPicture( - Offset(10.0, 10.0), CreateColoredBox(red, size)); // red - flutter + const Offset(10.0, 10.0), createColoredBox(red, size)); // red - flutter builder.pop(); PlatformDispatcher.instance.views.first.render(builder.build()); }; @@ -1332,6 +1386,7 @@ void invalid_backingstore() { } @pragma('vm:entry-point') +// ignore: non_constant_identifier_names void can_schedule_frame() { PlatformDispatcher.instance.onBeginFrame = (Duration beginTime) { signalNativeCount(beginTime.inMicroseconds); @@ -1340,6 +1395,7 @@ void can_schedule_frame() { } @pragma('vm:entry-point') +// ignore: non_constant_identifier_names void add_view_schedules_frame() { PlatformDispatcher.instance.onBeginFrame = (Duration beginTime) { for (final FlutterView view in PlatformDispatcher.instance.views) { @@ -1357,7 +1413,7 @@ void drawSolidColor(Color c) { builder.pushOffset(0.0, 0.0); builder.addPicture( Offset.zero, - CreateColoredBox( + createColoredBox( c, PlatformDispatcher.instance.views.first.physicalSize)); builder.pop(); PlatformDispatcher.instance.views.first.render(builder.build()); @@ -1366,24 +1422,27 @@ void drawSolidColor(Color c) { } @pragma('vm:entry-point') +// ignore: non_constant_identifier_names void draw_solid_red() { drawSolidColor(const Color.fromARGB(255, 255, 0, 0)); } @pragma('vm:entry-point') +// ignore: non_constant_identifier_names void draw_solid_green() { drawSolidColor(const Color.fromARGB(255, 0, 255, 0)); } @pragma('vm:entry-point') +// ignore: non_constant_identifier_names void draw_solid_blue() { drawSolidColor(const Color.fromARGB(255, 0, 0, 255)); } @pragma('vm:entry-point') +// ignore: non_constant_identifier_names void pointer_data_packet() { - PlatformDispatcher.instance.onPointerDataPacket = - (PointerDataPacket packet) { + PlatformDispatcher.instance.onPointerDataPacket = (PointerDataPacket packet) { signalNativeCount(packet.data.length); for (final PointerData pointerData in packet.data) { @@ -1395,6 +1454,7 @@ void pointer_data_packet() { } @pragma('vm:entry-point') +// ignore: non_constant_identifier_names void pointer_data_packet_view_id() { PlatformDispatcher.instance.onPointerDataPacket = (PointerDataPacket packet) { assert(packet.data.length == 1); @@ -1431,6 +1491,7 @@ List _findDifferences(Map a, Map b) { } @pragma('vm:entry-point') +// ignore: non_constant_identifier_names void window_metrics_event_view_id() { Map sizes = _getAllViewSizes(); PlatformDispatcher.instance.onMetricsChanged = () { @@ -1444,10 +1505,11 @@ void window_metrics_event_view_id() { } @pragma('vm:entry-point') +// ignore: non_constant_identifier_names void window_metrics_event_all_view_ids() { PlatformDispatcher.instance.onMetricsChanged = () { final List viewIds = - PlatformDispatcher.instance.views.map((view) => view.viewId).toList(); + PlatformDispatcher.instance.views.map((view) => view.viewId).toList(); viewIds.sort(); @@ -1458,6 +1520,7 @@ void window_metrics_event_all_view_ids() { } @pragma('vm:entry-point') +// ignore: non_constant_identifier_names Future channel_listener_response() async { channelBuffers.setListener('test/listen', (ByteData? data, PlatformMessageResponseCallback callback) { @@ -1467,10 +1530,11 @@ Future channel_listener_response() async { } @pragma('vm:entry-point') +// ignore: non_constant_identifier_names void render_gradient_retained() { OffsetEngineLayer? offsetLayer; // Retain the offset layer. PlatformDispatcher.instance.onBeginFrame = (Duration duration) { - final Size size = Size(800.0, 600.0); + const Size size = Size(800.0, 600.0); final SceneBuilder builder = SceneBuilder(); @@ -1478,8 +1542,7 @@ void render_gradient_retained() { // display_list_layer will comparing the display_list // no need to retain the picture - builder.addPicture( - Offset(0.0, 0.0), CreateGradientBox(size)); // gradient - flutter + builder.addPicture(Offset.zero, createGradientBox(size)); builder.pop(); @@ -1489,16 +1552,17 @@ void render_gradient_retained() { } @pragma('vm:entry-point') +// ignore: non_constant_identifier_names void render_impeller_gl_test() { PlatformDispatcher.instance.onBeginFrame = (Duration duration) { final SceneBuilder builder = SceneBuilder(); builder.pushOffset(0.0, 0.0); final Paint paint = Paint(); - paint.color = Color.fromARGB(255, 0, 0, 255); + paint.color = const Color.fromARGB(255, 0, 0, 255); final PictureRecorder baseRecorder = PictureRecorder(); final Canvas canvas = Canvas(baseRecorder); - canvas.drawPaint(Paint()..color = Color.fromARGB(255, 255, 0, 0)); - canvas.drawRect(Rect.fromLTRB(20.0, 20.0, 200.0, 150.0), paint); + canvas.drawPaint(Paint()..color = const Color.fromARGB(255, 255, 0, 0)); + canvas.drawRect(const Rect.fromLTRB(20.0, 20.0, 200.0, 150.0), paint); builder.addPicture(Offset.zero, baseRecorder.endRecording()); builder.pop(); PlatformDispatcher.instance.views.first.render(builder.build());