diff --git a/engine/src/flutter/lib/web_ui/analysis_options.yaml b/engine/src/flutter/lib/web_ui/analysis_options.yaml index bf2a59f3ed..3e5e0e74ea 100644 --- a/engine/src/flutter/lib/web_ui/analysis_options.yaml +++ b/engine/src/flutter/lib/web_ui/analysis_options.yaml @@ -26,8 +26,6 @@ linter: prefer_conditional_assignment: false prefer_const_constructors: false prefer_const_constructors_in_immutables: false - prefer_const_declarations: false - prefer_const_literals_to_create_immutables: false prefer_foreach: false prefer_generic_function_type_aliases: false prefer_initializing_formals: false @@ -37,14 +35,6 @@ linter: recursive_getters: false slash_for_doc_comments: false sort_unnamed_constructors_first: false - test_types_in_equals: false - throw_in_finally: false - type_init_formals: false - unnecessary_getters_setters: false - use_rethrow_when_possible: false - valid_regexps: false - use_function_type_syntax_for_parameters: false - avoid_single_cascade_in_expression_statements: false flutter_style_todos: false # We have some legitimate use-cases for this (preserve tear-off identity) diff --git a/engine/src/flutter/lib/web_ui/dev/browser.dart b/engine/src/flutter/lib/web_ui/dev/browser.dart index 88c40997b0..412559787b 100644 --- a/engine/src/flutter/lib/web_ui/dev/browser.dart +++ b/engine/src/flutter/lib/web_ui/dev/browser.dart @@ -97,7 +97,7 @@ abstract class Browser { /// which asynchronously returns the browser process. Any errors in /// [startBrowser] (even those raised asynchronously after it returns) are /// piped to [onExit] and will cause the browser to be killed. - Browser(Future startBrowser()) { + Browser(Future Function() startBrowser) { // Don't return a Future here because there's no need for the caller to wait // for the process to actually start. They should just wait for the HTTP // request instead. diff --git a/engine/src/flutter/lib/web_ui/dev/build.dart b/engine/src/flutter/lib/web_ui/dev/build.dart index f406bc92c3..525f2f31fc 100644 --- a/engine/src/flutter/lib/web_ui/dev/build.dart +++ b/engine/src/flutter/lib/web_ui/dev/build.dart @@ -15,8 +15,7 @@ import 'watcher.dart'; class BuildCommand extends Command with ArgUtils { BuildCommand() { - argParser - ..addFlag( + argParser.addFlag( 'watch', defaultsTo: false, abbr: 'w', diff --git a/engine/src/flutter/lib/web_ui/dev/chrome.dart b/engine/src/flutter/lib/web_ui/dev/chrome.dart index acc6c22bc4..98b93f5a02 100644 --- a/engine/src/flutter/lib/web_ui/dev/chrome.dart +++ b/engine/src/flutter/lib/web_ui/dev/chrome.dart @@ -112,7 +112,7 @@ class Chrome extends Browser { }, remoteDebuggerCompleter.future); } - Chrome._(Future startBrowser(), this.remoteDebuggerUrl) + Chrome._(Future Function() startBrowser, this.remoteDebuggerUrl) : super(startBrowser); } @@ -157,8 +157,9 @@ Future _spawnChromiumProcess(String executable, List args, { St }) .firstWhere((String line) => line.startsWith('DevTools listening'), orElse: () { if (hitGlibcBug) { - final String message = 'Encountered glibc bug https://sourceware.org/bugzilla/show_bug.cgi?id=19329. ' - 'Will try launching browser again.'; + const String message = 'Encountered glibc bug ' + 'https://sourceware.org/bugzilla/show_bug.cgi?id=19329. ' + 'Will try launching browser again.'; print(message); return message; } diff --git a/engine/src/flutter/lib/web_ui/dev/chrome_installer.dart b/engine/src/flutter/lib/web_ui/dev/chrome_installer.dart index 2ffaa2bede..4015f49535 100644 --- a/engine/src/flutter/lib/web_ui/dev/chrome_installer.dart +++ b/engine/src/flutter/lib/web_ui/dev/chrome_installer.dart @@ -34,8 +34,7 @@ class ChromeArgParser extends BrowserArgParser { _pinnedChromeBuildNumber = PlatformBinding.instance.getChromeBuild(browserLock); - argParser - ..addOption( + argParser.addOption( 'chrome-version', defaultsTo: pinnedChromeBuildNumber, help: 'The Chrome version to use while running tests. If the requested ' @@ -234,8 +233,8 @@ class ChromeInstaller { ..createSync(recursive: true) ..writeAsBytesSync(data); } else { - io.Directory(path.join(versionDir.path, filename)) - ..create(recursive: true); + io.Directory(path.join(versionDir.path, filename)).create( + recursive: true); } } diff --git a/engine/src/flutter/lib/web_ui/dev/create_simulator.dart b/engine/src/flutter/lib/web_ui/dev/create_simulator.dart index b35b41ac2c..77e3e5e723 100644 --- a/engine/src/flutter/lib/web_ui/dev/create_simulator.dart +++ b/engine/src/flutter/lib/web_ui/dev/create_simulator.dart @@ -14,7 +14,7 @@ class CreateSimulatorCommand extends Command with ArgUtils { CreateSimulatorCommand() { IosSafariArgParser.instance.populateOptions(argParser); argParser - ..addOption( + .addOption( 'type', defaultsTo: _defaultType, help: 'Type of the mobile simulator. Currently the only iOS ' @@ -24,7 +24,7 @@ class CreateSimulatorCommand extends Command with ArgUtils { } /// Currently the only iOS Simulators are supported. - static final String _defaultType = 'iOS'; + static const String _defaultType = 'iOS'; @override String get name => 'create_simulator'; diff --git a/engine/src/flutter/lib/web_ui/dev/edge.dart b/engine/src/flutter/lib/web_ui/dev/edge.dart index 01f22d4455..2006a75a6a 100644 --- a/engine/src/flutter/lib/web_ui/dev/edge.dart +++ b/engine/src/flutter/lib/web_ui/dev/edge.dart @@ -72,5 +72,5 @@ class Edge extends Browser { }); } - Edge._(Future startBrowser()) : super(startBrowser); + Edge._(Future Function() startBrowser) : super(startBrowser); } diff --git a/engine/src/flutter/lib/web_ui/dev/edge_installation.dart b/engine/src/flutter/lib/web_ui/dev/edge_installation.dart index 3e81440e18..c38d1206b5 100644 --- a/engine/src/flutter/lib/web_ui/dev/edge_installation.dart +++ b/engine/src/flutter/lib/web_ui/dev/edge_installation.dart @@ -24,8 +24,7 @@ class EdgeArgParser extends BrowserArgParser { @override void populateOptions(ArgParser argParser) { - argParser - ..addOption( + argParser.addOption( 'edge-version', defaultsTo: 'system', help: 'The Edge version to use while running tests. The Edge ' diff --git a/engine/src/flutter/lib/web_ui/dev/firefox.dart b/engine/src/flutter/lib/web_ui/dev/firefox.dart index 00a90b9d79..3f0277ac45 100644 --- a/engine/src/flutter/lib/web_ui/dev/firefox.dart +++ b/engine/src/flutter/lib/web_ui/dev/firefox.dart @@ -63,7 +63,7 @@ class Firefox extends Browser { ); // Using a profile on opening will prevent popups related to profiles. - final String _profile = ''' + const String _profile = ''' user_pref("browser.shell.checkDefaultBrowser", false); user_pref("dom.disable_open_during_load", false); user_pref("dom.max_script_run_time", 0); @@ -111,6 +111,6 @@ user_pref("dom.max_script_run_time", 0); }, remoteDebuggerCompleter.future); } - Firefox._(Future startBrowser(), this.remoteDebuggerUrl) + Firefox._(Future Function() startBrowser, this.remoteDebuggerUrl) : super(startBrowser); } diff --git a/engine/src/flutter/lib/web_ui/dev/firefox_installer.dart b/engine/src/flutter/lib/web_ui/dev/firefox_installer.dart index 6bcd7bb9fc..3f44596313 100644 --- a/engine/src/flutter/lib/web_ui/dev/firefox_installer.dart +++ b/engine/src/flutter/lib/web_ui/dev/firefox_installer.dart @@ -28,8 +28,7 @@ class FirefoxArgParser extends BrowserArgParser { final YamlMap browserLock = BrowserLock.instance.configuration; final String firefoxVersion = browserLock['firefox']['version'] as String; - argParser - ..addOption( + argParser.addOption( 'firefox-version', defaultsTo: firefoxVersion, help: 'The Firefox version to use while running tests. If the requested ' diff --git a/engine/src/flutter/lib/web_ui/dev/safari_installation.dart b/engine/src/flutter/lib/web_ui/dev/safari_installation.dart index b54aef5bf3..d8a3dc13a0 100644 --- a/engine/src/flutter/lib/web_ui/dev/safari_installation.dart +++ b/engine/src/flutter/lib/web_ui/dev/safari_installation.dart @@ -22,8 +22,7 @@ class SafariArgParser extends BrowserArgParser { @override void populateOptions(ArgParser argParser) { - argParser - ..addOption( + argParser.addOption( 'safari-version', defaultsTo: 'system', help: 'The Safari version to use while running tests. The Safari ' diff --git a/engine/src/flutter/lib/web_ui/dev/safari_ios.dart b/engine/src/flutter/lib/web_ui/dev/safari_ios.dart index 60c6e7085e..905fe6ef9f 100644 --- a/engine/src/flutter/lib/web_ui/dev/safari_ios.dart +++ b/engine/src/flutter/lib/web_ui/dev/safari_ios.dart @@ -72,7 +72,7 @@ class SafariIos extends Browser { }); } - SafariIos._(Future startBrowser()) : super(startBrowser); + SafariIos._(Future Function() startBrowser) : super(startBrowser); } /// [ScreenshotManager] implementation for Safari. diff --git a/engine/src/flutter/lib/web_ui/dev/safari_macos.dart b/engine/src/flutter/lib/web_ui/dev/safari_macos.dart index e393a0286e..5bfc70ef8c 100644 --- a/engine/src/flutter/lib/web_ui/dev/safari_macos.dart +++ b/engine/src/flutter/lib/web_ui/dev/safari_macos.dart @@ -89,5 +89,5 @@ class SafariMacOs extends Browser { }); } - SafariMacOs._(Future startBrowser()) : super(startBrowser); + SafariMacOs._(Future Function() startBrowser) : super(startBrowser); } diff --git a/engine/src/flutter/lib/web_ui/dev/utils.dart b/engine/src/flutter/lib/web_ui/dev/utils.dart index 57d3f12230..ec9e854177 100644 --- a/engine/src/flutter/lib/web_ui/dev/utils.dart +++ b/engine/src/flutter/lib/web_ui/dev/utils.dart @@ -337,8 +337,7 @@ class GeneralTestsArgumentParser { bool verbose = false; void populateOptions(ArgParser argParser) { - argParser - ..addFlag( + argParser.addFlag( 'verbose', defaultsTo: false, help: 'Flag to indicate extra logs should also be printed.', diff --git a/engine/src/flutter/lib/web_ui/lib/src/engine/canvaskit/initialization.dart b/engine/src/flutter/lib/web_ui/lib/src/engine/canvaskit/initialization.dart index 107fc15f05..ef8c905a25 100644 --- a/engine/src/flutter/lib/web_ui/lib/src/engine/canvaskit/initialization.dart +++ b/engine/src/flutter/lib/web_ui/lib/src/engine/canvaskit/initialization.dart @@ -88,9 +88,9 @@ const String canvasKitBaseUrl = String.fromEnvironment( 'FLUTTER_WEB_CANVASKIT_URL', defaultValue: 'https://unpkg.com/canvaskit-wasm@0.28.1/bin/', ); -final String canvasKitBuildUrl = +const String canvasKitBuildUrl = canvasKitBaseUrl + (kProfileMode ? 'profiling/' : ''); -final String canvasKitJavaScriptBindingsUrl = +const String canvasKitJavaScriptBindingsUrl = canvasKitBuildUrl + 'canvaskit.js'; String canvasKitWasmModuleUrl(String file) => _currentCanvasKitBase! + file; diff --git a/engine/src/flutter/lib/web_ui/lib/src/engine/canvaskit/surface.dart b/engine/src/flutter/lib/web_ui/lib/src/engine/canvaskit/surface.dart index f6143eae66..c77173c594 100644 --- a/engine/src/flutter/lib/web_ui/lib/src/engine/canvaskit/surface.dart +++ b/engine/src/flutter/lib/web_ui/lib/src/engine/canvaskit/surface.dart @@ -219,7 +219,7 @@ class Surface { final int surfaceHeight = _currentSurfaceSize!.height.ceil(); final double offset = (_pixelHeight - surfaceHeight) / window.devicePixelRatio; - htmlCanvas!.style..transform = 'translate(0, -${offset}px)'; + htmlCanvas!.style.transform = 'translate(0, -${offset}px)'; } void _contextRestoredListener(html.Event event) { diff --git a/engine/src/flutter/lib/web_ui/lib/src/engine/frame_reference.dart b/engine/src/flutter/lib/web_ui/lib/src/engine/frame_reference.dart index 05d5fa8bfe..c711b18100 100644 --- a/engine/src/flutter/lib/web_ui/lib/src/engine/frame_reference.dart +++ b/engine/src/flutter/lib/web_ui/lib/src/engine/frame_reference.dart @@ -67,7 +67,7 @@ class CrossFrameCache { void _addToCache(String key, _CrossFrameCacheItem item) { _cache ??= >>{}; - (_cache![key] ??= <_CrossFrameCacheItem>[])..add(item); + (_cache![key] ??= <_CrossFrameCacheItem>[]).add(item); } /// Given a key, consumes an item that has been cached in a prior frame. diff --git a/engine/src/flutter/lib/web_ui/lib/src/engine/html/path/conic.dart b/engine/src/flutter/lib/web_ui/lib/src/engine/html/path/conic.dart index 9e1c91ab3a..f617f762a4 100644 --- a/engine/src/flutter/lib/web_ui/lib/src/engine/html/path/conic.dart +++ b/engine/src/flutter/lib/web_ui/lib/src/engine/html/path/conic.dart @@ -216,13 +216,13 @@ class Conic { // Map conic to 3D. final double tx0 = p0x; final double ty0 = p0y; - final double tz0 = 1; + const double tz0 = 1; final double tx1 = p1x * fW; final double ty1 = p1y * fW; final double tz1 = fW; final double tx2 = p2x; final double ty2 = p2y; - final double tz2 = 1; + const double tz2 = 1; // Now interpolate each dimension. final double dx0 = tx0 + (tx1 - tx0) * t; final double dx2 = tx1 + (tx2 - tx1) * t; @@ -335,7 +335,7 @@ class Conic { static double evalDenominator(double w, double t) { final double B = 2 * (w - 1); - final double C = 1; + const double C = 1; final double A = -B; return polyEval(A, B, C, t); } diff --git a/engine/src/flutter/lib/web_ui/lib/src/engine/html/path/cubic.dart b/engine/src/flutter/lib/web_ui/lib/src/engine/html/path/cubic.dart index bd5d99e57e..f5835ba2d3 100644 --- a/engine/src/flutter/lib/web_ui/lib/src/engine/html/path/cubic.dart +++ b/engine/src/flutter/lib/web_ui/lib/src/engine/html/path/cubic.dart @@ -163,7 +163,7 @@ double? chopMonoAtY(Float32List _buffer, int bufferStartPos, double y) { } // Bisection / linear convergance. - final double tolerance = 1.0 / 65536; + const double tolerance = 1.0 / 65536; do { final double tMid = (tPos + tNeg) / 2.0; final double y01 = ycrv0 + (ycrv1 - ycrv0) * tMid; diff --git a/engine/src/flutter/lib/web_ui/lib/src/engine/html/path/path.dart b/engine/src/flutter/lib/web_ui/lib/src/engine/html/path/path.dart index 026c91fdab..fcc0f876e4 100644 --- a/engine/src/flutter/lib/web_ui/lib/src/engine/html/path/path.dart +++ b/engine/src/flutter/lib/web_ui/lib/src/engine/html/path/path.dart @@ -902,7 +902,7 @@ class SurfacePath implements ui.Path { assert(direction != SPathDirection.kUnknown); final bool isOval = _hasOnlyMoveTos(); - final double weight = SPath.scalarRoot2Over2; + const double weight = SPath.scalarRoot2Over2; final double left = oval.left; final double right = oval.right; final double centerX = (left + right) / 2.0; @@ -1018,7 +1018,7 @@ class SurfacePath implements ui.Path { // degenerate(oval) => line points are collapsing. _addOval(bounds, direction, startIndex ~/ 2); } else { - final double weight = SPath.scalarRoot2Over2; + const double weight = SPath.scalarRoot2Over2; final double left = bounds.left; final double right = bounds.right; final double top = bounds.top; diff --git a/engine/src/flutter/lib/web_ui/lib/src/engine/html/path/path_ref.dart b/engine/src/flutter/lib/web_ui/lib/src/engine/html/path/path_ref.dart index f345ce2a82..e1f92415d1 100644 --- a/engine/src/flutter/lib/web_ui/lib/src/engine/html/path/path_ref.dart +++ b/engine/src/flutter/lib/web_ui/lib/src/engine/html/path/path_ref.dart @@ -309,7 +309,7 @@ class PathRef { if (other.runtimeType != runtimeType) { return false; } - return equals(other as PathRef); + return other is PathRef && equals(other); } @override @@ -876,7 +876,7 @@ class PathRef { for (int i = 0; i < len; i += 2) { final double pointX = fPoints[i]; final double pointY = fPoints[i + 1]; - final double tolerance = 0.0001; + const double tolerance = 0.0001; final bool pointIsFinite = pointX.isFinite && pointY.isFinite; if (pointIsFinite && (pointX + tolerance < boundsLeft || diff --git a/engine/src/flutter/lib/web_ui/lib/src/engine/html/path/path_utils.dart b/engine/src/flutter/lib/web_ui/lib/src/engine/html/path/path_utils.dart index 302e19a058..fde50c5e41 100644 --- a/engine/src/flutter/lib/web_ui/lib/src/engine/html/path/path_utils.dart +++ b/engine/src/flutter/lib/web_ui/lib/src/engine/html/path/path_utils.dart @@ -314,7 +314,7 @@ class Convexicator { math.max(curVecX, math.max(curVecY, math.max(lastX, lastY))), -smallest); if (SPath.nearlyEqual(largest, largest + cross)) { - final double nearlyZeroSquared = + const double nearlyZeroSquared = SPath.scalarNearlyZero * SPath.scalarNearlyZero; if (SPath.nearlyEqual(lengthSquared(lastX, lastY), nearlyZeroSquared) || SPath.nearlyEqual(lengthSquared(curVecX, curVecY), nearlyZeroSquared)) { diff --git a/engine/src/flutter/lib/web_ui/lib/src/engine/html/shader_mask.dart b/engine/src/flutter/lib/web_ui/lib/src/engine/html/shader_mask.dart index 037abdee27..c9192b9a12 100644 --- a/engine/src/flutter/lib/web_ui/lib/src/engine/html/shader_mask.dart +++ b/engine/src/flutter/lib/web_ui/lib/src/engine/html/shader_mask.dart @@ -76,7 +76,7 @@ class PersistedShaderMask extends PersistedContainerSurface html.Element createElement() { final html.Element element = defaultCreateElement('flt-shader-mask'); final html.Element container = html.Element.tag('flt-mask-interior'); - container.style..position = 'absolute'; + container.style.position = 'absolute'; _childContainer = container; element.append(_childContainer!); return element; diff --git a/engine/src/flutter/lib/web_ui/lib/src/engine/html/surface.dart b/engine/src/flutter/lib/web_ui/lib/src/engine/html/surface.dart index fbd65de848..ca2104adf3 100644 --- a/engine/src/flutter/lib/web_ui/lib/src/engine/html/surface.dart +++ b/engine/src/flutter/lib/web_ui/lib/src/engine/html/surface.dart @@ -524,11 +524,7 @@ abstract class PersistedSurface implements ui.EngineLayer { /// transforms as well as this layer's transform (if any). /// /// The value is update by [recomputeTransformAndClip]. - Matrix4? get transform => _transform; - set transform(Matrix4? value) { - _transform = value; - } - Matrix4? _transform; + Matrix4? transform; /// The intersection at this surface level. /// @@ -555,7 +551,7 @@ abstract class PersistedSurface implements ui.EngineLayer { /// /// This method is called by the [preroll] method. void recomputeTransformAndClip() { - _transform = parent!._transform; + transform = parent!.transform; localClipBounds = null; projectedClip = null; } @@ -661,7 +657,7 @@ abstract class PersistedContainerSurface extends PersistedSurface { @override void recomputeTransformAndClip() { - _transform = parent!._transform; + transform = parent!.transform; localClipBounds = null; projectedClip = null; } diff --git a/engine/src/flutter/lib/web_ui/lib/src/engine/platform_dispatcher.dart b/engine/src/flutter/lib/web_ui/lib/src/engine/platform_dispatcher.dart index 22120eee86..65dd925f82 100644 --- a/engine/src/flutter/lib/web_ui/lib/src/engine/platform_dispatcher.dart +++ b/engine/src/flutter/lib/web_ui/lib/src/engine/platform_dispatcher.dart @@ -1012,7 +1012,7 @@ bool _handleWebTestEnd2EndMessage(MethodCodec codec, ByteData? data) { } /// Invokes [callback] inside the given [zone]. -void invoke(void callback()?, Zone? zone) { +void invoke(void Function()? callback, Zone? zone) { if (callback == null) { return; } @@ -1027,7 +1027,7 @@ void invoke(void callback()?, Zone? zone) { } /// Invokes [callback] inside the given [zone] passing it [arg]. -void invoke1(void callback(A a)?, Zone? zone, A arg) { +void invoke1(void Function(A a)? callback, Zone? zone, A arg) { if (callback == null) { return; } diff --git a/engine/src/flutter/lib/web_ui/lib/src/engine/text/measurement.dart b/engine/src/flutter/lib/web_ui/lib/src/engine/text/measurement.dart index 7aec3ff71e..d6221d907e 100644 --- a/engine/src/flutter/lib/web_ui/lib/src/engine/text/measurement.dart +++ b/engine/src/flutter/lib/web_ui/lib/src/engine/text/measurement.dart @@ -646,7 +646,7 @@ class CanvasTextMeasurementService extends TextMeasurementService { maxIntrinsicWidth: maxIntrinsicCalculator.value, width: constraints.width, lines: linesCalculator.lines, - placeholderBoxes: [], + placeholderBoxes: const [], textAlign: paragraph.textAlign, textDirection: paragraph.textDirection, ); diff --git a/engine/src/flutter/lib/web_ui/test/canvas_test.dart b/engine/src/flutter/lib/web_ui/test/canvas_test.dart index 6cdfb3b641..9e87bd100d 100644 --- a/engine/src/flutter/lib/web_ui/test/canvas_test.dart +++ b/engine/src/flutter/lib/web_ui/test/canvas_test.dart @@ -38,7 +38,7 @@ void testMain() { } testCanvas('draws laid out paragraph', (EngineCanvas canvas) { - final ui.Rect screenRect = const ui.Rect.fromLTWH(0, 0, 100, 100); + const ui.Rect screenRect = ui.Rect.fromLTWH(0, 0, 100, 100); final RecordingCanvas recordingCanvas = RecordingCanvas(screenRect); final ui.ParagraphBuilder builder = ui.ParagraphBuilder(ui.ParagraphStyle()); @@ -63,7 +63,7 @@ void testMain() { testCanvas('ignores paragraphs that were not laid out', (EngineCanvas canvas) { - final ui.Rect screenRect = const ui.Rect.fromLTWH(0, 0, 100, 100); + const ui.Rect screenRect = ui.Rect.fromLTWH(0, 0, 100, 100); final RecordingCanvas recordingCanvas = RecordingCanvas(screenRect); final ui.ParagraphBuilder builder = ui.ParagraphBuilder(ui.ParagraphStyle()); diff --git a/engine/src/flutter/lib/web_ui/test/engine/path_metrics_test.dart b/engine/src/flutter/lib/web_ui/test/engine/path_metrics_test.dart index c1e8fc3fa7..6522b6fb66 100644 --- a/engine/src/flutter/lib/web_ui/test/engine/path_metrics_test.dart +++ b/engine/src/flutter/lib/web_ui/test/engine/path_metrics_test.dart @@ -117,15 +117,15 @@ void testMain() { const double cy = 100; const double startAngle = 0.0; const double endAngle = 90.0; - final double startRad = startAngle * math.pi / 180.0; - final double endRad = endAngle * math.pi / 180.0; + const double startRad = startAngle * math.pi / 180.0; + const double endRad = endAngle * math.pi / 180.0; final double startX = cx + (rx * math.cos(startRad)); final double startY = cy + (ry * math.sin(startRad)); final double endX = cx + (rx * math.cos(endRad)); final double endY = cy + (ry * math.sin(endRad)); - final bool clockwise = endAngle > startAngle; + const bool clockwise = endAngle > startAngle; final bool largeArc = (endAngle - startAngle).abs() > 180.0; final Path path = Path() ..moveTo(startX, startY) @@ -146,15 +146,15 @@ void testMain() { const double cy = 100; const double startAngle = 0.0; const double endAngle = 180.0; - final double startRad = startAngle * math.pi / 180.0; - final double endRad = endAngle * math.pi / 180.0; + const double startRad = startAngle * math.pi / 180.0; + const double endRad = endAngle * math.pi / 180.0; final double startX = cx + (rx * math.cos(startRad)); final double startY = cy + (ry * math.sin(startRad)); final double endX = cx + (rx * math.cos(endRad)); final double endY = cy + (ry * math.sin(endRad)); - final bool clockwise = endAngle > startAngle; + const bool clockwise = endAngle > startAngle; final bool largeArc = (endAngle - startAngle).abs() > 180.0; final Path path = Path() ..moveTo(startX, startY) @@ -175,15 +175,15 @@ void testMain() { const double cy = 100; const double startAngle = 0.0; const double endAngle = 270.0; - final double startRad = startAngle * math.pi / 180.0; - final double endRad = endAngle * math.pi / 180.0; + const double startRad = startAngle * math.pi / 180.0; + const double endRad = endAngle * math.pi / 180.0; final double startX = cx + (rx * math.cos(startRad)); final double startY = cy + (ry * math.sin(startRad)); final double endX = cx + (rx * math.cos(endRad)); final double endY = cy + (ry * math.sin(endRad)); - final bool clockwise = endAngle > startAngle; + const bool clockwise = endAngle > startAngle; final bool largeArc = (endAngle - startAngle).abs() > 180.0; final Path path = Path() ..moveTo(startX, startY) @@ -204,15 +204,15 @@ void testMain() { const double cy = 100; const double startAngle = 0.0; const double endAngle = 270.0; - final double startRad = startAngle * math.pi / 180.0; - final double endRad = endAngle * math.pi / 180.0; + const double startRad = startAngle * math.pi / 180.0; + const double endRad = endAngle * math.pi / 180.0; final double startX = cx + (rx * math.cos(startRad)); final double startY = cy + (ry * math.sin(startRad)); final double endX = cx + (rx * math.cos(endRad)); final double endY = cy + (ry * math.sin(endRad)); - final bool clockwise = endAngle > startAngle; + const bool clockwise = endAngle > startAngle; final bool largeArc = (endAngle - startAngle).abs() > 180.0; final Path path = Path() ..moveTo(startX, startY) diff --git a/engine/src/flutter/lib/web_ui/test/engine/platform_views/content_manager_test.dart b/engine/src/flutter/lib/web_ui/test/engine/platform_views/content_manager_test.dart index 8bc00aeede..2025e5a6ac 100644 --- a/engine/src/flutter/lib/web_ui/test/engine/platform_views/content_manager_test.dart +++ b/engine/src/flutter/lib/web_ui/test/engine/platform_views/content_manager_test.dart @@ -16,8 +16,8 @@ void main() { void testMain() { group('PlatformViewManager', () { - final String viewType = 'forTest'; - final int viewId = 6; + const String viewType = 'forTest'; + const int viewId = 6; late PlatformViewManager contentManager; @@ -78,8 +78,8 @@ void testMain() { }); group('renderContent', () { - final String unregisteredViewType = 'unregisteredForTest'; - final String anotherViewType = 'anotherViewType'; + const String unregisteredViewType = 'unregisteredForTest'; + const String anotherViewType = 'anotherViewType'; setUp(() { contentManager.registerFactory(viewType, (int id) { diff --git a/engine/src/flutter/lib/web_ui/test/engine/platform_views/message_handler_test.dart b/engine/src/flutter/lib/web_ui/test/engine/platform_views/message_handler_test.dart index 819026b14a..3e78471b9b 100644 --- a/engine/src/flutter/lib/web_ui/test/engine/platform_views/message_handler_test.dart +++ b/engine/src/flutter/lib/web_ui/test/engine/platform_views/message_handler_test.dart @@ -19,8 +19,8 @@ final MethodCodec codec = StandardMethodCodec(); void testMain() { group('PlatformViewMessageHandler', () { group('handlePlatformViewCall', () { - final String viewType = 'forTest'; - final int viewId = 6; + const String viewType = 'forTest'; + const int viewId = 6; late PlatformViewManager contentManager; late Completer completer; late Completer contentCompleter; diff --git a/engine/src/flutter/lib/web_ui/test/engine/platform_views/slots_test.dart b/engine/src/flutter/lib/web_ui/test/engine/platform_views/slots_test.dart index 644718f238..f799e063c3 100644 --- a/engine/src/flutter/lib/web_ui/test/engine/platform_views/slots_test.dart +++ b/engine/src/flutter/lib/web_ui/test/engine/platform_views/slots_test.dart @@ -14,7 +14,7 @@ void main() { void testMain() { group('PlatformViewManager', () { - final int viewId = 6; + const int viewId = 6; group('createPlatformViewSlot', () { test( diff --git a/engine/src/flutter/lib/web_ui/test/engine/recording_canvas_test.dart b/engine/src/flutter/lib/web_ui/test/engine/recording_canvas_test.dart index 08f023256c..1cf2351f9b 100644 --- a/engine/src/flutter/lib/web_ui/test/engine/recording_canvas_test.dart +++ b/engine/src/flutter/lib/web_ui/test/engine/recording_canvas_test.dart @@ -16,7 +16,7 @@ void main() { void testMain() { late RecordingCanvas underTest; late MockEngineCanvas mockCanvas; - final Rect screenRect = Rect.largest; + const Rect screenRect = Rect.largest; setUp(() { underTest = RecordingCanvas(screenRect); diff --git a/engine/src/flutter/lib/web_ui/test/engine/surface/scene_builder_test.dart b/engine/src/flutter/lib/web_ui/test/engine/surface/scene_builder_test.dart index 2caf3b155e..b6defe96b7 100644 --- a/engine/src/flutter/lib/web_ui/test/engine/surface/scene_builder_test.dart +++ b/engine/src/flutter/lib/web_ui/test/engine/surface/scene_builder_test.dart @@ -760,7 +760,7 @@ class MockPersistedPicture extends PersistedPicture { final EnginePictureRecorder recorder = EnginePictureRecorder(); // Use the largest cull rect so that layer clips are effective. The tests // rely on this. - recorder.beginRecording(ui.Rect.largest)..drawPaint(SurfacePaint()); + recorder.beginRecording(ui.Rect.largest).drawPaint(SurfacePaint()); return MockPersistedPicture._(recorder.endRecording()); } diff --git a/engine/src/flutter/lib/web_ui/test/engine/surface/shaders/shader_builder_test.dart b/engine/src/flutter/lib/web_ui/test/engine/surface/shaders/shader_builder_test.dart index 9960998841..1629165ed1 100644 --- a/engine/src/flutter/lib/web_ui/test/engine/surface/shaders/shader_builder_test.dart +++ b/engine/src/flutter/lib/web_ui/test/engine/surface/shaders/shader_builder_test.dart @@ -12,12 +12,12 @@ void main() { } void testMain() { - final String mat2Sample = 'mat2(1.1, 2.1, 1.2, 2.2)'; - final String mat3Sample = 'mat3(1.1, 2.1, 3.1, // first column (not row!)\n' + const String mat2Sample = 'mat2(1.1, 2.1, 1.2, 2.2)'; + const String mat3Sample = 'mat3(1.1, 2.1, 3.1, // first column (not row!)\n' '1.2, 2.2, 3.2, // second column\n' '1.3, 2.3, 3.3 // third column\n' ')'; - final String mat4Sample = 'mat3(1.1, 2.1, 3.1, 4.1,\n' + const String mat4Sample = 'mat3(1.1, 2.1, 3.1, 4.1,\n' '1.2, 2.2, 3.2, 4.2,\n' '1.3, 2.3, 3.3, 4.3,\n' '1.4, 2.4, 3.4, 4.4,\n' diff --git a/engine/src/flutter/lib/web_ui/test/engine/ulps_test.dart b/engine/src/flutter/lib/web_ui/test/engine/ulps_test.dart index ab842425c8..ff70822739 100644 --- a/engine/src/flutter/lib/web_ui/test/engine/ulps_test.dart +++ b/engine/src/flutter/lib/web_ui/test/engine/ulps_test.dart @@ -54,7 +54,7 @@ void testMain() { test('Should compare equality based on ulps', () { // If number of floats between a=1.1 and b are below 16, equals should // return true. - final double a = 1.1; + const double a = 1.1; final int aBits = floatAs2sCompliment(a); double b = twosComplimentAsFloat(aBits + 1); expect(almostEqualUlps(a, b), isTrue); diff --git a/engine/src/flutter/lib/web_ui/test/engine/window_test.dart b/engine/src/flutter/lib/web_ui/test/engine/window_test.dart index e21d69d902..37105c4091 100644 --- a/engine/src/flutter/lib/web_ui/test/engine/window_test.dart +++ b/engine/src/flutter/lib/web_ui/test/engine/window_test.dart @@ -306,7 +306,7 @@ void testMain() { final Completer completer = Completer(); final ByteData inputData = JSONMethodCodec().encodeMethodCall(MethodCall( 'SystemChrome.setPreferredOrientations', - []))!; + const []))!; window.sendPlatformMessage( 'flutter/platform', diff --git a/engine/src/flutter/lib/web_ui/test/html/canvas_clip_path_golden_test.dart b/engine/src/flutter/lib/web_ui/test/html/canvas_clip_path_golden_test.dart index 6278c9d23d..a2e5074ea3 100644 --- a/engine/src/flutter/lib/web_ui/test/html/canvas_clip_path_golden_test.dart +++ b/engine/src/flutter/lib/web_ui/test/html/canvas_clip_path_golden_test.dart @@ -52,8 +52,8 @@ Future testMain() async { final engine.RecordingCanvas rc = engine.RecordingCanvas(const Rect.fromLTRB(0, 0, 500, 500)); rc.save(); - final double testWidth = 200; - final double testHeight = 150; + const double testWidth = 200; + const double testHeight = 150; final Path path = Path(); path.addOval(Rect.fromLTWH(100, 30, testWidth, testHeight)); rc.clipPath(path); @@ -77,8 +77,8 @@ Future testMain() async { final engine.RecordingCanvas rc = engine.RecordingCanvas(const Rect.fromLTRB(0, 0, 500, 500)); rc.save(); - final double testWidth = 200; - final double testHeight = 150; + const double testWidth = 200; + const double testHeight = 150; final Path paintPath = Path(); paintPath.addRect(Rect.fromLTWH(-50, 0, testWidth, testHeight)); @@ -105,8 +105,8 @@ Future testMain() async { final engine.RecordingCanvas rc = engine.RecordingCanvas(const Rect.fromLTRB(0, 0, 500, 500)); rc.save(); - final double testWidth = 200; - final double testHeight = 150; + const double testWidth = 200; + const double testHeight = 150; final Path paintPath = Path(); paintPath.addRect(Rect.fromLTWH(-50, 0, testWidth, testHeight)); diff --git a/engine/src/flutter/lib/web_ui/test/html/clip_op_golden_test.dart b/engine/src/flutter/lib/web_ui/test/html/clip_op_golden_test.dart index 7851f3d96f..791b07fae3 100644 --- a/engine/src/flutter/lib/web_ui/test/html/clip_op_golden_test.dart +++ b/engine/src/flutter/lib/web_ui/test/html/clip_op_golden_test.dart @@ -19,7 +19,7 @@ Future testMain() async { /// Regression test for https://github.com/flutter/flutter/issues/64734. test('Clips using difference', () async { - final Rect region = const Rect.fromLTRB(0, 0, 400, 300); + const Rect region = Rect.fromLTRB(0, 0, 400, 300); final RecordingCanvas canvas = RecordingCanvas(region); final Rect titleRect = Rect.fromLTWH(20, 0, 50, 20); final SurfacePaint paint = SurfacePaint() @@ -34,7 +34,7 @@ Future testMain() async { } finally { canvas.restore(); } - canvas..drawRect(titleRect, paint); + canvas.drawRect(titleRect, paint); await canvasScreenshot(canvas, 'clip_op_difference', region: const Rect.fromLTRB(0, 0, 420, 360)); }); diff --git a/engine/src/flutter/lib/web_ui/test/html/compositing/compositing_golden_test.dart b/engine/src/flutter/lib/web_ui/test/html/compositing/compositing_golden_test.dart index 9ade7d17fc..3ba16cfab9 100644 --- a/engine/src/flutter/lib/web_ui/test/html/compositing/compositing_golden_test.dart +++ b/engine/src/flutter/lib/web_ui/test/html/compositing/compositing_golden_test.dart @@ -666,7 +666,7 @@ void _testCullRectComputation() { test('pushClipPath', () async { final SurfaceSceneBuilder builder = SurfaceSceneBuilder(); final ui.Path path = ui.Path(); - path..addRect(const ui.Rect.fromLTRB(10, 10, 60, 60)); + path.addRect(const ui.Rect.fromLTRB(10, 10, 60, 60)); builder.pushClipPath( path, ); diff --git a/engine/src/flutter/lib/web_ui/test/html/drawing/canvas_draw_image_golden_test.dart b/engine/src/flutter/lib/web_ui/test/html/drawing/canvas_draw_image_golden_test.dart index 3bf3009718..00601c04c0 100644 --- a/engine/src/flutter/lib/web_ui/test/html/drawing/canvas_draw_image_golden_test.dart +++ b/engine/src/flutter/lib/web_ui/test/html/drawing/canvas_draw_image_golden_test.dart @@ -349,7 +349,7 @@ Future testMain() async { // Creates a picture test('Paints nine slice image', () async { - final Rect region = const Rect.fromLTWH(0, 0, 500, 500); + const Rect region = Rect.fromLTWH(0, 0, 500, 500); final EnginePictureRecorder recorder = EnginePictureRecorder(); final Canvas canvas = Canvas(recorder, region); final Image testImage = createNineSliceImage(); @@ -379,7 +379,7 @@ Future testMain() async { // Tests for correct behavior when using drawImageNine with a destination // size that is too small to render the center portion of the original image. test('Paints nine slice image', () async { - final Rect region = const Rect.fromLTWH(0, 0, 100, 100); + const Rect region = Rect.fromLTWH(0, 0, 100, 100); final EnginePictureRecorder recorder = EnginePictureRecorder(); final Canvas canvas = Canvas(recorder, region); final Image testImage = createNineSliceImage(); @@ -414,7 +414,7 @@ Future testMain() async { // the image we did not apply `transform-origin: 0 0 0` to the clipping // element which resulted in an undesirable offset. test('Paints clipped and transformed image', () async { - final Rect region = const Rect.fromLTRB(0, 0, 60, 70); + const Rect region = Rect.fromLTRB(0, 0, 60, 70); final RecordingCanvas canvas = RecordingCanvas(region); canvas.translate(10, 10); canvas.transform(Matrix4.rotationZ(0.4).storage); @@ -431,7 +431,7 @@ Future testMain() async { /// Regression test for https://github.com/flutter/flutter/issues/61245 test('Should render image with perspective', () async { - final Rect region = const Rect.fromLTRB(0, 0, 200, 200); + const Rect region = Rect.fromLTRB(0, 0, 200, 200); final RecordingCanvas canvas = RecordingCanvas(region); canvas.translate(10, 10); canvas.drawImage(createTestImage(), Offset(0, 0), SurfacePaint()); @@ -448,7 +448,7 @@ Future testMain() async { /// Regression test for https://github.com/flutter/flutter/issues/61245 test('Should render image with perspective inside clip area', () async { - final Rect region = const Rect.fromLTRB(0, 0, 200, 200); + const Rect region = Rect.fromLTRB(0, 0, 200, 200); final RecordingCanvas canvas = RecordingCanvas(region); canvas.drawRect(region, SurfacePaint()..color = Color(0xFFE0E0E0)); canvas.translate(10, 10); @@ -468,7 +468,7 @@ Future testMain() async { }); test('Should render rect with perspective transform', () async { - final Rect region = const Rect.fromLTRB(0, 0, 400, 400); + const Rect region = Rect.fromLTRB(0, 0, 400, 400); final RecordingCanvas canvas = RecordingCanvas(region); canvas.drawRect(region, SurfacePaint()..color = Color(0xFFE0E0E0)); canvas.translate(20, 20); @@ -492,7 +492,7 @@ Future testMain() async { }); test('Should render color and ovals with perspective transform', () async { - final Rect region = const Rect.fromLTRB(0, 0, 400, 400); + const Rect region = Rect.fromLTRB(0, 0, 400, 400); final RecordingCanvas canvas = RecordingCanvas(region); canvas.drawRect(region, SurfacePaint()..color = Color(0xFFFF0000)); canvas.drawColor(Color(0xFFE0E0E0), BlendMode.src); @@ -517,7 +517,7 @@ Future testMain() async { }); test('Should render path with perspective transform', () async { - final Rect region = const Rect.fromLTRB(0, 0, 400, 400); + const Rect region = Rect.fromLTRB(0, 0, 400, 400); final RecordingCanvas canvas = RecordingCanvas(region); canvas.drawRect(region, SurfacePaint()..color = Color(0xFFFF0000)); canvas.drawColor(Color(0xFFE0E0E0), BlendMode.src); @@ -549,7 +549,7 @@ Future testMain() async { }); test('Should render path with perspective transform', () async { - final Rect region = const Rect.fromLTRB(0, 0, 400, 400); + const Rect region = Rect.fromLTRB(0, 0, 400, 400); final RecordingCanvas canvas = RecordingCanvas(region); canvas.drawRect(region, SurfacePaint()..color = Color(0xFFFF0000)); canvas.drawColor(Color(0xFFE0E0E0), BlendMode.src); diff --git a/engine/src/flutter/lib/web_ui/test/html/paragraph/general_golden_test.dart b/engine/src/flutter/lib/web_ui/test/html/paragraph/general_golden_test.dart index 49b4198571..c51d841285 100644 --- a/engine/src/flutter/lib/web_ui/test/html/paragraph/general_golden_test.dart +++ b/engine/src/flutter/lib/web_ui/test/html/paragraph/general_golden_test.dart @@ -270,7 +270,7 @@ Future testMain() async { // Draw a rect in the placeholder. // Leave some padding around the placeholder to make the black paragraph // background visible. - final double padding = 5; + const double padding = 5; final TextBox placeholderBox = paragraph2.getBoxesForPlaceholders().single; canvas.drawRect( placeholderBox.toRect().shift(offset).deflate(padding), @@ -371,11 +371,11 @@ Future testMain() async { }); void testFontFeatures(EngineCanvas canvas) { - final String text = 'Aa Bb Dd Ee Ff Difficult'; + const String text = 'Aa Bb Dd Ee Ff Difficult'; final FontFeature enableSmallCaps = FontFeature('smcp'); final FontFeature disableSmallCaps = FontFeature('smcp', 0); - final String numeric = '123.4560'; + const String numeric = '123.4560'; final FontFeature enableOnum = FontFeature('onum'); final FontFeature disableLigatures = FontFeature('liga', 0); diff --git a/engine/src/flutter/lib/web_ui/test/html/paragraph/overflow_golden_test.dart b/engine/src/flutter/lib/web_ui/test/html/paragraph/overflow_golden_test.dart index 27b02e7a3a..a948f53a4b 100644 --- a/engine/src/flutter/lib/web_ui/test/html/paragraph/overflow_golden_test.dart +++ b/engine/src/flutter/lib/web_ui/test/html/paragraph/overflow_golden_test.dart @@ -25,9 +25,9 @@ Future testMain() async { Offset offset = Offset.zero; CanvasParagraph paragraph; - final double fontSize = 22.0; - final double width = 126.0; - final double padding = 20.0; + const double fontSize = 22.0; + const double width = 126.0; + const double padding = 20.0; paragraph = rich( EngineParagraphStyle(fontFamily: 'Roboto', fontSize: fontSize, ellipsis: '...'), diff --git a/engine/src/flutter/lib/web_ui/test/html/paragraph/text_multiline_clipping_golden_test.dart b/engine/src/flutter/lib/web_ui/test/html/paragraph/text_multiline_clipping_golden_test.dart index e35f378af4..2aa3bb6b33 100644 --- a/engine/src/flutter/lib/web_ui/test/html/paragraph/text_multiline_clipping_golden_test.dart +++ b/engine/src/flutter/lib/web_ui/test/html/paragraph/text_multiline_clipping_golden_test.dart @@ -25,7 +25,7 @@ Future testMain() async { setUpStableTestFonts(); void paintTest(EngineCanvas canvas, PaintTest painter) { - final Rect screenRect = const Rect.fromLTWH(0, 0, 600, 600); + const Rect screenRect = Rect.fromLTWH(0, 0, 600, 600); final RecordingCanvas recordingCanvas = RecordingCanvas(screenRect); painter(recordingCanvas); recordingCanvas.endRecording(); diff --git a/engine/src/flutter/lib/web_ui/test/html/paragraph/text_placeholders_golden_test.dart b/engine/src/flutter/lib/web_ui/test/html/paragraph/text_placeholders_golden_test.dart index 5eb85870e0..6ea85995b6 100644 --- a/engine/src/flutter/lib/web_ui/test/html/paragraph/text_placeholders_golden_test.dart +++ b/engine/src/flutter/lib/web_ui/test/html/paragraph/text_placeholders_golden_test.dart @@ -28,7 +28,7 @@ Future testMain() async { setUpStableTestFonts(); testEachCanvas('draws paragraphs with placeholders', (EngineCanvas canvas) { - final Rect screenRect = const Rect.fromLTWH(0, 0, 600, 600); + const Rect screenRect = Rect.fromLTWH(0, 0, 600, 600); final RecordingCanvas recordingCanvas = RecordingCanvas(screenRect); Offset offset = Offset.zero; @@ -51,7 +51,7 @@ Future testMain() async { }); testEachCanvas('text alignment and placeholders', (EngineCanvas canvas) { - final Rect screenRect = const Rect.fromLTWH(0, 0, 600, 600); + const Rect screenRect = Rect.fromLTWH(0, 0, 600, 600); final RecordingCanvas recordingCanvas = RecordingCanvas(screenRect); Offset offset = Offset.zero; diff --git a/engine/src/flutter/lib/web_ui/test/html/path_metrics_golden_test.dart b/engine/src/flutter/lib/web_ui/test/html/path_metrics_golden_test.dart index 046f820468..ac2e21beda 100644 --- a/engine/src/flutter/lib/web_ui/test/html/path_metrics_golden_test.dart +++ b/engine/src/flutter/lib/web_ui/test/html/path_metrics_golden_test.dart @@ -67,10 +67,10 @@ Future testMain() async { test('Should calculate tangent on cubic curve', () async { final Path path = Path(); - final double p1x = 240; - final double p1y = 120; - final double p2x = 320; - final double p2y = 25; + const double p1x = 240; + const double p1y = 120; + const double p2x = 320; + const double p2y = 25; path.moveTo(150, 20); path.quadraticBezierTo(p1x, p1y, p2x, p2y); final PathMetric metric = path.computeMetrics().first; @@ -83,10 +83,10 @@ Future testMain() async { test('Should calculate tangent on quadratic curve', () async { final Path path = Path(); - final double p0x = 150; - final double p0y = 20; - final double p1x = 320; - final double p1y = 25; + const double p0x = 150; + const double p0y = 20; + const double p1x = 320; + const double p1y = 25; path.moveTo(150, 20); path.quadraticBezierTo(p0x, p0y, p1x, p1y); final PathMetric metric = path.computeMetrics().first; @@ -114,16 +114,16 @@ Future testMain() async { final SurfacePath path = SurfacePath(); path.moveTo(50, 130); path.lineTo(150, 20); - final double p1x = 240; - final double p1y = 120; - final double p2x = 320; - final double p2y = 25; + const double p1x = 240; + const double p1y = 120; + const double p2x = 320; + const double p2y = 25; path.quadraticBezierTo(p1x, p1y, p2x, p2y); rc.drawPath(path, paint); - final double t0 = 0.2; - final double t1 = 0.7; + const double t0 = 0.2; + const double t1 = 0.7; final List metrics = path.computeMetrics().toList(); double totalLength = 0; @@ -135,7 +135,7 @@ Future testMain() async { double distance = totalLength * t0; bool draw = true; while (distance < measurePath.length * t1) { - final double length = kDashLength; + const double length = kDashLength; if (draw) { dashedPath.addPath( measurePath.extractPath(distance, distance + length), @@ -166,18 +166,18 @@ Future testMain() async { final Path path = Path(); path.moveTo(50, 130); path.lineTo(150, 20); - final double p1x = 40; - final double p1y = 120; - final double p2x = 300; - final double p2y = 130; - final double p3x = 320; - final double p3y = 25; + const double p1x = 40; + const double p1y = 120; + const double p2x = 300; + const double p2y = 130; + const double p3x = 320; + const double p3y = 25; path.cubicTo(p1x, p1y, p2x, p2y, p3x, p3y); rc.drawPath(path, paint); - final double t0 = 0.2; - final double t1 = 0.7; + const double t0 = 0.2; + const double t1 = 0.7; final List metrics = path.computeMetrics().toList(); double totalLength = 0; @@ -189,7 +189,7 @@ Future testMain() async { double distance = totalLength * t0; bool draw = true; while (distance < measurePath.length * t1) { - final double length = kDashLength; + const double length = kDashLength; if (draw) { dashedPath.addPath( measurePath.extractPath(distance, distance + length), diff --git a/engine/src/flutter/lib/web_ui/test/html/shaders/image_shader_golden_test.dart b/engine/src/flutter/lib/web_ui/test/html/shaders/image_shader_golden_test.dart index 77fe70ee0c..0af6894aa6 100644 --- a/engine/src/flutter/lib/web_ui/test/html/shaders/image_shader_golden_test.dart +++ b/engine/src/flutter/lib/web_ui/test/html/shaders/image_shader_golden_test.dart @@ -68,7 +68,7 @@ Future testMain() async { final RecordingCanvas rc = RecordingCanvas(const Rect.fromLTRB(0, 0, screenWidth, screenHeight)); //Rect shaderRect = const Rect.fromLTRB(20, 20, 100, 100); - final Rect shaderRect = const Rect.fromLTRB(0, 0, 100, 100); + const Rect shaderRect = Rect.fromLTRB(0, 0, 100, 100); final SurfacePaint paint = Paint() as SurfacePaint; paint.shader = ImageShader(testImage, tmx, tmy, Matrix4.identity().toFloat64() diff --git a/engine/src/flutter/lib/web_ui/test/html/shaders/linear_gradient_golden_test.dart b/engine/src/flutter/lib/web_ui/test/html/shaders/linear_gradient_golden_test.dart index 5b18d1d5cb..3b99048765 100644 --- a/engine/src/flutter/lib/web_ui/test/html/shaders/linear_gradient_golden_test.dart +++ b/engine/src/flutter/lib/web_ui/test/html/shaders/linear_gradient_golden_test.dart @@ -29,7 +29,7 @@ Future testMain() async { test('Should draw linear gradient using rectangle.', () async { final RecordingCanvas rc = RecordingCanvas(const Rect.fromLTRB(0, 0, 500, 500)); - final Rect shaderRect = const Rect.fromLTRB(50, 50, 300, 300); + const Rect shaderRect = Rect.fromLTRB(50, 50, 300, 300); final SurfacePaint paint = SurfacePaint()..shader = Gradient.linear( Offset(shaderRect.left, shaderRect.top), Offset(shaderRect.right, shaderRect.bottom), @@ -78,7 +78,7 @@ Future testMain() async { test('Should draw linear gradient using rounded rect.', () async { final RecordingCanvas rc = RecordingCanvas(const Rect.fromLTRB(0, 0, 500, 500)); - final Rect shaderRect = const Rect.fromLTRB(50, 50, 300, 300); + const Rect shaderRect = Rect.fromLTRB(50, 50, 300, 300); final SurfacePaint paint = SurfacePaint()..shader = Gradient.linear( Offset(shaderRect.left, shaderRect.top), Offset(shaderRect.right, shaderRect.bottom), diff --git a/engine/src/flutter/lib/web_ui/test/html/shaders/radial_gradient_golden_test.dart b/engine/src/flutter/lib/web_ui/test/html/shaders/radial_gradient_golden_test.dart index 4e2f2b2bd0..558cd6aff3 100644 --- a/engine/src/flutter/lib/web_ui/test/html/shaders/radial_gradient_golden_test.dart +++ b/engine/src/flutter/lib/web_ui/test/html/shaders/radial_gradient_golden_test.dart @@ -37,7 +37,7 @@ Future testMain() async { } test('Should draw centered radial gradient.', () async { - final Rect shaderRect = const Rect.fromLTRB(50, 50, 300, 300); + const Rect shaderRect = Rect.fromLTRB(50, 50, 300, 300); await _testGradient( 'radial_gradient_centered', Gradient.radial( @@ -53,7 +53,7 @@ Future testMain() async { }); test('Should draw right bottom centered radial gradient.', () async { - final Rect shaderRect = const Rect.fromLTRB(50, 50, 300, 300); + const Rect shaderRect = Rect.fromLTRB(50, 50, 300, 300); await _testGradient( 'radial_gradient_right_bottom', Gradient.radial( @@ -70,7 +70,7 @@ Future testMain() async { }); test('Should draw with radial gradient with TileMode.clamp.', () async { - final Rect shaderRect = const Rect.fromLTRB(50, 50, 100, 100); + const Rect shaderRect = Rect.fromLTRB(50, 50, 100, 100); await _testGradient( 'radial_gradient_tilemode_clamp', Gradient.radial( @@ -99,7 +99,7 @@ Future testMain() async { const List colorStops = [0.0, 0.05, 0.4, 0.6, 0.9, 1.0]; test('Should draw with radial gradient with TileMode.repeated.', () async { - final Rect shaderRect = const Rect.fromLTRB(50, 50, 100, 100); + const Rect shaderRect = Rect.fromLTRB(50, 50, 100, 100); await _testGradient( 'radial_gradient_tilemode_repeated', Gradient.radial( @@ -114,7 +114,7 @@ Future testMain() async { }); test('Should draw with radial gradient with TileMode.mirrored.', () async { - final Rect shaderRect = const Rect.fromLTRB(50, 50, 100, 100); + const Rect shaderRect = Rect.fromLTRB(50, 50, 100, 100); await _testGradient( 'radial_gradient_tilemode_mirror', Gradient.radial( diff --git a/engine/src/flutter/lib/web_ui/test/html/shaders/shader_mask_golden_test.dart b/engine/src/flutter/lib/web_ui/test/html/shaders/shader_mask_golden_test.dart index 2832ba4eeb..9254540123 100644 --- a/engine/src/flutter/lib/web_ui/test/html/shaders/shader_mask_golden_test.dart +++ b/engine/src/flutter/lib/web_ui/test/html/shaders/shader_mask_golden_test.dart @@ -178,7 +178,7 @@ Picture _drawTestPictureWithText( builder.addText(text); final CanvasParagraph paragraph = builder.build(); - final double maxWidth = 200 - 10; + const double maxWidth = 200 - 10; paragraph.layout(ParagraphConstraints(width: maxWidth)); canvas.drawParagraph(paragraph, Offset(offsetX, offsetY)); return recorder.endRecording(); diff --git a/engine/src/flutter/lib/web_ui/test/keyboard_converter_test.dart b/engine/src/flutter/lib/web_ui/test/keyboard_converter_test.dart index 6d23e3421c..30d2fbeadb 100644 --- a/engine/src/flutter/lib/web_ui/test/keyboard_converter_test.dart +++ b/engine/src/flutter/lib/web_ui/test/keyboard_converter_test.dart @@ -25,14 +25,14 @@ final int kPhysicalTab = kWebToPhysicalKey['Tab']!; final int kPhysicalCapsLock = kWebToPhysicalKey['CapsLock']!; final int kPhysicalScrollLock = kWebToPhysicalKey['ScrollLock']!; -final int kLogicalKeyA = 0x00000000061; -final int kLogicalKeyU = 0x00000000075; -final int kLogicalDigit1 = 0x00000000031; +const int kLogicalKeyA = 0x00000000061; +const int kLogicalKeyU = 0x00000000075; +const int kLogicalDigit1 = 0x00000000031; final int kLogicalNumpad1 = kWebLogicalLocationMap['1']![kLocationNumpad]!; final int kLogicalShiftLeft = kWebLogicalLocationMap['Shift']![kLocationLeft]!; final int kLogicalShiftRight = kWebLogicalLocationMap['Shift']![kLocationRight]!; final int kLogicalMetaLeft = kWebLogicalLocationMap['Meta']![kLocationLeft]!; -final int kLogicalTab = 0x0000000009; +const int kLogicalTab = 0x0000000009; final int kLogicalCapsLock = kWebToLogicalKey['CapsLock']!; final int kLogicalScrollLock = kWebToLogicalKey['ScrollLock']!; diff --git a/engine/src/flutter/lib/web_ui/test/text/canvas_paragraph_builder_test.dart b/engine/src/flutter/lib/web_ui/test/text/canvas_paragraph_builder_test.dart index f2a1e1a85e..9ad02f348f 100644 --- a/engine/src/flutter/lib/web_ui/test/text/canvas_paragraph_builder_test.dart +++ b/engine/src/flutter/lib/web_ui/test/text/canvas_paragraph_builder_test.dart @@ -25,7 +25,7 @@ String fontFamilyToAttribute(String fontFamily) { final String defaultFontFamily = fontFamilyToAttribute('Ahem'); const String defaultColor = 'color: rgb(255, 0, 0);'; const String defaultFontSize = 'font-size: 14px;'; -final String paragraphStyle = +const String paragraphStyle = 'position: absolute; white-space: pre;'; void main() { diff --git a/engine/src/flutter/lib/web_ui/test/text/font_collection_test.dart b/engine/src/flutter/lib/web_ui/test/text/font_collection_test.dart index aba20afd2a..7de6eff71e 100644 --- a/engine/src/flutter/lib/web_ui/test/text/font_collection_test.dart +++ b/engine/src/flutter/lib/web_ui/test/text/font_collection_test.dart @@ -28,7 +28,7 @@ void testMain() { group('regular special characters', () { test('Register Asset with no special characters', () async { - final String _testFontFamily = "Ahem"; + const String _testFontFamily = "Ahem"; final List fontFamilyList = []; fontManager.registerAsset( @@ -46,7 +46,7 @@ void testMain() { skip: browserEngine == BrowserEngine.edge); test('Register Asset with white space in the family name', () async { - final String _testFontFamily = "Ahem ahem ahem"; + const String _testFontFamily = "Ahem ahem ahem"; final List fontFamilyList = []; fontManager.registerAsset( @@ -66,7 +66,7 @@ void testMain() { browserEngine == BrowserEngine.webkit); test('Register Asset with capital case letters', () async { - final String _testFontFamily = "AhEm"; + const String _testFontFamily = "AhEm"; final List fontFamilyList = []; fontManager.registerAsset( @@ -86,7 +86,7 @@ void testMain() { group('fonts with special characters', () { test('Register Asset twice with special character slash', () async { - final String _testFontFamily = '/Ahem'; + const String _testFontFamily = '/Ahem'; final List fontFamilyList = []; fontManager.registerAsset( @@ -112,7 +112,7 @@ void testMain() { browserEngine == BrowserEngine.webkit); test('Register Asset twice with exclamation mark', () async { - final String _testFontFamily = 'Ahem!!ahem'; + const String _testFontFamily = 'Ahem!!ahem'; final List fontFamilyList = []; fontManager.registerAsset( @@ -138,7 +138,7 @@ void testMain() { browserEngine == BrowserEngine.webkit); test('Register Asset twice with comma', () async { - final String _testFontFamily = 'Ahem ,ahem'; + const String _testFontFamily = 'Ahem ,ahem'; final List fontFamilyList = []; fontManager.registerAsset( @@ -165,7 +165,7 @@ void testMain() { test('Register Asset twice with a digit at the start of a token', () async { - final String testFontFamily = 'Ahem 1998'; + const String testFontFamily = 'Ahem 1998'; final List fontFamilyList = []; fontManager.registerAsset( diff --git a/engine/src/flutter/lib/web_ui/test/text_editing_test.dart b/engine/src/flutter/lib/web_ui/test/text_editing_test.dart index c13bd55cf8..2ebc757a56 100644 --- a/engine/src/flutter/lib/web_ui/test/text_editing_test.dart +++ b/engine/src/flutter/lib/web_ui/test/text_editing_test.dart @@ -1396,7 +1396,7 @@ void testMain() { test('multiTextField Autofill sync updates back to Flutter', () { // Create a configuration with an AutofillGroup of four text fields. - final String hintForFirstElement = 'familyName'; + const String hintForFirstElement = 'familyName'; final Map flutterMultiAutofillElementConfig = createFlutterConfig('text', autofillHint: 'email', @@ -2064,10 +2064,10 @@ void checkInputEditingState( void clearBackUpDomElementIfExists() { final List domElementsToRemove = []; if (defaultTextEditingRoot.querySelectorAll('input').isNotEmpty) { - domElementsToRemove..addAll(defaultTextEditingRoot.querySelectorAll('input')); + domElementsToRemove.addAll(defaultTextEditingRoot.querySelectorAll('input')); } if (defaultTextEditingRoot.querySelectorAll('textarea').isNotEmpty) { - domElementsToRemove..addAll(defaultTextEditingRoot.querySelectorAll('textarea')); + domElementsToRemove.addAll(defaultTextEditingRoot.querySelectorAll('textarea')); } domElementsToRemove.forEach(_removeNode); } diff --git a/engine/src/flutter/lib/web_ui/test/window_test.dart b/engine/src/flutter/lib/web_ui/test/window_test.dart index d92fa243e6..45a0d3a31d 100644 --- a/engine/src/flutter/lib/web_ui/test/window_test.dart +++ b/engine/src/flutter/lib/web_ui/test/window_test.dart @@ -70,7 +70,7 @@ void testMain() { 'flutter/navigation', JSONMethodCodec().encodeMethodCall(MethodCall( 'routeUpdated', - {'routeName': '/bar'}, + const {'routeName': '/bar'}, )), (_) { callback.complete(); }, ); @@ -167,6 +167,7 @@ void testMain() { await window.handleNavigationMessage( JSONMethodCodec().encodeMethodCall(MethodCall( 'routeInformationUpdated', + // ignore: prefer_const_literals_to_create_immutables { 'location': '/baz', 'state': null, @@ -197,6 +198,7 @@ void testMain() { 'flutter/navigation', JSONMethodCodec().encodeMethodCall(MethodCall( 'routeUpdated', + // ignore: prefer_const_literals_to_create_immutables {'routeName': '/bar'}, )), (_) { callback.complete(); }, @@ -211,6 +213,7 @@ void testMain() { 'flutter/navigation', JSONMethodCodec().encodeMethodCall(MethodCall( 'routeInformationUpdated', + // ignore: prefer_const_literals_to_create_immutables { 'location': '/baz', 'state': null, @@ -226,6 +229,7 @@ void testMain() { await window.handleNavigationMessage( JSONMethodCodec().encodeMethodCall(MethodCall( 'routeUpdated', + // ignore: prefer_const_literals_to_create_immutables {'routeName': '/foo'}, )) ); @@ -245,6 +249,7 @@ void testMain() { 'flutter/navigation', JSONMethodCodec().encodeMethodCall(MethodCall( 'routeInformationUpdated', + // ignore: prefer_const_literals_to_create_immutables { 'location': '/baz', 'state': '/state', @@ -261,6 +266,7 @@ void testMain() { 'flutter/navigation', JSONMethodCodec().encodeMethodCall(MethodCall( 'routeInformationUpdated', + // ignore: prefer_const_literals_to_create_immutables { 'location': '/baz', 'state': '/state1', @@ -278,6 +284,7 @@ void testMain() { 'flutter/navigation', JSONMethodCodec().encodeMethodCall(MethodCall( 'routeInformationUpdated', + // ignore: prefer_const_literals_to_create_immutables { 'location': '/foo', 'state': '/foostate1', @@ -307,6 +314,7 @@ void testMain() { 'flutter/navigation', JSONMethodCodec().encodeMethodCall(MethodCall( 'routeUpdated', + // ignore: prefer_const_literals_to_create_immutables {'routeName': '/bar'}, )), (_) { callback.complete(); }, @@ -332,6 +340,7 @@ void testMain() { 'flutter/navigation', JSONMethodCodec().encodeMethodCall(MethodCall( 'routeInformationUpdated', + // ignore: prefer_const_literals_to_create_immutables { 'location': '/baz', 'state': null,