[web] Code cleanup (#27766)
diff --git a/lib/web_ui/analysis_options.yaml b/lib/web_ui/analysis_options.yaml
index 3e5e0e7..f4b1f25 100644
--- a/lib/web_ui/analysis_options.yaml
+++ b/lib/web_ui/analysis_options.yaml
@@ -13,28 +13,13 @@
linter:
rules:
- library_names: false
- library_prefixes: false
- list_remove_unrelated_type: false
- no_adjacent_strings_in_list: false
- no_duplicate_case_values: false
- non_constant_identifier_names: false
- overridden_fields: false
package_api_docs: false
- package_names: false
- prefer_adjacent_string_concatenation: false
- prefer_conditional_assignment: false
- prefer_const_constructors: false
- prefer_const_constructors_in_immutables: false
prefer_foreach: false
prefer_generic_function_type_aliases: false
prefer_initializing_formals: false
prefer_single_quotes: false
prefer_typing_uninitialized_variables: false
public_member_api_docs: false
- recursive_getters: false
- slash_for_doc_comments: false
- sort_unnamed_constructors_first: false
flutter_style_todos: false
# We have some legitimate use-cases for this (preserve tear-off identity)
diff --git a/lib/web_ui/dev/browser.dart b/lib/web_ui/dev/browser.dart
index 4125597..0b8c792 100644
--- a/lib/web_ui/dev/browser.dart
+++ b/lib/web_ui/dev/browser.dart
@@ -130,7 +130,7 @@
// resolve the ambiguity is to wait a brief amount of time and see if this
// browser is actually closed.
if (!_closed && exitCode < 0) {
- await Future<void>.delayed(Duration(milliseconds: 200));
+ await Future<void>.delayed(const Duration(milliseconds: 200));
}
if (!_closed && exitCode != 0) {
@@ -153,9 +153,8 @@
// Make sure the process dies even if the error wasn't fatal.
_process.then((Process process) => process.kill());
- if (stackTrace == null) {
- stackTrace = Trace.current();
- }
+ stackTrace ??= Trace.current();
+
if (_onExitCompleter.isCompleted) {
return;
}
diff --git a/lib/web_ui/dev/test_platform.dart b/lib/web_ui/dev/test_platform.dart
index be147c2..481de15 100644
--- a/lib/web_ui/dev/test_platform.dart
+++ b/lib/web_ui/dev/test_platform.dart
@@ -614,7 +614,7 @@
//
// Start this canceled because we don't want it to start ticking until we
// get some response from the iframe.
- _timer = RestartableTimer(Duration(seconds: 3), () {
+ _timer = RestartableTimer(const Duration(seconds: 3), () {
for (final RunnerSuiteController controller in _controllers) {
controller.setDebugging(true);
}
diff --git a/lib/web_ui/dev/utils.dart b/lib/web_ui/dev/utils.dart
index ec9e854..5912676 100644
--- a/lib/web_ui/dev/utils.dart
+++ b/lib/web_ui/dev/utils.dart
@@ -262,7 +262,7 @@
/// An exception related to an attempt to spawn a sub-process.
@immutable
class ProcessException implements Exception {
- ProcessException({
+ const ProcessException({
required this.description,
required this.executable,
required this.arguments,
diff --git a/lib/web_ui/lib/src/engine/canvaskit/canvaskit_api.dart b/lib/web_ui/lib/src/engine/canvaskit/canvaskit_api.dart
index 5fb0fd3..d4c8a53 100644
--- a/lib/web_ui/lib/src/engine/canvaskit/canvaskit_api.dart
+++ b/lib/web_ui/lib/src/engine/canvaskit/canvaskit_api.dart
@@ -6,6 +6,7 @@
///
/// Prefer keeping the original CanvasKit names so it is easier to locate
/// the API behind these bindings in the Skia source code.
+// ignore_for_file: non_constant_identifier_names
@JS()
library canvaskit_api;
diff --git a/lib/web_ui/lib/src/engine/canvaskit/embedded_views.dart b/lib/web_ui/lib/src/engine/canvaskit/embedded_views.dart
index fa60d0a..a1ccaa8 100644
--- a/lib/web_ui/lib/src/engine/canvaskit/embedded_views.dart
+++ b/lib/web_ui/lib/src/engine/canvaskit/embedded_views.dart
@@ -101,14 +101,14 @@
// Only initialize the picture recorder for the backup surface once.
final CkPictureRecorder pictureRecorder = CkPictureRecorder();
pictureRecorder.beginRecording(ui.Offset.zero & _frameSize);
- pictureRecorder.recordingCanvas!.clear(ui.Color(0x00000000));
+ pictureRecorder.recordingCanvas!.clear(const ui.Color(0x00000000));
_backupPictureRecorder = pictureRecorder;
}
_pictureRecorders[viewId] = _backupPictureRecorder!;
} else {
final CkPictureRecorder pictureRecorder = CkPictureRecorder();
pictureRecorder.beginRecording(ui.Offset.zero & _frameSize);
- pictureRecorder.recordingCanvas!.clear(ui.Color(0x00000000));
+ pictureRecorder.recordingCanvas!.clear(const ui.Color(0x00000000));
_pictureRecorders[viewId] = pictureRecorder;
}
_compositionOrder.add(viewId);
diff --git a/lib/web_ui/lib/src/engine/canvaskit/font_fallbacks.dart b/lib/web_ui/lib/src/engine/canvaskit/font_fallbacks.dart
index cadfad0..7df7c79 100644
--- a/lib/web_ui/lib/src/engine/canvaskit/font_fallbacks.dart
+++ b/lib/web_ui/lib/src/engine/canvaskit/font_fallbacks.dart
@@ -629,29 +629,29 @@
}
NotoFont _notoSansSC = NotoFont('Noto Sans SC', <CodeunitRange>[
- CodeunitRange(12288, 12591),
- CodeunitRange(12800, 13311),
- CodeunitRange(19968, 40959),
- CodeunitRange(65072, 65135),
- CodeunitRange(65280, 65519),
+ const CodeunitRange(12288, 12591),
+ const CodeunitRange(12800, 13311),
+ const CodeunitRange(19968, 40959),
+ const CodeunitRange(65072, 65135),
+ const CodeunitRange(65280, 65519),
]);
NotoFont _notoSansTC = NotoFont('Noto Sans TC', <CodeunitRange>[
- CodeunitRange(12288, 12351),
- CodeunitRange(12549, 12585),
- CodeunitRange(19968, 40959),
+ const CodeunitRange(12288, 12351),
+ const CodeunitRange(12549, 12585),
+ const CodeunitRange(19968, 40959),
]);
NotoFont _notoSansHK = NotoFont('Noto Sans HK', <CodeunitRange>[
- CodeunitRange(12288, 12351),
- CodeunitRange(12549, 12585),
- CodeunitRange(19968, 40959),
+ const CodeunitRange(12288, 12351),
+ const CodeunitRange(12549, 12585),
+ const CodeunitRange(19968, 40959),
]);
NotoFont _notoSansJP = NotoFont('Noto Sans JP', <CodeunitRange>[
- CodeunitRange(12288, 12543),
- CodeunitRange(19968, 40959),
- CodeunitRange(65280, 65519),
+ const CodeunitRange(12288, 12543),
+ const CodeunitRange(19968, 40959),
+ const CodeunitRange(65280, 65519),
]);
List<NotoFont> _cjkFonts = <NotoFont>[
@@ -667,181 +667,181 @@
_notoSansHK,
_notoSansJP,
NotoFont('Noto Naskh Arabic UI', <CodeunitRange>[
- CodeunitRange(1536, 1791),
- CodeunitRange(8204, 8206),
- CodeunitRange(8208, 8209),
- CodeunitRange(8271, 8271),
- CodeunitRange(11841, 11841),
- CodeunitRange(64336, 65023),
- CodeunitRange(65132, 65276),
+ const CodeunitRange(1536, 1791),
+ const CodeunitRange(8204, 8206),
+ const CodeunitRange(8208, 8209),
+ const CodeunitRange(8271, 8271),
+ const CodeunitRange(11841, 11841),
+ const CodeunitRange(64336, 65023),
+ const CodeunitRange(65132, 65276),
]),
NotoFont('Noto Sans Armenian', <CodeunitRange>[
- CodeunitRange(1328, 1424),
- CodeunitRange(64275, 64279),
+ const CodeunitRange(1328, 1424),
+ const CodeunitRange(64275, 64279),
]),
NotoFont('Noto Sans Bengali UI', <CodeunitRange>[
- CodeunitRange(2404, 2405),
- CodeunitRange(2433, 2555),
- CodeunitRange(8204, 8205),
- CodeunitRange(8377, 8377),
- CodeunitRange(9676, 9676),
+ const CodeunitRange(2404, 2405),
+ const CodeunitRange(2433, 2555),
+ const CodeunitRange(8204, 8205),
+ const CodeunitRange(8377, 8377),
+ const CodeunitRange(9676, 9676),
]),
NotoFont('Noto Sans Myanmar UI', <CodeunitRange>[
- CodeunitRange(4096, 4255),
- CodeunitRange(8204, 8205),
- CodeunitRange(9676, 9676),
+ const CodeunitRange(4096, 4255),
+ const CodeunitRange(8204, 8205),
+ const CodeunitRange(9676, 9676),
]),
NotoFont('Noto Sans Egyptian Hieroglyphs', <CodeunitRange>[
- CodeunitRange(77824, 78894),
+ const CodeunitRange(77824, 78894),
]),
NotoFont('Noto Sans Ethiopic', <CodeunitRange>[
- CodeunitRange(4608, 5017),
- CodeunitRange(11648, 11742),
- CodeunitRange(43777, 43822),
+ const CodeunitRange(4608, 5017),
+ const CodeunitRange(11648, 11742),
+ const CodeunitRange(43777, 43822),
]),
NotoFont('Noto Sans Georgian', <CodeunitRange>[
- CodeunitRange(1417, 1417),
- CodeunitRange(4256, 4351),
- CodeunitRange(11520, 11567),
+ const CodeunitRange(1417, 1417),
+ const CodeunitRange(4256, 4351),
+ const CodeunitRange(11520, 11567),
]),
NotoFont('Noto Sans Gujarati UI', <CodeunitRange>[
- CodeunitRange(2404, 2405),
- CodeunitRange(2688, 2815),
- CodeunitRange(8204, 8205),
- CodeunitRange(8377, 8377),
- CodeunitRange(9676, 9676),
- CodeunitRange(43056, 43065),
+ const CodeunitRange(2404, 2405),
+ const CodeunitRange(2688, 2815),
+ const CodeunitRange(8204, 8205),
+ const CodeunitRange(8377, 8377),
+ const CodeunitRange(9676, 9676),
+ const CodeunitRange(43056, 43065),
]),
NotoFont('Noto Sans Gurmukhi UI', <CodeunitRange>[
- CodeunitRange(2404, 2405),
- CodeunitRange(2561, 2677),
- CodeunitRange(8204, 8205),
- CodeunitRange(8377, 8377),
- CodeunitRange(9676, 9676),
- CodeunitRange(9772, 9772),
- CodeunitRange(43056, 43065),
+ const CodeunitRange(2404, 2405),
+ const CodeunitRange(2561, 2677),
+ const CodeunitRange(8204, 8205),
+ const CodeunitRange(8377, 8377),
+ const CodeunitRange(9676, 9676),
+ const CodeunitRange(9772, 9772),
+ const CodeunitRange(43056, 43065),
]),
NotoFont('Noto Sans Hebrew', <CodeunitRange>[
- CodeunitRange(1424, 1535),
- CodeunitRange(8362, 8362),
- CodeunitRange(9676, 9676),
- CodeunitRange(64285, 64335),
+ const CodeunitRange(1424, 1535),
+ const CodeunitRange(8362, 8362),
+ const CodeunitRange(9676, 9676),
+ const CodeunitRange(64285, 64335),
]),
NotoFont('Noto Sans Devanagari UI', <CodeunitRange>[
- CodeunitRange(2304, 2431),
- CodeunitRange(7376, 7414),
- CodeunitRange(7416, 7417),
- CodeunitRange(8204, 8205),
- CodeunitRange(8360, 8360),
- CodeunitRange(8377, 8377),
- CodeunitRange(9676, 9676),
- CodeunitRange(43056, 43065),
- CodeunitRange(43232, 43259),
+ const CodeunitRange(2304, 2431),
+ const CodeunitRange(7376, 7414),
+ const CodeunitRange(7416, 7417),
+ const CodeunitRange(8204, 8205),
+ const CodeunitRange(8360, 8360),
+ const CodeunitRange(8377, 8377),
+ const CodeunitRange(9676, 9676),
+ const CodeunitRange(43056, 43065),
+ const CodeunitRange(43232, 43259),
]),
NotoFont('Noto Sans Kannada UI', <CodeunitRange>[
- CodeunitRange(2404, 2405),
- CodeunitRange(3202, 3314),
- CodeunitRange(8204, 8205),
- CodeunitRange(8377, 8377),
- CodeunitRange(9676, 9676),
+ const CodeunitRange(2404, 2405),
+ const CodeunitRange(3202, 3314),
+ const CodeunitRange(8204, 8205),
+ const CodeunitRange(8377, 8377),
+ const CodeunitRange(9676, 9676),
]),
NotoFont('Noto Sans Khmer UI', <CodeunitRange>[
- CodeunitRange(6016, 6143),
- CodeunitRange(8204, 8204),
- CodeunitRange(9676, 9676),
+ const CodeunitRange(6016, 6143),
+ const CodeunitRange(8204, 8204),
+ const CodeunitRange(9676, 9676),
]),
NotoFont('Noto Sans KR', <CodeunitRange>[
- CodeunitRange(12593, 12686),
- CodeunitRange(12800, 12828),
- CodeunitRange(12896, 12923),
- CodeunitRange(44032, 55215),
+ const CodeunitRange(12593, 12686),
+ const CodeunitRange(12800, 12828),
+ const CodeunitRange(12896, 12923),
+ const CodeunitRange(44032, 55215),
]),
NotoFont('Noto Sans Lao UI', <CodeunitRange>[
- CodeunitRange(3713, 3807),
- CodeunitRange(9676, 9676),
+ const CodeunitRange(3713, 3807),
+ const CodeunitRange(9676, 9676),
]),
NotoFont('Noto Sans Malayalam UI', <CodeunitRange>[
- CodeunitRange(775, 775),
- CodeunitRange(803, 803),
- CodeunitRange(2404, 2405),
- CodeunitRange(3330, 3455),
- CodeunitRange(8204, 8205),
- CodeunitRange(8377, 8377),
- CodeunitRange(9676, 9676),
+ const CodeunitRange(775, 775),
+ const CodeunitRange(803, 803),
+ const CodeunitRange(2404, 2405),
+ const CodeunitRange(3330, 3455),
+ const CodeunitRange(8204, 8205),
+ const CodeunitRange(8377, 8377),
+ const CodeunitRange(9676, 9676),
]),
NotoFont('Noto Sans Sinhala', <CodeunitRange>[
- CodeunitRange(2404, 2405),
- CodeunitRange(3458, 3572),
- CodeunitRange(8204, 8205),
- CodeunitRange(9676, 9676),
+ const CodeunitRange(2404, 2405),
+ const CodeunitRange(3458, 3572),
+ const CodeunitRange(8204, 8205),
+ const CodeunitRange(9676, 9676),
]),
NotoFont('Noto Sans Tamil UI', <CodeunitRange>[
- CodeunitRange(2404, 2405),
- CodeunitRange(2946, 3066),
- CodeunitRange(8204, 8205),
- CodeunitRange(8377, 8377),
- CodeunitRange(9676, 9676),
+ const CodeunitRange(2404, 2405),
+ const CodeunitRange(2946, 3066),
+ const CodeunitRange(8204, 8205),
+ const CodeunitRange(8377, 8377),
+ const CodeunitRange(9676, 9676),
]),
NotoFont('Noto Sans Telugu UI', <CodeunitRange>[
- CodeunitRange(2385, 2386),
- CodeunitRange(2404, 2405),
- CodeunitRange(3072, 3199),
- CodeunitRange(7386, 7386),
- CodeunitRange(8204, 8205),
- CodeunitRange(9676, 9676),
+ const CodeunitRange(2385, 2386),
+ const CodeunitRange(2404, 2405),
+ const CodeunitRange(3072, 3199),
+ const CodeunitRange(7386, 7386),
+ const CodeunitRange(8204, 8205),
+ const CodeunitRange(9676, 9676),
]),
NotoFont('Noto Sans Thai UI', <CodeunitRange>[
- CodeunitRange(3585, 3675),
- CodeunitRange(8204, 8205),
- CodeunitRange(9676, 9676),
+ const CodeunitRange(3585, 3675),
+ const CodeunitRange(8204, 8205),
+ const CodeunitRange(9676, 9676),
]),
NotoFont('Noto Sans', <CodeunitRange>[
- CodeunitRange(0, 255),
- CodeunitRange(305, 305),
- CodeunitRange(338, 339),
- CodeunitRange(699, 700),
- CodeunitRange(710, 710),
- CodeunitRange(730, 730),
- CodeunitRange(732, 732),
- CodeunitRange(8192, 8303),
- CodeunitRange(8308, 8308),
- CodeunitRange(8364, 8364),
- CodeunitRange(8482, 8482),
- CodeunitRange(8593, 8593),
- CodeunitRange(8595, 8595),
- CodeunitRange(8722, 8722),
- CodeunitRange(8725, 8725),
- CodeunitRange(65279, 65279),
- CodeunitRange(65533, 65533),
- CodeunitRange(1024, 1119),
- CodeunitRange(1168, 1169),
- CodeunitRange(1200, 1201),
- CodeunitRange(8470, 8470),
- CodeunitRange(1120, 1327),
- CodeunitRange(7296, 7304),
- CodeunitRange(8372, 8372),
- CodeunitRange(11744, 11775),
- CodeunitRange(42560, 42655),
- CodeunitRange(65070, 65071),
- CodeunitRange(880, 1023),
- CodeunitRange(7936, 8191),
- CodeunitRange(256, 591),
- CodeunitRange(601, 601),
- CodeunitRange(7680, 7935),
- CodeunitRange(8224, 8224),
- CodeunitRange(8352, 8363),
- CodeunitRange(8365, 8399),
- CodeunitRange(8467, 8467),
- CodeunitRange(11360, 11391),
- CodeunitRange(42784, 43007),
- CodeunitRange(258, 259),
- CodeunitRange(272, 273),
- CodeunitRange(296, 297),
- CodeunitRange(360, 361),
- CodeunitRange(416, 417),
- CodeunitRange(431, 432),
- CodeunitRange(7840, 7929),
- CodeunitRange(8363, 8363),
+ const CodeunitRange(0, 255),
+ const CodeunitRange(305, 305),
+ const CodeunitRange(338, 339),
+ const CodeunitRange(699, 700),
+ const CodeunitRange(710, 710),
+ const CodeunitRange(730, 730),
+ const CodeunitRange(732, 732),
+ const CodeunitRange(8192, 8303),
+ const CodeunitRange(8308, 8308),
+ const CodeunitRange(8364, 8364),
+ const CodeunitRange(8482, 8482),
+ const CodeunitRange(8593, 8593),
+ const CodeunitRange(8595, 8595),
+ const CodeunitRange(8722, 8722),
+ const CodeunitRange(8725, 8725),
+ const CodeunitRange(65279, 65279),
+ const CodeunitRange(65533, 65533),
+ const CodeunitRange(1024, 1119),
+ const CodeunitRange(1168, 1169),
+ const CodeunitRange(1200, 1201),
+ const CodeunitRange(8470, 8470),
+ const CodeunitRange(1120, 1327),
+ const CodeunitRange(7296, 7304),
+ const CodeunitRange(8372, 8372),
+ const CodeunitRange(11744, 11775),
+ const CodeunitRange(42560, 42655),
+ const CodeunitRange(65070, 65071),
+ const CodeunitRange(880, 1023),
+ const CodeunitRange(7936, 8191),
+ const CodeunitRange(256, 591),
+ const CodeunitRange(601, 601),
+ const CodeunitRange(7680, 7935),
+ const CodeunitRange(8224, 8224),
+ const CodeunitRange(8352, 8363),
+ const CodeunitRange(8365, 8399),
+ const CodeunitRange(8467, 8467),
+ const CodeunitRange(11360, 11391),
+ const CodeunitRange(42784, 43007),
+ const CodeunitRange(258, 259),
+ const CodeunitRange(272, 273),
+ const CodeunitRange(296, 297),
+ const CodeunitRange(360, 361),
+ const CodeunitRange(416, 417),
+ const CodeunitRange(431, 432),
+ const CodeunitRange(7840, 7929),
+ const CodeunitRange(8363, 8363),
]),
];
diff --git a/lib/web_ui/lib/src/engine/canvaskit/layer_tree.dart b/lib/web_ui/lib/src/engine/canvaskit/layer_tree.dart
index 909ecdb..ef67732 100644
--- a/lib/web_ui/lib/src/engine/canvaskit/layer_tree.dart
+++ b/lib/web_ui/lib/src/engine/canvaskit/layer_tree.dart
@@ -54,7 +54,7 @@
internalNodesCanvas.addCanvas(overlayCanvases[i]);
}
// Clear the canvases before painting
- internalNodesCanvas.clear(ui.Color(0x00000000));
+ internalNodesCanvas.clear(const ui.Color(0x00000000));
final PaintContext context = PaintContext(
internalNodesCanvas,
frame.canvas,
diff --git a/lib/web_ui/lib/src/engine/canvaskit/text.dart b/lib/web_ui/lib/src/engine/canvaskit/text.dart
index ab051d8..5fefea4 100644
--- a/lib/web_ui/lib/src/engine/canvaskit/text.dart
+++ b/lib/web_ui/lib/src/engine/canvaskit/text.dart
@@ -778,7 +778,7 @@
return ui.TextRange(start: metric.startIndex, end: metric.endIndex);
}
}
- return ui.TextRange(start: -1, end: -1);
+ return const ui.TextRange(start: -1, end: -1);
}
@override
diff --git a/lib/web_ui/lib/src/engine/font_change_util.dart b/lib/web_ui/lib/src/engine/font_change_util.dart
index b41cc14..14cfcf0 100644
--- a/lib/web_ui/lib/src/engine/font_change_util.dart
+++ b/lib/web_ui/lib/src/engine/font_change_util.dart
@@ -10,7 +10,8 @@
import 'services.dart';
final ByteData? _fontChangeMessage =
- JSONMessageCodec().encodeMessage(<String, dynamic>{'type': 'fontsChange'});
+ const JSONMessageCodec().encodeMessage(
+ <String, dynamic>{'type': 'fontsChange'});
// Font load callbacks will typically arrive in sequence, we want to prevent
// sendFontChangeMessage of causing multiple synchronous rebuilds.
diff --git a/lib/web_ui/lib/src/engine/html/bitmap_canvas.dart b/lib/web_ui/lib/src/engine/html/bitmap_canvas.dart
index 857ed2b..f1731cb 100644
--- a/lib/web_ui/lib/src/engine/html/bitmap_canvas.dart
+++ b/lib/web_ui/lib/src/engine/html/bitmap_canvas.dart
@@ -586,7 +586,7 @@
}
}
_applyFilter(svgElm, paint);
- _drawElement(svgElm, ui.Offset(0, 0), paint);
+ _drawElement(svgElm, const ui.Offset(0, 0), paint);
} else {
setUpPaint(paint, paint.shader != null ? path.getBounds() : null);
if (paint.style == null && paint.strokeWidth != null) {
@@ -1009,7 +1009,7 @@
: convertVertexPositions(mode, vertices.positions);
// Draw hairline for vertices if no vertex colors are specified.
save();
- final ui.Color color = paint.color ?? ui.Color(0xFF000000);
+ final ui.Color color = paint.color ?? const ui.Color(0xFF000000);
_canvasPool.contextHandle
..fillStyle = null
..strokeStyle = colorToCssString(color);
diff --git a/lib/web_ui/lib/src/engine/html/color_filter.dart b/lib/web_ui/lib/src/engine/html/color_filter.dart
index 5a43dd1..1b61063 100644
--- a/lib/web_ui/lib/src/engine/html/color_filter.dart
+++ b/lib/web_ui/lib/src/engine/html/color_filter.dart
@@ -220,11 +220,8 @@
case ui.BlendMode.luminosity:
case ui.BlendMode.multiply:
case ui.BlendMode.screen:
- case ui.BlendMode.overlay:
case ui.BlendMode.darken:
case ui.BlendMode.lighten:
- case ui.BlendMode.colorDodge:
- case ui.BlendMode.colorBurn:
case ui.BlendMode.hardLight:
case ui.BlendMode.softLight:
case ui.BlendMode.difference:
diff --git a/lib/web_ui/lib/src/engine/html/path/conic.dart b/lib/web_ui/lib/src/engine/html/path/conic.dart
index f617f76..ba5c50d 100644
--- a/lib/web_ui/lib/src/engine/html/path/conic.dart
+++ b/lib/web_ui/lib/src/engine/html/path/conic.dart
@@ -427,11 +427,11 @@
// {t^2 (2 - 2 w), t (-2 + 2 w), 1}
// Calculate coefficients and solve root.
final QuadRoots roots = QuadRoots();
- final double P20x = x2 - x1;
- final double P10x = cpX - x1;
- final double wP10x = w * P10x;
- final double ax = w * P20x - P20x;
- final double bx = P20x - 2 * wP10x;
+ final double p20x = x2 - x1;
+ final double p10x = cpX - x1;
+ final double wP10x = w * p10x;
+ final double ax = w * p20x - p20x;
+ final double bx = p20x - 2 * wP10x;
final double cx = wP10x;
int n = roots.findRoots(ax, bx, cx);
if (n != 0) {
@@ -449,11 +449,11 @@
maxY = math.max(maxY, extremaY);
}
}
- final double P20y = y2 - y1;
- final double P10y = cpY - y1;
- final double wP10y = w * P10y;
- final double a = w * P20y - P20y;
- final double b = P20y - 2 * wP10y;
+ final double p20y = y2 - y1;
+ final double p10y = cpY - y1;
+ final double wP10y = w * p10y;
+ final double a = w * p20y - p20y;
+ final double b = p20y - 2 * wP10y;
final double c = wP10y;
n = roots.findRoots(a, b, c);
diff --git a/lib/web_ui/lib/src/engine/html/path/path.dart b/lib/web_ui/lib/src/engine/html/path/path.dart
index fcc0f87..17fa23c 100644
--- a/lib/web_ui/lib/src/engine/html/path/path.dart
+++ b/lib/web_ui/lib/src/engine/html/path/path.dart
@@ -1270,7 +1270,7 @@
final int last = tangents.length - 1;
final ui.Offset tangent = tangents[last];
if (SPath.nearlyEqual(lengthSquaredOffset(tangent), 0)) {
- tangents.remove(last);
+ tangents.removeAt(last);
} else {
for (int index = 0; index < last; ++index) {
final ui.Offset test = tangents[index];
diff --git a/lib/web_ui/lib/src/engine/html/path/path_metrics.dart b/lib/web_ui/lib/src/engine/html/path/path_metrics.dart
index 8ab8b43..beb67f2 100644
--- a/lib/web_ui/lib/src/engine/html/path/path_metrics.dart
+++ b/lib/web_ui/lib/src/engine/html/path/path_metrics.dart
@@ -604,7 +604,7 @@
ui.Offset _normalizeSlope(double dx, double dy) {
final double length = math.sqrt(dx * dx + dy * dy);
return length < kEpsilon
- ? ui.Offset(0.0, 0.0)
+ ? const ui.Offset(0.0, 0.0)
: ui.Offset(dx / length, dy / length);
}
diff --git a/lib/web_ui/lib/src/engine/html/recording_canvas.dart b/lib/web_ui/lib/src/engine/html/recording_canvas.dart
index 973986f..4417723 100644
--- a/lib/web_ui/lib/src/engine/html/recording_canvas.dart
+++ b/lib/web_ui/lib/src/engine/html/recording_canvas.dart
@@ -1091,9 +1091,7 @@
@override
void apply(EngineCanvas canvas) {
- if (paint.style == null) {
- paint.style = ui.PaintingStyle.fill;
- }
+ paint.style ??= ui.PaintingStyle.fill;
canvas.drawPath(path!, paint);
}
diff --git a/lib/web_ui/lib/src/engine/html/render_vertices.dart b/lib/web_ui/lib/src/engine/html/render_vertices.dart
index baaf8ef..7034c39 100644
--- a/lib/web_ui/lib/src/engine/html/render_vertices.dart
+++ b/lib/web_ui/lib/src/engine/html/render_vertices.dart
@@ -223,7 +223,7 @@
// Buffer kBGRA_8888.
if (vertices.colors == null) {
- final ui.Color color = paint.color ?? ui.Color(0xFF000000);
+ final ui.Color color = paint.color ?? const ui.Color(0xFF000000);
final Uint32List vertexColors = Uint32List(vertexCount);
for (int i = 0; i < vertexCount; i++) {
vertexColors[i] = color.value;
diff --git a/lib/web_ui/lib/src/engine/html/shader_mask.dart b/lib/web_ui/lib/src/engine/html/shader_mask.dart
index c9192b9..29d00dc 100644
--- a/lib/web_ui/lib/src/engine/html/shader_mask.dart
+++ b/lib/web_ui/lib/src/engine/html/shader_mask.dart
@@ -230,11 +230,8 @@
case ui.BlendMode.luminosity:
case ui.BlendMode.multiply:
case ui.BlendMode.screen:
- case ui.BlendMode.overlay:
case ui.BlendMode.darken:
case ui.BlendMode.lighten:
- case ui.BlendMode.colorDodge:
- case ui.BlendMode.colorBurn:
case ui.BlendMode.hardLight:
case ui.BlendMode.softLight:
case ui.BlendMode.difference:
@@ -242,7 +239,6 @@
svgFilter = _blendImageToSvg(
imageUrl, stringForBlendMode(blendMode), width, height);
break;
- case ui.BlendMode.src:
case ui.BlendMode.dst:
case ui.BlendMode.dstATop:
case ui.BlendMode.dstIn:
diff --git a/lib/web_ui/lib/src/engine/html/shaders/normalized_gradient.dart b/lib/web_ui/lib/src/engine/html/shaders/normalized_gradient.dart
index 72e229f..a7f5b16 100644
--- a/lib/web_ui/lib/src/engine/html/shaders/normalized_gradient.dart
+++ b/lib/web_ui/lib/src/engine/html/shaders/normalized_gradient.dart
@@ -22,9 +22,6 @@
/// scale = (c2 - c1) / (t2 - t1)
/// bias = c1 - t1 / (t2 - t1) * (c2 - c1)
class NormalizedGradient {
- NormalizedGradient._(
- this.thresholdCount, this._thresholds, this._scale, this._bias);
-
final Float32List _thresholds;
final Float32List _bias;
final Float32List _scale;
@@ -100,6 +97,9 @@
return NormalizedGradient._(normalizedCount, thresholds, scale, bias);
}
+ NormalizedGradient._(
+ this.thresholdCount, this._thresholds, this._scale, this._bias);
+
/// Sets uniforms for threshold, bias and scale for program.
void setupUniforms(GlContext gl, GlProgram glProgram) {
for (int i = 0; i < thresholdCount; i++) {
diff --git a/lib/web_ui/lib/src/engine/html/shaders/shader.dart b/lib/web_ui/lib/src/engine/html/shaders/shader.dart
index 096948c..22c20b8 100644
--- a/lib/web_ui/lib/src/engine/html/shaders/shader.dart
+++ b/lib/web_ui/lib/src/engine/html/shaders/shader.dart
@@ -239,7 +239,7 @@
/// When creating an image to apply to a dom element, render
/// contents at 0,0 and adjust gradient vector for shaderBounds.
- final bool translateToOrigin = createDataUrl && shaderBounds != null;
+ final bool translateToOrigin = createDataUrl;
if (translateToOrigin) {
shaderBounds = shaderBounds.translate(-shaderBounds.left, -shaderBounds.top);
diff --git a/lib/web_ui/lib/src/engine/platform_dispatcher.dart b/lib/web_ui/lib/src/engine/platform_dispatcher.dart
index 65dd925..e2c921a 100644
--- a/lib/web_ui/lib/src/engine/platform_dispatcher.dart
+++ b/lib/web_ui/lib/src/engine/platform_dispatcher.dart
@@ -488,7 +488,7 @@
case 'flutter/accessibility':
// In widget tests we want to bypass processing of platform messages.
- final StandardMessageCodec codec = StandardMessageCodec();
+ const StandardMessageCodec codec = StandardMessageCodec();
accessibilityAnnouncements.handleMessage(codec, data);
replyToPlatformMessage(callback, codec.encodeMessage(true));
return;
diff --git a/lib/web_ui/lib/src/engine/platform_views/message_handler.dart b/lib/web_ui/lib/src/engine/platform_views/message_handler.dart
index c36ea8a..94ef036 100644
--- a/lib/web_ui/lib/src/engine/platform_views/message_handler.dart
+++ b/lib/web_ui/lib/src/engine/platform_views/message_handler.dart
@@ -38,7 +38,7 @@
/// some extra cleanup of its internal state, but it can do it automatically. See
/// [HtmlViewEmbedder.disposeViews]
class PlatformViewMessageHandler {
- final MethodCodec _codec = StandardMethodCodec();
+ final MethodCodec _codec = const StandardMethodCodec();
final PlatformViewManager _contentManager;
final PlatformViewContentHandler? _contentHandler;
diff --git a/lib/web_ui/lib/src/engine/semantics/text_field.dart b/lib/web_ui/lib/src/engine/semantics/text_field.dart
index 8aee1ae..0e3f4a7 100644
--- a/lib/web_ui/lib/src/engine/semantics/text_field.dart
+++ b/lib/web_ui/lib/src/engine/semantics/text_field.dart
@@ -49,12 +49,6 @@
/// Current input configuration supplied by the "flutter/textinput" channel.
InputConfiguration? inputConfig;
- @override
- OnChangeCallback? onChange;
-
- @override
- OnActionCallback? onAction;
-
/// The semantics implementation does not operate on DOM nodes, but only
/// remembers the config and callbacks. This is because the DOM nodes are
/// supplied in the semantics update and enabled by [activate].
@@ -258,7 +252,6 @@
case BrowserEngine.edge:
case BrowserEngine.ie11:
case BrowserEngine.firefox:
- case BrowserEngine.ie11:
case BrowserEngine.unknown:
_initializeForBlink();
break;
diff --git a/lib/web_ui/lib/src/engine/test_embedding.dart b/lib/web_ui/lib/src/engine/test_embedding.dart
index c8a4bf6..058c987 100644
--- a/lib/web_ui/lib/src/engine/test_embedding.dart
+++ b/lib/web_ui/lib/src/engine/test_embedding.dart
@@ -32,7 +32,7 @@
class TestUrlStrategy extends UrlStrategy {
/// Creates a instance of [TestUrlStrategy] with an empty string as the
/// path.
- factory TestUrlStrategy() => TestUrlStrategy.fromEntry(TestHistoryEntry(null, null, ''));
+ factory TestUrlStrategy() => TestUrlStrategy.fromEntry(const TestHistoryEntry(null, null, ''));
/// Creates an instance of [TestUrlStrategy] and populates it with a list
/// that has [initialEntry] as the only item.
diff --git a/lib/web_ui/lib/src/engine/text/layout_service.dart b/lib/web_ui/lib/src/engine/text/layout_service.dart
index 332acf9..57d3944 100644
--- a/lib/web_ui/lib/src/engine/text/layout_service.dart
+++ b/lib/web_ui/lib/src/engine/text/layout_service.dart
@@ -829,7 +829,7 @@
spanometer,
maxWidth: maxWidth,
lineNumber: 0,
- start: LineBreakResult.sameIndex(0, LineBreakType.prohibited),
+ start: const LineBreakResult.sameIndex(0, LineBreakType.prohibited),
accumulatedHeight: 0.0,
);
}
diff --git a/lib/web_ui/lib/src/engine/text/paragraph.dart b/lib/web_ui/lib/src/engine/text/paragraph.dart
index b325cd7..8f1f509 100644
--- a/lib/web_ui/lib/src/engine/text/paragraph.dart
+++ b/lib/web_ui/lib/src/engine/text/paragraph.dart
@@ -686,7 +686,7 @@
// [offset] is above all the lines.
if (offset.dy < 0) {
- return ui.TextPosition(
+ return const ui.TextPosition(
offset: 0,
affinity: ui.TextAffinity.downstream,
);
diff --git a/lib/web_ui/lib/src/engine/text/ruler.dart b/lib/web_ui/lib/src/engine/text/ruler.dart
index 2387bb4..dc12dbb 100644
--- a/lib/web_ui/lib/src/engine/text/ruler.dart
+++ b/lib/web_ui/lib/src/engine/text/ruler.dart
@@ -1058,7 +1058,7 @@
/// The text direction of the paragraph.
final ui.TextDirection textDirection;
- MeasurementResult(
+ const MeasurementResult(
this.constraintWidth, {
required this.isSingleLine,
required this.width,
diff --git a/lib/web_ui/lib/src/engine/text/text_direction.dart b/lib/web_ui/lib/src/engine/text/text_direction.dart
index 60eb0fb..782b0b6 100644
--- a/lib/web_ui/lib/src/engine/text/text_direction.dart
+++ b/lib/web_ui/lib/src/engine/text/text_direction.dart
@@ -13,39 +13,39 @@
final UnicodePropertyLookup<ui.TextDirection?> _textDirectionLookup = UnicodePropertyLookup<ui.TextDirection?>(
<UnicodeRange<ui.TextDirection>>[
// LTR
- UnicodeRange<ui.TextDirection>(kChar_A, kChar_Z, ui.TextDirection.ltr),
- UnicodeRange<ui.TextDirection>(kChar_a, kChar_z, ui.TextDirection.ltr),
- UnicodeRange<ui.TextDirection>(0x00C0, 0x00D6, ui.TextDirection.ltr),
- UnicodeRange<ui.TextDirection>(0x00D8, 0x00F6, ui.TextDirection.ltr),
- UnicodeRange<ui.TextDirection>(0x00F8, 0x02B8, ui.TextDirection.ltr),
- UnicodeRange<ui.TextDirection>(0x0300, 0x0590, ui.TextDirection.ltr),
+ const UnicodeRange<ui.TextDirection>(kChar_A, kChar_Z, ui.TextDirection.ltr),
+ const UnicodeRange<ui.TextDirection>(kChar_a, kChar_z, ui.TextDirection.ltr),
+ const UnicodeRange<ui.TextDirection>(0x00C0, 0x00D6, ui.TextDirection.ltr),
+ const UnicodeRange<ui.TextDirection>(0x00D8, 0x00F6, ui.TextDirection.ltr),
+ const UnicodeRange<ui.TextDirection>(0x00F8, 0x02B8, ui.TextDirection.ltr),
+ const UnicodeRange<ui.TextDirection>(0x0300, 0x0590, ui.TextDirection.ltr),
// RTL
- UnicodeRange<ui.TextDirection>(0x0591, 0x06EF, ui.TextDirection.rtl),
- UnicodeRange<ui.TextDirection>(0x06FA, 0x08FF, ui.TextDirection.rtl),
+ const UnicodeRange<ui.TextDirection>(0x0591, 0x06EF, ui.TextDirection.rtl),
+ const UnicodeRange<ui.TextDirection>(0x06FA, 0x08FF, ui.TextDirection.rtl),
// LTR
- UnicodeRange<ui.TextDirection>(0x0900, 0x1FFF, ui.TextDirection.ltr),
- UnicodeRange<ui.TextDirection>(0x200E, 0x200E, ui.TextDirection.ltr),
+ const UnicodeRange<ui.TextDirection>(0x0900, 0x1FFF, ui.TextDirection.ltr),
+ const UnicodeRange<ui.TextDirection>(0x200E, 0x200E, ui.TextDirection.ltr),
// RTL
- UnicodeRange<ui.TextDirection>(0x200F, 0x200F, ui.TextDirection.rtl),
+ const UnicodeRange<ui.TextDirection>(0x200F, 0x200F, ui.TextDirection.rtl),
// LTR
- UnicodeRange<ui.TextDirection>(0x2C00, 0xD801, ui.TextDirection.ltr),
+ const UnicodeRange<ui.TextDirection>(0x2C00, 0xD801, ui.TextDirection.ltr),
// RTL
- UnicodeRange<ui.TextDirection>(0xD802, 0xD803, ui.TextDirection.rtl),
+ const UnicodeRange<ui.TextDirection>(0xD802, 0xD803, ui.TextDirection.rtl),
// LTR
- UnicodeRange<ui.TextDirection>(0xD804, 0xD839, ui.TextDirection.ltr),
+ const UnicodeRange<ui.TextDirection>(0xD804, 0xD839, ui.TextDirection.ltr),
// RTL
- UnicodeRange<ui.TextDirection>(0xD83A, 0xD83B, ui.TextDirection.rtl),
+ const UnicodeRange<ui.TextDirection>(0xD83A, 0xD83B, ui.TextDirection.rtl),
// LTR
- UnicodeRange<ui.TextDirection>(0xD83C, 0xDBFF, ui.TextDirection.ltr),
- UnicodeRange<ui.TextDirection>(0xF900, 0xFB1C, ui.TextDirection.ltr),
+ const UnicodeRange<ui.TextDirection>(0xD83C, 0xDBFF, ui.TextDirection.ltr),
+ const UnicodeRange<ui.TextDirection>(0xF900, 0xFB1C, ui.TextDirection.ltr),
// RTL
- UnicodeRange<ui.TextDirection>(0xFB1D, 0xFDFF, ui.TextDirection.rtl),
+ const UnicodeRange<ui.TextDirection>(0xFB1D, 0xFDFF, ui.TextDirection.rtl),
// LTR
- UnicodeRange<ui.TextDirection>(0xFE00, 0xFE6F, ui.TextDirection.ltr),
+ const UnicodeRange<ui.TextDirection>(0xFE00, 0xFE6F, ui.TextDirection.ltr),
// RTL
- UnicodeRange<ui.TextDirection>(0xFE70, 0xFEFC, ui.TextDirection.rtl),
+ const UnicodeRange<ui.TextDirection>(0xFE70, 0xFEFC, ui.TextDirection.rtl),
// LTR
- UnicodeRange<ui.TextDirection>(0xFEFD, 0xFFFF, ui.TextDirection.ltr),
+ const UnicodeRange<ui.TextDirection>(0xFEFD, 0xFFFF, ui.TextDirection.ltr),
],
null,
);
diff --git a/lib/web_ui/lib/src/engine/text_editing/text_editing.dart b/lib/web_ui/lib/src/engine/text_editing/text_editing.dart
index 24af25e..a5cb3e4 100644
--- a/lib/web_ui/lib/src/engine/text_editing/text_editing.dart
+++ b/lib/web_ui/lib/src/engine/text_editing/text_editing.dart
@@ -1379,7 +1379,7 @@
/// Responds to the 'TextInput.setClient' message.
class TextInputSetClient extends TextInputCommand {
- TextInputSetClient({
+ const TextInputSetClient({
required this.clientId,
required this.configuration,
});
@@ -1421,7 +1421,7 @@
/// Responds to the 'TextInput.updateConfig' message.
class TextInputUpdateConfig extends TextInputCommand {
- TextInputUpdateConfig();
+ const TextInputUpdateConfig();
@override
void run(HybridTextEditing textEditing) {
@@ -1431,7 +1431,7 @@
/// Responds to the 'TextInput.setEditingState' message.
class TextInputSetEditingState extends TextInputCommand {
- TextInputSetEditingState({
+ const TextInputSetEditingState({
required this.state,
});
@@ -1457,7 +1457,7 @@
/// Responds to the 'TextInput.setEditableSizeAndTransform' message.
class TextInputSetEditableSizeAndTransform extends TextInputCommand {
- TextInputSetEditableSizeAndTransform({
+ const TextInputSetEditableSizeAndTransform({
required this.geometry,
});
@@ -1471,7 +1471,7 @@
/// Responds to the 'TextInput.setStyle' message.
class TextInputSetStyle extends TextInputCommand {
- TextInputSetStyle({
+ const TextInputSetStyle({
required this.style,
});
@@ -1536,7 +1536,7 @@
}
class TextInputFinishAutofillContext extends TextInputCommand {
- TextInputFinishAutofillContext({
+ const TextInputFinishAutofillContext({
required this.saveForm,
});
@@ -1607,7 +1607,7 @@
// field used to flush the command queue. However, delaye applying the
// configuration because the strategy may not be available yet.
implementation.configuration = InputConfiguration.fromFrameworkMessage(call.arguments);
- command = TextInputUpdateConfig();
+ command = const TextInputUpdateConfig();
break;
case 'TextInput.setEditingState':
@@ -1870,7 +1870,7 @@
/// message from the framework.
@immutable
class EditableTextGeometry {
- EditableTextGeometry({
+ const EditableTextGeometry({
required this.width,
required this.height,
required this.globalTransform,
diff --git a/lib/web_ui/lib/src/engine/ulps.dart b/lib/web_ui/lib/src/engine/ulps.dart
index dc3e3b4..58e5b2c 100644
--- a/lib/web_ui/lib/src/engine/ulps.dart
+++ b/lib/web_ui/lib/src/engine/ulps.dart
@@ -50,7 +50,6 @@
class _FloatBitConverter {
final Float32List float32List;
final Int32List int32List;
- _FloatBitConverter._(this.float32List, this.int32List);
factory _FloatBitConverter() {
final Float32List float32List = Float32List(1);
@@ -58,6 +57,8 @@
float32List, float32List.buffer.asInt32List(0, 1));
}
+ _FloatBitConverter._(this.float32List, this.int32List);
+
int toInt(Float32List source, int index) {
float32List[0] = source[index];
return int32List[0];
diff --git a/lib/web_ui/lib/src/engine/window.dart b/lib/web_ui/lib/src/engine/window.dart
index 2ac0b97..540ed1b 100644
--- a/lib/web_ui/lib/src/engine/window.dart
+++ b/lib/web_ui/lib/src/engine/window.dart
@@ -47,7 +47,7 @@
final EnginePlatformDispatcher engineDispatcher =
platformDispatcher as EnginePlatformDispatcher;
engineDispatcher.windows[_windowId] = this;
- engineDispatcher.windowConfigurations[_windowId] = ui.ViewConfiguration();
+ engineDispatcher.windowConfigurations[_windowId] = const ui.ViewConfiguration();
if (_isUrlStrategySet) {
_browserHistory =
MultiEntriesBrowserHistory(urlStrategy: _customUrlStrategy);
@@ -151,7 +151,7 @@
Future<bool> handleNavigationMessage(ByteData? data) async {
return _waitInTheLine(() async {
- final MethodCall decoded = JSONMethodCodec().decodeMethodCall(data);
+ final MethodCall decoded = const JSONMethodCodec().decodeMethodCall(data);
final Map<String, dynamic>? arguments = decoded.arguments;
switch (decoded.method) {
case 'selectMultiEntryHistory':
@@ -185,7 +185,7 @@
platformDispatcher as EnginePlatformDispatcher;
assert(engineDispatcher.windowConfigurations.containsKey(_windowId));
return engineDispatcher.windowConfigurations[_windowId] ??
- ui.ViewConfiguration();
+ const ui.ViewConfiguration();
}
@override
@@ -338,7 +338,7 @@
UrlStrategy? _createDefaultUrlStrategy() {
return ui.debugEmulateFlutterTesterEnvironment
- ? TestUrlStrategy.fromEntry(TestHistoryEntry('default', null, '/'))
+ ? TestUrlStrategy.fromEntry(const TestHistoryEntry('default', null, '/'))
: const HashUrlStrategy();
}
@@ -378,7 +378,7 @@
platformDispatcher as EnginePlatformDispatcher;
assert(engineDispatcher.windowConfigurations.containsKey(_viewId));
return engineDispatcher.windowConfigurations[_viewId] ??
- ui.ViewConfiguration();
+ const ui.ViewConfiguration();
}
}
diff --git a/lib/web_ui/lib/src/ui/initialization.dart b/lib/web_ui/lib/src/ui/initialization.dart
index a429745..13662b6 100644
--- a/lib/web_ui/lib/src/ui/initialization.dart
+++ b/lib/web_ui/lib/src/ui/initialization.dart
@@ -47,8 +47,9 @@
bool _webOnlyIsInitialized = false;
bool get webOnlyIsInitialized => _webOnlyIsInitialized;
Future<void> webOnlySetAssetManager(engine.AssetManager assetManager) async {
+ // ignore: unnecessary_null_comparison
assert(assetManager != null,
- 'Cannot set assetManager to null'); // ignore: unnecessary_null_comparison
+ 'Cannot set assetManager to null');
if (assetManager == _assetManager) {
return;
}
diff --git a/lib/web_ui/test/canvaskit/backdrop_filter_golden_test.dart b/lib/web_ui/test/canvaskit/backdrop_filter_golden_test.dart
index a08430d..08dc492 100644
--- a/lib/web_ui/test/canvaskit/backdrop_filter_golden_test.dart
+++ b/lib/web_ui/test/canvaskit/backdrop_filter_golden_test.dart
@@ -26,7 +26,7 @@
// Make a checkerboard picture so we can see the blur.
final CkPictureRecorder recorder = CkPictureRecorder();
final CkCanvas canvas = recorder.beginRecording(region);
- canvas.drawColor(ui.Color(0xffffffff), ui.BlendMode.srcOver);
+ canvas.drawColor(const ui.Color(0xffffffff), ui.BlendMode.srcOver);
final double sideLength = region.width / 20;
final int rows = (region.height / sideLength).ceil();
@@ -40,7 +40,7 @@
sideLength,
sideLength,
);
- canvas.drawRect(rect, CkPaint()..color = ui.Color(0xffff0000));
+ canvas.drawRect(rect, CkPaint()..color = const ui.Color(0xffff0000));
}
}
final CkPicture checkerboard = recorder.endRecording();
diff --git a/lib/web_ui/test/canvaskit/canvas_golden_test.dart b/lib/web_ui/test/canvaskit/canvas_golden_test.dart
index d5e4b1d..d4109c7 100644
--- a/lib/web_ui/test/canvaskit/canvas_golden_test.dart
+++ b/lib/web_ui/test/canvaskit/canvas_golden_test.dart
@@ -86,7 +86,7 @@
final SkPicture restoredSkPicture = snapshot!.toPicture();
expect(restoredSkPicture, isNotNull);
final CkPicture restoredPicture = CkPicture(
- restoredSkPicture, ui.Rect.fromLTRB(0, 0, 50, 50), snapshot);
+ restoredSkPicture, const ui.Rect.fromLTRB(0, 0, 50, 50), snapshot);
final ByteData restoredPixels =
(await (await restoredPicture.toImage(50, 50)).toByteData())!;
@@ -118,7 +118,7 @@
canvas.save();
for (int col = 0; col < 10; col += 1) {
final double elevation = 2 * (col % 5).toDouble();
- canvas.drawShadow(shape, ui.Color(0xFFFF0000), elevation, true);
+ canvas.drawShadow(shape, const ui.Color(0xFFFF0000), elevation, true);
canvas.drawPath(shape, shapePaint);
final PhysicalShapeEngineLayer psl = PhysicalShapeEngineLayer(
@@ -284,7 +284,7 @@
await testTextStyle('paragraph text height behavior',
layoutWidth: 50,
paragraphHeight: 1.5,
- paragraphTextHeightBehavior: ui.TextHeightBehavior(
+ paragraphTextHeightBehavior: const ui.TextHeightBehavior(
applyHeightToFirstAscent: false,
applyHeightToLastDescent: false,
));
@@ -408,7 +408,7 @@
'half leading inherited from paragraph',
height: 20,
fontSize: 10,
- paragraphTextHeightBehavior: ui.TextHeightBehavior(
+ paragraphTextHeightBehavior: const ui.TextHeightBehavior(
leadingDistribution: ui.TextLeadingDistribution.even,
),
);
@@ -417,7 +417,7 @@
height: 20,
fontSize: 10,
leadingDistribution: ui.TextLeadingDistribution.proportional,
- paragraphTextHeightBehavior: ui.TextHeightBehavior(
+ paragraphTextHeightBehavior: const ui.TextHeightBehavior(
leadingDistribution: ui.TextLeadingDistribution.even,
),
);
@@ -483,14 +483,14 @@
test('text styles - shadows', () async {
await testTextStyle('shadows', shadows: <ui.Shadow>[
- ui.Shadow(
- color: const ui.Color(0xFF999900),
- offset: const ui.Offset(10, 10),
+ const ui.Shadow(
+ color: ui.Color(0xFF999900),
+ offset: ui.Offset(10, 10),
blurRadius: 5,
),
- ui.Shadow(
- color: const ui.Color(0xFF009999),
- offset: const ui.Offset(-10, -10),
+ const ui.Shadow(
+ color: ui.Color(0xFF009999),
+ offset: ui.Offset(-10, -10),
blurRadius: 10,
),
]);
@@ -621,24 +621,24 @@
}
builder.addText(text.toString());
final CkParagraph paragraph = builder.build();
- paragraph.layout(ui.ParagraphConstraints(width: testWidth));
+ paragraph.layout(const ui.ParagraphConstraints(width: testWidth));
return paragraph;
}
final List<ParagraphFactory> variations = <ParagraphFactory>[
() => createTestParagraph(),
- () => createTestParagraph(color: ui.Color(0xFF009900)),
+ () => createTestParagraph(color: const ui.Color(0xFF009900)),
() => createTestParagraph(
- foreground: CkPaint()..color = ui.Color(0xFF990000)),
+ foreground: CkPaint()..color = const ui.Color(0xFF990000)),
() => createTestParagraph(
- background: CkPaint()..color = ui.Color(0xFF7777FF)),
+ background: CkPaint()..color = const ui.Color(0xFF7777FF)),
() => createTestParagraph(
- color: ui.Color(0xFFFF00FF),
- background: CkPaint()..color = ui.Color(0xFF0000FF),
+ color: const ui.Color(0xFFFF00FF),
+ background: CkPaint()..color = const ui.Color(0xFF0000FF),
),
() => createTestParagraph(
- foreground: CkPaint()..color = ui.Color(0xFF00FFFF),
- background: CkPaint()..color = ui.Color(0xFF0000FF),
+ foreground: CkPaint()..color = const ui.Color(0xFF00FFFF),
+ background: CkPaint()..color = const ui.Color(0xFF0000FF),
),
];
@@ -655,7 +655,7 @@
final ui.Offset leftEnd = ui.Offset(
fromParagraph.maxIntrinsicWidth + 10, fromParagraph.height / 2);
final ui.Offset rightEnd = ui.Offset(middle - 10, leftEnd.dy);
- final ui.Offset tipOffset = ui.Offset(-5, -5);
+ const ui.Offset tipOffset = ui.Offset(-5, -5);
canvas.drawLine(leftEnd, rightEnd, CkPaint());
canvas.drawLine(rightEnd, rightEnd + tipOffset, CkPaint());
canvas.drawLine(
@@ -672,7 +672,7 @@
await matchPictureGolden(
'canvaskit_text_styles_do_not_leak.png',
picture,
- region: ui.Rect.fromLTRB(0, 0, testWidth, 850),
+ region: const ui.Rect.fromLTRB(0, 0, testWidth, 850),
);
});
@@ -806,8 +806,8 @@
// First draw a frame with a red rectangle
final CkPictureRecorder recorder = CkPictureRecorder();
final CkCanvas canvas = recorder.beginRecording(ui.Rect.largest);
- canvas.drawRect(ui.Rect.fromLTRB(20, 20, 100, 100),
- CkPaint()..color = ui.Color(0xffff0000));
+ canvas.drawRect(const ui.Rect.fromLTRB(20, 20, 100, 100),
+ CkPaint()..color = const ui.Color(0xffff0000));
final CkPicture picture = recorder.endRecording();
final LayerSceneBuilder builder = LayerSceneBuilder();
builder.pushOffset(0, 0);
@@ -823,7 +823,7 @@
EnginePlatformDispatcher.instance.rasterizer!.draw(emptyLayerTree);
await matchGoldenFile('canvaskit_empty_scene.png',
- region: ui.Rect.fromLTRB(0, 0, 100, 100));
+ region: const ui.Rect.fromLTRB(0, 0, 100, 100));
});
// TODO: https://github.com/flutter/flutter/issues/60040
// TODO: https://github.com/flutter/flutter/issues/71520
@@ -845,7 +845,7 @@
));
paragraphBuilder.addText(text);
final CkParagraph paragraph = paragraphBuilder.build();
- paragraph.layout(ui.ParagraphConstraints(width: testWidth - 20));
+ paragraph.layout(const ui.ParagraphConstraints(width: testWidth - 20));
canvas.drawParagraph(paragraph, const ui.Offset(10, 10));
paragraphHeight = paragraph.height;
return recorder.endRecording();
@@ -863,7 +863,7 @@
typedef ParagraphFactory = CkParagraph Function();
void drawTestPicture(CkCanvas canvas) {
- canvas.clear(ui.Color(0xFFFFFFF));
+ canvas.clear(const ui.Color(0xFFFFFFF));
canvas.translate(10, 10);
@@ -872,12 +872,12 @@
canvas.save();
canvas.clipRect(
- ui.Rect.fromLTRB(0, 0, 45, 45),
+ const ui.Rect.fromLTRB(0, 0, 45, 45),
ui.ClipOp.intersect,
true,
);
canvas.clipRRect(
- ui.RRect.fromLTRBR(5, 5, 50, 50, ui.Radius.circular(8)),
+ ui.RRect.fromLTRBR(5, 5, 50, 50, const ui.Radius.circular(8)),
true,
);
canvas.clipPath(
@@ -889,23 +889,23 @@
..close(),
true,
);
- canvas.drawColor(ui.Color.fromARGB(255, 100, 100, 0), ui.BlendMode.srcOver);
+ canvas.drawColor(const ui.Color.fromARGB(255, 100, 100, 0), ui.BlendMode.srcOver);
canvas.restore(); // remove clips
canvas.translate(60, 0);
canvas.drawCircle(
const ui.Offset(30, 25),
15,
- CkPaint()..color = ui.Color(0xFF0000AA),
+ CkPaint()..color = const ui.Color(0xFF0000AA),
);
canvas.translate(60, 0);
canvas.drawArc(
- ui.Rect.fromLTRB(10, 20, 50, 40),
+ const ui.Rect.fromLTRB(10, 20, 50, 40),
math.pi / 4,
3 * math.pi / 2,
true,
- CkPaint()..color = ui.Color(0xFF00AA00),
+ CkPaint()..color = const ui.Color(0xFF00AA00),
);
canvas.translate(60, 0);
@@ -943,24 +943,24 @@
canvas.translate(60, 0);
canvas.drawDRRect(
- ui.RRect.fromLTRBR(0, 0, 40, 30, ui.Radius.elliptical(16, 8)),
- ui.RRect.fromLTRBR(10, 10, 30, 20, ui.Radius.elliptical(4, 8)),
+ ui.RRect.fromLTRBR(0, 0, 40, 30, const ui.Radius.elliptical(16, 8)),
+ ui.RRect.fromLTRBR(10, 10, 30, 20, const ui.Radius.elliptical(4, 8)),
CkPaint(),
);
canvas.translate(60, 0);
canvas.drawImageRect(
generateTestImage(),
- ui.Rect.fromLTRB(0, 0, 15, 15),
- ui.Rect.fromLTRB(10, 10, 40, 40),
+ const ui.Rect.fromLTRB(0, 0, 15, 15),
+ const ui.Rect.fromLTRB(10, 10, 40, 40),
CkPaint(),
);
canvas.translate(60, 0);
canvas.drawImageNine(
generateTestImage(),
- ui.Rect.fromLTRB(5, 5, 15, 15),
- ui.Rect.fromLTRB(10, 10, 50, 40),
+ const ui.Rect.fromLTRB(5, 5, 15, 15),
+ const ui.Rect.fromLTRB(10, 10, 50, 40),
CkPaint(),
);
@@ -970,29 +970,29 @@
canvas.translate(0, 60);
canvas.save();
- canvas.drawLine(ui.Offset(0, 0), ui.Offset(40, 30), CkPaint());
+ canvas.drawLine(const ui.Offset(0, 0), const ui.Offset(40, 30), CkPaint());
canvas.translate(60, 0);
canvas.drawOval(
- ui.Rect.fromLTRB(0, 0, 40, 30),
+ const ui.Rect.fromLTRB(0, 0, 40, 30),
CkPaint(),
);
canvas.translate(60, 0);
canvas.save();
- canvas.clipRect(ui.Rect.fromLTRB(0, 0, 50, 30), ui.ClipOp.intersect, true);
- canvas.drawPaint(CkPaint()..color = ui.Color(0xFF6688AA));
+ canvas.clipRect(const ui.Rect.fromLTRB(0, 0, 50, 30), ui.ClipOp.intersect, true);
+ canvas.drawPaint(CkPaint()..color = const ui.Color(0xFF6688AA));
canvas.restore();
canvas.translate(60, 0);
{
final CkPictureRecorder otherRecorder = CkPictureRecorder();
final CkCanvas otherCanvas =
- otherRecorder.beginRecording(ui.Rect.fromLTRB(0, 0, 40, 20));
+ otherRecorder.beginRecording(const ui.Rect.fromLTRB(0, 0, 40, 20));
otherCanvas.drawCircle(
- ui.Offset(30, 15),
+ const ui.Offset(30, 15),
10,
- CkPaint()..color = ui.Color(0xFFAABBCC),
+ CkPaint()..color = const ui.Color(0xFFAABBCC),
);
canvas.drawPicture(otherRecorder.endRecording());
}
@@ -1004,11 +1004,11 @@
// will ensure it's fixed when we have the fix.
canvas.drawPoints(
CkPaint()
- ..color = ui.Color(0xFF0000FF)
+ ..color = const ui.Color(0xFF0000FF)
..strokeWidth = 5
..strokeCap = ui.StrokeCap.round,
ui.PointMode.polygon,
- offsetListToFloat32List(<ui.Offset>[
+ offsetListToFloat32List(const <ui.Offset>[
ui.Offset(10, 10),
ui.Offset(20, 10),
ui.Offset(30, 20),
@@ -1018,20 +1018,20 @@
canvas.translate(60, 0);
canvas.drawRRect(
- ui.RRect.fromLTRBR(0, 0, 40, 30, ui.Radius.circular(10)),
+ ui.RRect.fromLTRBR(0, 0, 40, 30, const ui.Radius.circular(10)),
CkPaint(),
);
canvas.translate(60, 0);
canvas.drawRect(
- ui.Rect.fromLTRB(0, 0, 40, 30),
+ const ui.Rect.fromLTRB(0, 0, 40, 30),
CkPaint(),
);
canvas.translate(60, 0);
canvas.drawShadow(
- CkPath()..addRect(ui.Rect.fromLTRB(0, 0, 40, 30)),
- ui.Color(0xFF00FF00),
+ CkPath()..addRect(const ui.Rect.fromLTRB(0, 0, 40, 30)),
+ const ui.Color(0xFF00FF00),
4,
true,
);
@@ -1045,7 +1045,7 @@
canvas.drawVertices(
CkVertices(
ui.VertexMode.triangleFan,
- <ui.Offset>[
+ const <ui.Offset>[
ui.Offset(10, 30),
ui.Offset(30, 50),
ui.Offset(10, 60),
@@ -1063,44 +1063,44 @@
canvas.drawCircle(ui.Offset.zero, 5, CkPaint());
}
canvas.restoreToCount(restorePoint);
- canvas.drawCircle(ui.Offset.zero, 7, CkPaint()..color = ui.Color(0xFFFF0000));
+ canvas.drawCircle(ui.Offset.zero, 7, CkPaint()..color = const ui.Color(0xFFFF0000));
canvas.translate(60, 0);
- canvas.drawLine(ui.Offset.zero, ui.Offset(30, 30), CkPaint());
+ canvas.drawLine(ui.Offset.zero, const ui.Offset(30, 30), CkPaint());
canvas.save();
canvas.rotate(-math.pi / 8);
- canvas.drawLine(ui.Offset.zero, ui.Offset(30, 30), CkPaint());
+ canvas.drawLine(ui.Offset.zero, const ui.Offset(30, 30), CkPaint());
canvas.drawCircle(
- ui.Offset(30, 30), 7, CkPaint()..color = ui.Color(0xFF00AA00));
+ const ui.Offset(30, 30), 7, CkPaint()..color = const ui.Color(0xFF00AA00));
canvas.restore();
canvas.translate(60, 0);
final CkPaint thickStroke = CkPaint()
..style = ui.PaintingStyle.stroke
..strokeWidth = 20;
- final CkPaint semitransparent = CkPaint()..color = ui.Color(0x66000000);
+ final CkPaint semitransparent = CkPaint()..color = const ui.Color(0x66000000);
canvas.saveLayer(kDefaultRegion, semitransparent);
- canvas.drawLine(ui.Offset(10, 10), ui.Offset(50, 50), thickStroke);
- canvas.drawLine(ui.Offset(50, 10), ui.Offset(10, 50), thickStroke);
+ canvas.drawLine(const ui.Offset(10, 10), const ui.Offset(50, 50), thickStroke);
+ canvas.drawLine(const ui.Offset(50, 10), const ui.Offset(10, 50), thickStroke);
canvas.restore();
canvas.translate(60, 0);
canvas.saveLayerWithoutBounds(semitransparent);
- canvas.drawLine(ui.Offset(10, 10), ui.Offset(50, 50), thickStroke);
- canvas.drawLine(ui.Offset(50, 10), ui.Offset(10, 50), thickStroke);
+ canvas.drawLine(const ui.Offset(10, 10), const ui.Offset(50, 50), thickStroke);
+ canvas.drawLine(const ui.Offset(50, 10), const ui.Offset(10, 50), thickStroke);
canvas.restore();
// To test saveLayerWithFilter we draw three circles with only the middle one
// blurred using the layer image filter.
canvas.translate(60, 0);
canvas.saveLayer(kDefaultRegion, CkPaint());
- canvas.drawCircle(ui.Offset(30, 30), 10, CkPaint());
+ canvas.drawCircle(const ui.Offset(30, 30), 10, CkPaint());
{
canvas.saveLayerWithFilter(
kDefaultRegion, ui.ImageFilter.blur(sigmaX: 5, sigmaY: 10));
- canvas.drawCircle(ui.Offset(10, 10), 10, CkPaint());
- canvas.drawCircle(ui.Offset(50, 50), 10, CkPaint());
+ canvas.drawCircle(const ui.Offset(10, 10), 10, CkPaint());
+ canvas.drawCircle(const ui.Offset(50, 50), 10, CkPaint());
canvas.restore();
}
canvas.restore();
@@ -1116,7 +1116,7 @@
canvas.save();
canvas.translate(30, 30);
canvas.skew(2, 1.5);
- canvas.drawRect(ui.Rect.fromLTRB(-10, -10, 10, 10), CkPaint());
+ canvas.drawRect(const ui.Rect.fromLTRB(-10, -10, 10, 10), CkPaint());
canvas.restore();
canvas.restore();
@@ -1141,15 +1141,15 @@
fontSize: 18,
));
pb.pushStyle(CkTextStyle(
- color: ui.Color(0xFF0000AA),
+ color: const ui.Color(0xFF0000AA),
));
pb.addText('Hello');
pb.pop();
final CkParagraph p = pb.build();
- p.layout(ui.ParagraphConstraints(width: 1000));
+ p.layout(const ui.ParagraphConstraints(width: 1000));
canvas.drawParagraph(
p,
- ui.Offset(10, 20),
+ const ui.Offset(10, 20),
);
canvas.translate(60, 0);
@@ -1159,7 +1159,7 @@
..lineTo(50, 50)
..lineTo(10, 50)
..close(),
- CkPaint()..color = ui.Color(0xFF0000AA),
+ CkPaint()..color = const ui.Color(0xFF0000AA),
);
canvas.restore();
@@ -1265,8 +1265,8 @@
descriptionBuilder.addText(name);
final CkParagraph descriptionParagraph = descriptionBuilder.build();
descriptionParagraph
- .layout(ui.ParagraphConstraints(width: testWidth / 2 - 70));
- final ui.Offset descriptionOffset = ui.Offset(testWidth / 2 + 30, 0);
+ .layout(const ui.ParagraphConstraints(width: testWidth / 2 - 70));
+ const ui.Offset descriptionOffset = ui.Offset(testWidth / 2 + 30, 0);
canvas.drawParagraph(descriptionParagraph, descriptionOffset);
final CkParagraphBuilder pb = CkParagraphBuilder(CkParagraphStyle(
diff --git a/lib/web_ui/test/canvaskit/canvaskit_api_test.dart b/lib/web_ui/test/canvaskit/canvaskit_api_test.dart
index e048627..826f5f5 100644
--- a/lib/web_ui/test/canvaskit/canvaskit_api_test.dart
+++ b/lib/web_ui/test/canvaskit/canvaskit_api_test.dart
@@ -219,13 +219,13 @@
test('Path.combine test', () {
final ui.Path path1 = ui.Path();
expect(path1, isA<CkPath>());
- path1.addRect(ui.Rect.fromLTRB(0, 0, 10, 10));
- path1.addOval(ui.Rect.fromLTRB(10, 10, 100, 100));
+ path1.addRect(const ui.Rect.fromLTRB(0, 0, 10, 10));
+ path1.addOval(const ui.Rect.fromLTRB(10, 10, 100, 100));
final ui.Path path2 = ui.Path();
expect(path2, isA<CkPath>());
- path2.addRect(ui.Rect.fromLTRB(5, 5, 15, 15));
- path2.addOval(ui.Rect.fromLTRB(15, 15, 105, 105));
+ path2.addRect(const ui.Rect.fromLTRB(5, 5, 15, 15));
+ path2.addOval(const ui.Rect.fromLTRB(15, 15, 105, 105));
final ui.Path union = ui.Path.combine(ui.PathOperation.union, path1, path2);
expect(union, isA<CkPath>());
@@ -594,12 +594,12 @@
void _toSkRectTests() {
test('toSkRect', () {
- expect(toSkRect(ui.Rect.fromLTRB(1, 2, 3, 4)), <double>[1, 2, 3, 4]);
+ expect(toSkRect(const ui.Rect.fromLTRB(1, 2, 3, 4)), <double>[1, 2, 3, 4]);
});
test('fromSkRect', () {
expect(fromSkRect(Float32List.fromList(<double>[1, 2, 3, 4])),
- ui.Rect.fromLTRB(1, 2, 3, 4));
+ const ui.Rect.fromLTRB(1, 2, 3, 4));
});
test('toSkRRect', () {
@@ -609,10 +609,10 @@
2,
3,
4,
- topLeft: ui.Radius.elliptical(5, 6),
- topRight: ui.Radius.elliptical(7, 8),
- bottomRight: ui.Radius.elliptical(9, 10),
- bottomLeft: ui.Radius.elliptical(11, 12),
+ topLeft: const ui.Radius.elliptical(5, 6),
+ topRight: const ui.Radius.elliptical(7, 8),
+ bottomRight: const ui.Radius.elliptical(9, 10),
+ bottomLeft: const ui.Radius.elliptical(11, 12),
)),
<double>[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
);
@@ -641,7 +641,7 @@
test('addArc', () {
path.addArc(
- toSkRect(ui.Rect.fromLTRB(10, 20, 30, 40)),
+ toSkRect(const ui.Rect.fromLTRB(10, 20, 30, 40)),
1,
5,
);
@@ -649,7 +649,7 @@
test('addOval', () {
path.addOval(
- toSkRect(ui.Rect.fromLTRB(10, 20, 30, 40)),
+ toSkRect(const ui.Rect.fromLTRB(10, 20, 30, 40)),
false,
1,
);
@@ -670,8 +670,8 @@
test('addRRect', () {
final ui.RRect rrect = ui.RRect.fromRectAndRadius(
- ui.Rect.fromLTRB(10, 10, 20, 20),
- ui.Radius.circular(3),
+ const ui.Rect.fromLTRB(10, 10, 20, 20),
+ const ui.Radius.circular(3),
);
path.addRRect(
toSkRRect(rrect),
@@ -680,12 +680,12 @@
});
test('addRect', () {
- path.addRect(toSkRect(ui.Rect.fromLTRB(1, 2, 3, 4)));
+ path.addRect(toSkRect(const ui.Rect.fromLTRB(1, 2, 3, 4)));
});
test('arcTo', () {
path.arcToOval(
- toSkRect(ui.Rect.fromLTRB(1, 2, 3, 4)),
+ toSkRect(const ui.Rect.fromLTRB(1, 2, 3, 4)),
5,
40,
false,
@@ -800,7 +800,7 @@
path = _testClosedSkPath();
path.transform(2, 0, 10, 0, 2, 10, 0, 0, 0);
final ui.Rect transformedBounds = fromSkRect(path.getBounds());
- expect(transformedBounds, ui.Rect.fromLTRB(30, 30, 50, 50));
+ expect(transformedBounds, const ui.Rect.fromLTRB(30, 30, 50, 50));
});
test('SkContourMeasureIter/SkContourMeasure', () {
@@ -835,7 +835,7 @@
// | |
// 20 +-----------+
final SkPath segment = measure1.getSegment(5, 15, true);
- expect(fromSkRect(segment.getBounds()), ui.Rect.fromLTRB(15, 10, 20, 15));
+ expect(fromSkRect(segment.getBounds()), const ui.Rect.fromLTRB(15, 10, 20, 15));
final SkContourMeasure? measure2 = iter.next();
expect(measure2, isNull);
@@ -881,7 +881,7 @@
setUp(() {
recorder = SkPictureRecorder();
canvas =
- recorder.beginRecording(toSkRect(ui.Rect.fromLTRB(0, 0, 100, 100)));
+ recorder.beginRecording(toSkRect(const ui.Rect.fromLTRB(0, 0, 100, 100)));
});
tearDown(() {
@@ -903,7 +903,7 @@
test('saveLayer', () {
canvas.saveLayer(
SkPaint(),
- toSkRect(ui.Rect.fromLTRB(0, 0, 100, 100)),
+ toSkRect(const ui.Rect.fromLTRB(0, 0, 100, 100)),
null,
null,
);
@@ -916,7 +916,7 @@
test('saveLayer with filter', () {
canvas.saveLayer(
SkPaint(),
- toSkRect(ui.Rect.fromLTRB(0, 0, 100, 100)),
+ toSkRect(const ui.Rect.fromLTRB(0, 0, 100, 100)),
canvasKit.ImageFilter.MakeBlur(1, 2, canvasKit.TileMode.Repeat, null),
0,
);
@@ -1442,28 +1442,28 @@
test('TextHeightBehavior', () {
expect(
- toSkTextHeightBehavior(ui.TextHeightBehavior(
+ toSkTextHeightBehavior(const ui.TextHeightBehavior(
applyHeightToFirstAscent: true,
applyHeightToLastDescent: true,
)),
canvasKit.TextHeightBehavior.All,
);
expect(
- toSkTextHeightBehavior(ui.TextHeightBehavior(
+ toSkTextHeightBehavior(const ui.TextHeightBehavior(
applyHeightToFirstAscent: false,
applyHeightToLastDescent: true,
)),
canvasKit.TextHeightBehavior.DisableFirstAscent,
);
expect(
- toSkTextHeightBehavior(ui.TextHeightBehavior(
+ toSkTextHeightBehavior(const ui.TextHeightBehavior(
applyHeightToFirstAscent: true,
applyHeightToLastDescent: false,
)),
canvasKit.TextHeightBehavior.DisableLastDescent,
);
expect(
- toSkTextHeightBehavior(ui.TextHeightBehavior(
+ toSkTextHeightBehavior(const ui.TextHeightBehavior(
applyHeightToFirstAscent: false,
applyHeightToLastDescent: false,
)),
diff --git a/lib/web_ui/test/canvaskit/color_filter_golden_test.dart b/lib/web_ui/test/canvaskit/color_filter_golden_test.dart
index 1b9431c..31bda23 100644
--- a/lib/web_ui/test/canvaskit/color_filter_golden_test.dart
+++ b/lib/web_ui/test/canvaskit/color_filter_golden_test.dart
@@ -39,16 +39,16 @@
final CkCanvas canvas = recorder.beginRecording(region);
canvas.drawCircle(
- ui.Offset(75, 125),
+ const ui.Offset(75, 125),
50,
- CkPaint()..color = ui.Color.fromARGB(255, 255, 0, 0),
+ CkPaint()..color = const ui.Color.fromARGB(255, 255, 0, 0),
);
final CkPicture redCircle = recorder.endRecording();
builder.addPicture(ui.Offset.zero, redCircle);
// Apply a "greyscale" color filter.
- builder.pushColorFilter(ui.ColorFilter.matrix(<double>[
+ builder.pushColorFilter(const ui.ColorFilter.matrix(<double>[
0.2126, 0.7152, 0.0722, 0, 0, //
0.2126, 0.7152, 0.0722, 0, 0, //
0.2126, 0.7152, 0.0722, 0, 0, //
@@ -61,9 +61,9 @@
final CkCanvas canvas2 = recorder2.beginRecording(region);
canvas2.drawCircle(
- ui.Offset(425, 125),
+ const ui.Offset(425, 125),
50,
- CkPaint()..color = ui.Color.fromARGB(255, 255, 0, 0),
+ CkPaint()..color = const ui.Color.fromARGB(255, 255, 0, 0),
);
final CkPicture greyCircle = recorder2.endRecording();
diff --git a/lib/web_ui/test/canvaskit/embedded_views_test.dart b/lib/web_ui/test/canvaskit/embedded_views_test.dart
index f036b69..025bc3c 100644
--- a/lib/web_ui/test/canvaskit/embedded_views_test.dart
+++ b/lib/web_ui/test/canvaskit/embedded_views_test.dart
@@ -71,7 +71,7 @@
ui.window.platformDispatcher as EnginePlatformDispatcher;
final LayerSceneBuilder sb = LayerSceneBuilder();
sb.pushOffset(0, 0);
- sb.pushClipRRect(ui.RRect.fromLTRBR(0, 0, 10, 10, ui.Radius.circular(3)));
+ sb.pushClipRRect(ui.RRect.fromLTRBR(0, 0, 10, 10, const ui.Radius.circular(3)));
sb.addPlatformView(0, width: 10, height: 10);
dispatcher.rasterizer!.draw(sb.build().layerTree);
@@ -204,8 +204,8 @@
test('renders overlays on top of platform views', () async {
expect(SurfaceFactory.instance.debugCacheSize, 0);
final CkPicture testPicture =
- paintPicture(ui.Rect.fromLTRB(0, 0, 10, 10), (CkCanvas canvas) {
- canvas.drawCircle(ui.Offset(5, 5), 5, CkPaint());
+ paintPicture(const ui.Rect.fromLTRB(0, 0, 10, 10), (CkCanvas canvas) {
+ canvas.drawCircle(const ui.Offset(5, 5), 5, CkPaint());
});
// Initialize all platform views to be used in the test.
@@ -284,7 +284,7 @@
// Render: deleted platform views.
// Expect: error.
for (final int id in platformViewIds) {
- final StandardMethodCodec codec = StandardMethodCodec();
+ const StandardMethodCodec codec = StandardMethodCodec();
final Completer<void> completer = Completer<void>();
ui.window.sendPlatformMessage(
'flutter/platform_views',
@@ -427,7 +427,7 @@
final LayerSceneBuilder sb = LayerSceneBuilder();
sb.pushOffset(0, 0);
sb.pushClipRRect(
- ui.RRect.fromLTRBR(0, 0, 10, 10, ui.Radius.circular(3)));
+ ui.RRect.fromLTRBR(0, 0, 10, 10, const ui.Radius.circular(3)));
sb.addPlatformView(0, width: 10, height: 10);
dispatcher.rasterizer!.draw(sb.build().layerTree);
}
diff --git a/lib/web_ui/test/canvaskit/fallback_fonts_golden_test.dart b/lib/web_ui/test/canvaskit/fallback_fonts_golden_test.dart
index baf6a8c..120eb00 100644
--- a/lib/web_ui/test/canvaskit/fallback_fonts_golden_test.dart
+++ b/lib/web_ui/test/canvaskit/fallback_fonts_golden_test.dart
@@ -96,9 +96,9 @@
pb.addText('مرØبا');
pb.pop();
final CkParagraph paragraph = pb.build();
- paragraph.layout(ui.ParagraphConstraints(width: 1000));
+ paragraph.layout(const ui.ParagraphConstraints(width: 1000));
- canvas.drawParagraph(paragraph, ui.Offset(0, 0));
+ canvas.drawParagraph(paragraph, const ui.Offset(0, 0));
await matchPictureGolden(
'canvaskit_font_fallback_arabic.png', recorder.endRecording());
@@ -153,7 +153,7 @@
pb.addText('Hello 😊 مرØبا');
pb.pop();
final CkParagraph paragraph = pb.build();
- paragraph.layout(ui.ParagraphConstraints(width: 1000));
+ paragraph.layout(const ui.ParagraphConstraints(width: 1000));
EnginePlatformDispatcher.instance.rasterizer!
.debugRunPostFrameCallbacks();
@@ -203,9 +203,9 @@
pb.addText('Hello 😊');
pb.pop();
final CkParagraph paragraph = pb.build();
- paragraph.layout(ui.ParagraphConstraints(width: 1000));
+ paragraph.layout(const ui.ParagraphConstraints(width: 1000));
- canvas.drawParagraph(paragraph, ui.Offset(0, 0));
+ canvas.drawParagraph(paragraph, const ui.Offset(0, 0));
await matchPictureGolden(
'canvaskit_font_fallback_emoji.png', recorder.endRecording());
diff --git a/lib/web_ui/test/canvaskit/filter_test.dart b/lib/web_ui/test/canvaskit/filter_test.dart
index 35fe300..ad2634b 100644
--- a/lib/web_ui/test/canvaskit/filter_test.dart
+++ b/lib/web_ui/test/canvaskit/filter_test.dart
@@ -17,10 +17,10 @@
void testMain() {
List<CkColorFilter> createColorFilters() {
return <CkColorFilter>[
- EngineColorFilter.mode(ui.Color(0x12345678), ui.BlendMode.srcOver) as CkColorFilter,
- EngineColorFilter.mode(ui.Color(0x12345678), ui.BlendMode.dstOver) as CkColorFilter,
- EngineColorFilter.mode(ui.Color(0x87654321), ui.BlendMode.dstOver) as CkColorFilter,
- EngineColorFilter.matrix(<double>[
+ const EngineColorFilter.mode(ui.Color(0x12345678), ui.BlendMode.srcOver) as CkColorFilter,
+ const EngineColorFilter.mode(ui.Color(0x12345678), ui.BlendMode.dstOver) as CkColorFilter,
+ const EngineColorFilter.mode(ui.Color(0x87654321), ui.BlendMode.dstOver) as CkColorFilter,
+ const EngineColorFilter.matrix(<double>[
1, 0, 0, 0, 0,
0, 1, 0, 0, 0,
0, 0, 1, 0, 0,
@@ -32,8 +32,8 @@
0, 0, 2, 0, 0,
0, 0, 0, 2, 0,
])) as CkColorFilter,
- EngineColorFilter.linearToSrgbGamma() as CkColorFilter,
- EngineColorFilter.srgbToLinearGamma() as CkColorFilter,
+ const EngineColorFilter.linearToSrgbGamma() as CkColorFilter,
+ const EngineColorFilter.srgbToLinearGamma() as CkColorFilter,
];
}
@@ -97,7 +97,7 @@
test('with 0 sigma can be set on a Paint', () {
final ui.Paint paint = ui.Paint();
- final ui.MaskFilter filter = ui.MaskFilter.blur(ui.BlurStyle.normal, 0);
+ const ui.MaskFilter filter = ui.MaskFilter.blur(ui.BlurStyle.normal, 0);
expect(() => paint.maskFilter = filter, isNot(throwsException));
});
diff --git a/lib/web_ui/test/canvaskit/interval_tree_test.dart b/lib/web_ui/test/canvaskit/interval_tree_test.dart
index a497d0c..39eb3ff 100644
--- a/lib/web_ui/test/canvaskit/interval_tree_test.dart
+++ b/lib/web_ui/test/canvaskit/interval_tree_test.dart
@@ -14,8 +14,8 @@
group('$IntervalTree', () {
test('is balanced', () {
final Map<String, List<CodeunitRange>> ranges = <String, List<CodeunitRange>>{
- 'A': <CodeunitRange>[CodeunitRange(0, 5), CodeunitRange(6, 10)],
- 'B': <CodeunitRange>[CodeunitRange(4, 6)],
+ 'A': const <CodeunitRange>[CodeunitRange(0, 5), CodeunitRange(6, 10)],
+ 'B': const <CodeunitRange>[CodeunitRange(4, 6)],
};
// Should create a balanced 3-node tree with a root with a left and right
@@ -31,7 +31,7 @@
// Should create a balanced 15-node tree (4 layers deep).
final Map<String, List<CodeunitRange>> ranges2 = <String, List<CodeunitRange>>{
- 'A': <CodeunitRange>[
+ 'A': const <CodeunitRange>[
CodeunitRange(1, 1),
CodeunitRange(2, 2),
CodeunitRange(3, 3),
@@ -67,8 +67,8 @@
test('finds values whose intervals overlap with a given point', () {
final Map<String, List<CodeunitRange>> ranges = <String, List<CodeunitRange>>{
- 'A': <CodeunitRange>[CodeunitRange(0, 5), CodeunitRange(7, 10)],
- 'B': <CodeunitRange>[CodeunitRange(4, 6)],
+ 'A': const <CodeunitRange>[CodeunitRange(0, 5), CodeunitRange(7, 10)],
+ 'B': const <CodeunitRange>[CodeunitRange(4, 6)],
};
final IntervalTree<String> tree = IntervalTree<String>.createFromRanges(ranges);
diff --git a/lib/web_ui/test/canvaskit/layer_test.dart b/lib/web_ui/test/canvaskit/layer_test.dart
index 4c77464..245e098 100644
--- a/lib/web_ui/test/canvaskit/layer_test.dart
+++ b/lib/web_ui/test/canvaskit/layer_test.dart
@@ -25,13 +25,13 @@
ui.window.platformDispatcher as EnginePlatformDispatcher;
final CkPicture picture =
- paintPicture(ui.Rect.fromLTRB(0, 0, 60, 60), (CkCanvas canvas) {
- canvas.drawRect(ui.Rect.fromLTRB(0, 0, 60, 60),
+ paintPicture(const ui.Rect.fromLTRB(0, 0, 60, 60), (CkCanvas canvas) {
+ canvas.drawRect(const ui.Rect.fromLTRB(0, 0, 60, 60),
CkPaint()..style = ui.PaintingStyle.fill);
});
final LayerSceneBuilder sb = LayerSceneBuilder();
- sb.pushClipRect(ui.Rect.fromLTRB(15, 15, 30, 30));
+ sb.pushClipRect(const ui.Rect.fromLTRB(15, 15, 30, 30));
// Intentionally use a perspective transform, which triggered the
// https://github.com/flutter/flutter/issues/63715 bug.
@@ -44,10 +44,10 @@
final LayerTree layerTree = sb.build().layerTree;
dispatcher.rasterizer!.draw(layerTree);
final ClipRectEngineLayer clipRect = layerTree.rootLayer.debugLayers.single as ClipRectEngineLayer;
- expect(clipRect.paintBounds, ui.Rect.fromLTRB(15, 15, 30, 30));
+ expect(clipRect.paintBounds, const ui.Rect.fromLTRB(15, 15, 30, 30));
final TransformEngineLayer transform = clipRect.debugLayers.single as TransformEngineLayer;
- expect(transform.paintBounds, ui.Rect.fromLTRB(0, 0, 30, 30));
+ expect(transform.paintBounds, const ui.Rect.fromLTRB(0, 0, 30, 30));
});
test('can push a leaf layer without a container layer', () async {
diff --git a/lib/web_ui/test/canvaskit/linear_gradient_golden_test.dart b/lib/web_ui/test/canvaskit/linear_gradient_golden_test.dart
index 8b9b835..1551438 100644
--- a/lib/web_ui/test/canvaskit/linear_gradient_golden_test.dart
+++ b/lib/web_ui/test/canvaskit/linear_gradient_golden_test.dart
@@ -41,14 +41,14 @@
final CkGradientLinear gradient = CkGradientLinear(
ui.Offset(region.left + region.width / 4, region.height / 2),
ui.Offset(region.right - region.width / 8, region.height / 2),
- <ui.Color>[
+ const <ui.Color>[
ui.Color(0xFF4285F4),
ui.Color(0xFF34A853),
ui.Color(0xFFFBBC05),
ui.Color(0xFFEA4335),
ui.Color(0xFF4285F4),
],
- <double>[
+ const <double>[
0.0,
0.25,
0.5,
@@ -75,14 +75,14 @@
final CkGradientLinear gradient = CkGradientLinear(
ui.Offset(region.left + region.width / 4, region.height / 2),
ui.Offset(region.right - region.width / 8, region.height / 2),
- <ui.Color>[
+ const <ui.Color>[
ui.Color(0xFF4285F4),
ui.Color(0xFF34A853),
ui.Color(0xFFFBBC05),
ui.Color(0xFFEA4335),
ui.Color(0xFF4285F4),
],
- <double>[
+ const <double>[
0.0,
0.25,
0.5,
diff --git a/lib/web_ui/test/canvaskit/path_test.dart b/lib/web_ui/test/canvaskit/path_test.dart
index 006ec20..d89bc68 100644
--- a/lib/web_ui/test/canvaskit/path_test.dart
+++ b/lib/web_ui/test/canvaskit/path_test.dart
@@ -27,22 +27,22 @@
expect(path, isA<CkPath>());
expect(path.computeMetrics().length, 0);
- path.addRect(ui.Rect.fromLTRB(0, 0, 10, 10));
+ path.addRect(const ui.Rect.fromLTRB(0, 0, 10, 10));
final ui.PathMetric metric = path.computeMetrics().single;
expect(metric.contourIndex, 0);
expect(metric.extractPath(0, 0.5).computeMetrics().length, 1);
final ui.Tangent tangent1 = metric.getTangentForOffset(5)!;
- expect(tangent1.position, ui.Offset(5, 0));
- expect(tangent1.vector, ui.Offset(1, 0));
+ expect(tangent1.position, const ui.Offset(5, 0));
+ expect(tangent1.vector, const ui.Offset(1, 0));
final ui.Tangent tangent2 = metric.getTangentForOffset(15)!;
- expect(tangent2.position, ui.Offset(10, 5));
- expect(tangent2.vector, ui.Offset(0, 1));
+ expect(tangent2.position, const ui.Offset(10, 5));
+ expect(tangent2.vector, const ui.Offset(0, 1));
expect(metric.isClosed, isTrue);
- path.addOval(ui.Rect.fromLTRB(10, 10, 100, 100));
+ path.addOval(const ui.Rect.fromLTRB(10, 10, 100, 100));
expect(path.computeMetrics().length, 2);
// Path metrics can be iterated over multiple times.
@@ -99,9 +99,9 @@
browserSupportsFinalizationRegistry = false;
final ui.Path path = ui.Path();
expect(path, isA<CkPath>());
- path.addRect(ui.Rect.fromLTRB(0, 0, 10, 10));
- path.addRect(ui.Rect.fromLTRB(20, 20, 30, 30));
- path.addRect(ui.Rect.fromLTRB(40, 40, 50, 50));
+ path.addRect(const ui.Rect.fromLTRB(0, 0, 10, 10));
+ path.addRect(const ui.Rect.fromLTRB(20, 20, 30, 30));
+ path.addRect(const ui.Rect.fromLTRB(40, 40, 50, 50));
final ui.PathMetrics metrics = path.computeMetrics();
final CkContourMeasureIter iterator = metrics.iterator as CkContourMeasureIter;
@@ -125,9 +125,9 @@
browserSupportsFinalizationRegistry = false;
final ui.Path path = ui.Path();
expect(path, isA<CkPath>());
- path.addRect(ui.Rect.fromLTRB(0, 0, 10, 10));
- path.addRect(ui.Rect.fromLTRB(20, 20, 30, 30));
- path.addRect(ui.Rect.fromLTRB(40, 40, 50, 50));
+ path.addRect(const ui.Rect.fromLTRB(0, 0, 10, 10));
+ path.addRect(const ui.Rect.fromLTRB(20, 20, 30, 30));
+ path.addRect(const ui.Rect.fromLTRB(40, 40, 50, 50));
final ui.PathMetrics metrics = path.computeMetrics();
final CkContourMeasureIter iterator = metrics.iterator as CkContourMeasureIter;
@@ -135,12 +135,12 @@
expect(iterator.moveNext(), isTrue);
final CkContourMeasure measure0 = iterator.current as CkContourMeasure;
expect(measure0.contourIndex, 0);
- expect(measure0.extractPath(0, 15).getBounds(), ui.Rect.fromLTRB(0, 0, 10, 5));
+ expect(measure0.extractPath(0, 15).getBounds(), const ui.Rect.fromLTRB(0, 0, 10, 5));
expect(iterator.moveNext(), isTrue);
final CkContourMeasure measure1 = iterator.current as CkContourMeasure;
expect(measure1.contourIndex, 1);
- expect(measure1.extractPath(0, 15).getBounds(), ui.Rect.fromLTRB(20, 20, 30, 25));
+ expect(measure1.extractPath(0, 15).getBounds(), const ui.Rect.fromLTRB(20, 20, 30, 25));
// Delete iterator and the measure in the middle of iteration
iterator.delete();
@@ -152,14 +152,14 @@
// Check that the measure is still value after resurrection.
expect(measure0.contourIndex, 0);
- expect(measure0.extractPath(0, 15).getBounds(), ui.Rect.fromLTRB(0, 0, 10, 5));
+ expect(measure0.extractPath(0, 15).getBounds(), const ui.Rect.fromLTRB(0, 0, 10, 5));
expect(measure1.contourIndex, 1);
- expect(measure1.extractPath(0, 15).getBounds(), ui.Rect.fromLTRB(20, 20, 30, 25));
+ expect(measure1.extractPath(0, 15).getBounds(), const ui.Rect.fromLTRB(20, 20, 30, 25));
});
test('Path.from', () {
- final ui.Rect rect1 = ui.Rect.fromLTRB(0, 0, 10, 10);
- final ui.Rect rect2 = ui.Rect.fromLTRB(10, 10, 20, 20);
+ const ui.Rect rect1 = ui.Rect.fromLTRB(0, 0, 10, 10);
+ const ui.Rect rect2 = ui.Rect.fromLTRB(10, 10, 20, 20);
final ui.Path original = ui.Path();
original.addRect(rect1);
diff --git a/lib/web_ui/test/canvaskit/platform_dispatcher_test.dart b/lib/web_ui/test/canvaskit/platform_dispatcher_test.dart
index c7ffdd4..3a6619a 100644
--- a/lib/web_ui/test/canvaskit/platform_dispatcher_test.dart
+++ b/lib/web_ui/test/canvaskit/platform_dispatcher_test.dart
@@ -26,7 +26,7 @@
final Completer<ByteData?> completer = Completer<ByteData?>();
ui.PlatformDispatcher.instance.sendPlatformMessage(
'flutter/skia',
- codec.encodeMethodCall(MethodCall(
+ codec.encodeMethodCall(const MethodCall(
'Skia.setResourceCacheMaxBytes',
512 * 1000 * 1000,
)),
diff --git a/lib/web_ui/test/canvaskit/scene_test.dart b/lib/web_ui/test/canvaskit/scene_test.dart
index 52a766a..1fe148c 100644
--- a/lib/web_ui/test/canvaskit/scene_test.dart
+++ b/lib/web_ui/test/canvaskit/scene_test.dart
@@ -29,10 +29,10 @@
final ui.Paint paint = ui.Paint();
expect(paint, isA<CkPaint>());
- paint.color = ui.Color.fromARGB(255, 255, 0, 0);
+ paint.color = const ui.Color.fromARGB(255, 255, 0, 0);
// Draw a red circle.
- canvas.drawCircle(ui.Offset(20, 20), 10, paint);
+ canvas.drawCircle(const ui.Offset(20, 20), 10, paint);
final ui.Picture picture = recorder.endRecording();
expect(picture, isA<CkPicture>());
@@ -41,7 +41,7 @@
expect(builder, isA<LayerSceneBuilder>());
builder.pushOffset(0, 0);
- builder.addPicture(ui.Offset(0, 0), picture);
+ builder.addPicture(const ui.Offset(0, 0), picture);
final ui.Scene scene = builder.build();
@@ -54,7 +54,7 @@
expect(builder, isA<LayerSceneBuilder>());
builder.pushOffset(0, 0);
- builder.pushColorFilter(ui.ColorFilter.srgbToLinearGamma());
+ builder.pushColorFilter(const ui.ColorFilter.srgbToLinearGamma());
final ui.Scene scene = builder.build();
expect(scene, isNotNull);
diff --git a/lib/web_ui/test/canvaskit/shader_mask_golden_test.dart b/lib/web_ui/test/canvaskit/shader_mask_golden_test.dart
index 7f136f0..001e136 100644
--- a/lib/web_ui/test/canvaskit/shader_mask_golden_test.dart
+++ b/lib/web_ui/test/canvaskit/shader_mask_golden_test.dart
@@ -40,24 +40,24 @@
final CkCanvas canvas = recorder.beginRecording(region);
canvas.drawCircle(
- ui.Offset(425, 125),
+ const ui.Offset(425, 125),
50,
- CkPaint()..color = ui.Color.fromARGB(255, 255, 0, 0),
+ CkPaint()..color = const ui.Color.fromARGB(255, 255, 0, 0),
);
final CkPicture redCircle = recorder.endRecording();
builder.addPicture(ui.Offset.zero, redCircle);
final CkGradientSweep shader = CkGradientSweep(
- ui.Offset(250, 125),
- <ui.Color>[
+ const ui.Offset(250, 125),
+ const <ui.Color>[
ui.Color(0xFF4285F4),
ui.Color(0xFF34A853),
ui.Color(0xFFFBBC05),
ui.Color(0xFFEA4335),
ui.Color(0xFF4285F4),
],
- <double>[
+ const <double>[
0.0,
0.25,
0.5,
@@ -70,11 +70,11 @@
null);
final ui.Path clipPath = ui.Path()
- ..addOval(ui.Rect.fromLTWH(25, 75, 100, 100));
+ ..addOval(const ui.Rect.fromLTWH(25, 75, 100, 100));
builder.pushClipPath(clipPath);
// Apply a shader mask.
- builder.pushShaderMask(shader, ui.Rect.fromLTRB(0, 0, 200, 250),
+ builder.pushShaderMask(shader, const ui.Rect.fromLTRB(0, 0, 200, 250),
ui.BlendMode.color);
// Draw another red circle and apply it to the scene.
@@ -82,8 +82,8 @@
final CkPictureRecorder recorder2 = CkPictureRecorder();
final CkCanvas canvas2 = recorder2.beginRecording(region);
- canvas2.drawRect(ui.Rect.fromLTWH(25, 75, 100, 100),
- CkPaint()..color = ui.Color.fromARGB(255, 0, 255, 0),
+ canvas2.drawRect(const ui.Rect.fromLTWH(25, 75, 100, 100),
+ CkPaint()..color = const ui.Color.fromARGB(255, 0, 255, 0),
);
final CkPicture sweepCircle = recorder2.endRecording();
@@ -105,24 +105,24 @@
final CkCanvas canvas = recorder.beginRecording(region);
canvas.drawCircle(
- ui.Offset(425, 125),
+ const ui.Offset(425, 125),
50,
- CkPaint()..color = ui.Color.fromARGB(255, 255, 0, 0),
+ CkPaint()..color = const ui.Color.fromARGB(255, 255, 0, 0),
);
final CkPicture redCircle = recorder.endRecording();
builder.addPicture(ui.Offset.zero, redCircle);
final CkGradientSweep shader = CkGradientSweep(
- ui.Offset(250, 125),
- <ui.Color>[
+ const ui.Offset(250, 125),
+ const <ui.Color>[
ui.Color(0xFF4285F4),
ui.Color(0xFF34A853),
ui.Color(0xFFFBBC05),
ui.Color(0xFFEA4335),
ui.Color(0xFF4285F4),
],
- <double>[
+ const <double>[
0.0,
0.25,
0.5,
@@ -135,11 +135,11 @@
null);
final ui.Path clipPath = ui.Path()
- ..addOval(ui.Rect.fromLTWH(25, 75, 100, 100));
+ ..addOval(const ui.Rect.fromLTWH(25, 75, 100, 100));
builder.pushClipPath(clipPath);
// Apply a shader mask.
- builder.pushShaderMask(shader, ui.Rect.fromLTRB(50, 50, 200, 250),
+ builder.pushShaderMask(shader, const ui.Rect.fromLTRB(50, 50, 200, 250),
ui.BlendMode.color);
// Draw another red circle and apply it to the scene.
@@ -147,8 +147,8 @@
final CkPictureRecorder recorder2 = CkPictureRecorder();
final CkCanvas canvas2 = recorder2.beginRecording(region);
- canvas2.drawRect(ui.Rect.fromLTWH(25, 75, 100, 100),
- CkPaint()..color = ui.Color.fromARGB(255, 0, 255, 0),
+ canvas2.drawRect(const ui.Rect.fromLTWH(25, 75, 100, 100),
+ CkPaint()..color = const ui.Color.fromARGB(255, 0, 255, 0),
);
final CkPicture sweepCircle = recorder2.endRecording();
diff --git a/lib/web_ui/test/canvaskit/skia_objects_cache_test.dart b/lib/web_ui/test/canvaskit/skia_objects_cache_test.dart
index bb59284..47ed663 100644
--- a/lib/web_ui/test/canvaskit/skia_objects_cache_test.dart
+++ b/lib/web_ui/test/canvaskit/skia_objects_cache_test.dart
@@ -141,8 +141,7 @@
expect(
spy.printLog,
<String>[
- 'Engine counters:\n'
- ' TestSkDeletable created: 1\n'
+ 'Engine counters:\n TestSkDeletable created: 1\n'
],
);
@@ -168,9 +167,7 @@
expect(
spy.printLog,
<String>[
- 'Engine counters:\n'
- ' TestSkDeletable created: 1\n'
- ' TestSkDeletable deleted: 1\n'
+ 'Engine counters:\n TestSkDeletable created: 1\n TestSkDeletable deleted: 1\n'
],
);
Instrumentation.enabled = false;
diff --git a/lib/web_ui/test/canvaskit/surface_test.dart b/lib/web_ui/test/canvaskit/surface_test.dart
index 115db58..8c0fccb 100644
--- a/lib/web_ui/test/canvaskit/surface_test.dart
+++ b/lib/web_ui/test/canvaskit/surface_test.dart
@@ -25,7 +25,7 @@
test('Surface allocates canvases efficiently', () {
final Surface surface = SurfaceFactory.instance.getSurface();
final CkSurface originalSurface =
- surface.acquireFrame(ui.Size(9, 19)).skiaSurface;
+ surface.acquireFrame(const ui.Size(9, 19)).skiaSurface;
final html.CanvasElement original = surface.htmlCanvas!;
// Expect exact requested dimensions.
@@ -38,7 +38,7 @@
// Shrinking reuses the existing canvas straight-up.
final CkSurface shrunkSurface =
- surface.acquireFrame(ui.Size(5, 15)).skiaSurface;
+ surface.acquireFrame(const ui.Size(5, 15)).skiaSurface;
final html.CanvasElement shrunk = surface.htmlCanvas!;
expect(shrunk, same(original));
expect(shrunk.style.width, '9px');
@@ -50,7 +50,7 @@
// The first increase will allocate a new canvas, but will overallocate
// by 40% to accommodate future increases.
final CkSurface firstIncreaseSurface =
- surface.acquireFrame(ui.Size(10, 20)).skiaSurface;
+ surface.acquireFrame(const ui.Size(10, 20)).skiaSurface;
final html.CanvasElement firstIncrease = surface.htmlCanvas!;
expect(firstIncrease, isNot(same(original)));
expect(firstIncreaseSurface, isNot(same(shrunkSurface)));
@@ -65,7 +65,7 @@
// Subsequent increases within 40% reuse the old canvas.
final CkSurface secondIncreaseSurface =
- surface.acquireFrame(ui.Size(11, 22)).skiaSurface;
+ surface.acquireFrame(const ui.Size(11, 22)).skiaSurface;
final html.CanvasElement secondIncrease = surface.htmlCanvas!;
expect(secondIncrease, same(firstIncrease));
expect(secondIncreaseSurface, isNot(same(firstIncreaseSurface)));
@@ -73,7 +73,7 @@
expect(secondIncreaseSurface.height(), 22);
// Increases beyond the 40% limit will cause a new allocation.
- final CkSurface hugeSurface = surface.acquireFrame(ui.Size(20, 40)).skiaSurface;
+ final CkSurface hugeSurface = surface.acquireFrame(const ui.Size(20, 40)).skiaSurface;
final html.CanvasElement huge = surface.htmlCanvas!;
expect(huge, isNot(same(secondIncrease)));
expect(hugeSurface, isNot(same(secondIncreaseSurface)));
@@ -88,7 +88,7 @@
// Shrink again. Reuse the last allocated surface.
final CkSurface shrunkSurface2 =
- surface.acquireFrame(ui.Size(5, 15)).skiaSurface;
+ surface.acquireFrame(const ui.Size(5, 15)).skiaSurface;
final html.CanvasElement shrunk2 = surface.htmlCanvas!;
expect(shrunk2, same(huge));
expect(shrunkSurface2, isNot(same(hugeSurface)));
@@ -107,13 +107,13 @@
final Surface surface = SurfaceFactory.instance.getSurface();
expect(surface.debugForceNewContext, isTrue);
final CkSurface before =
- surface.acquireFrame(ui.Size(9, 19)).skiaSurface;
+ surface.acquireFrame(const ui.Size(9, 19)).skiaSurface;
expect(surface.debugForceNewContext, isFalse);
// Pump a timer to flush any microtasks.
await Future<void>.delayed(Duration.zero);
final CkSurface afterAcquireFrame =
- surface.acquireFrame(ui.Size(9, 19)).skiaSurface;
+ surface.acquireFrame(const ui.Size(9, 19)).skiaSurface;
// Existing context is reused.
expect(afterAcquireFrame, same(before));
@@ -140,7 +140,7 @@
expect(surface.debugForceNewContext, isTrue);
final CkSurface afterContextLost =
- surface.acquireFrame(ui.Size(9, 19)).skiaSurface;
+ surface.acquireFrame(const ui.Size(9, 19)).skiaSurface;
// A new context is created.
expect(afterContextLost, isNot(same(before)));
},
@@ -152,7 +152,7 @@
test('updates canvas logical size when device-pixel ratio changes', () {
final Surface surface = Surface();
final CkSurface original =
- surface.acquireFrame(ui.Size(10, 16)).skiaSurface;
+ surface.acquireFrame(const ui.Size(10, 16)).skiaSurface;
expect(original.width(), 10);
expect(original.height(), 16);
@@ -163,7 +163,7 @@
// fewer of them to cover the browser window.
window.debugOverrideDevicePixelRatio(2.0);
final CkSurface highDpr =
- surface.acquireFrame(ui.Size(10, 16)).skiaSurface;
+ surface.acquireFrame(const ui.Size(10, 16)).skiaSurface;
expect(highDpr.width(), 10);
expect(highDpr.height(), 16);
expect(surface.htmlCanvas!.style.width, '5px');
@@ -173,7 +173,7 @@
// more of them to cover the browser window.
window.debugOverrideDevicePixelRatio(0.5);
final CkSurface lowDpr =
- surface.acquireFrame(ui.Size(10, 16)).skiaSurface;
+ surface.acquireFrame(const ui.Size(10, 16)).skiaSurface;
expect(lowDpr.width(), 10);
expect(lowDpr.height(), 16);
expect(surface.htmlCanvas!.style.width, '20px');
diff --git a/lib/web_ui/test/canvaskit/sweep_gradient_golden_test.dart b/lib/web_ui/test/canvaskit/sweep_gradient_golden_test.dart
index 0b6a7a3..2100180 100644
--- a/lib/web_ui/test/canvaskit/sweep_gradient_golden_test.dart
+++ b/lib/web_ui/test/canvaskit/sweep_gradient_golden_test.dart
@@ -39,15 +39,15 @@
final CkCanvas canvas = recorder.beginRecording(region);
final CkGradientSweep gradient = CkGradientSweep(
- ui.Offset(250, 125),
- <ui.Color>[
+ const ui.Offset(250, 125),
+ const <ui.Color>[
ui.Color(0xFF4285F4),
ui.Color(0xFF34A853),
ui.Color(0xFFFBBC05),
ui.Color(0xFFEA4335),
ui.Color(0xFF4285F4),
],
- <double>[
+ const <double>[
0.0,
0.25,
0.5,
diff --git a/lib/web_ui/test/canvaskit/text_test.dart b/lib/web_ui/test/canvaskit/text_test.dart
index 0cc643b..11b6b4c 100644
--- a/lib/web_ui/test/canvaskit/text_test.dart
+++ b/lib/web_ui/test/canvaskit/text_test.dart
@@ -20,22 +20,22 @@
final ui.TextStyle textStyleWithShadows = ui.TextStyle(
fontSize: 16,
shadows: <ui.Shadow>[
- ui.Shadow(
+ const ui.Shadow(
color: ui.Color.fromARGB(255, 0, 0, 0),
blurRadius: 3.0,
offset: ui.Offset(3.0, 3.0),
),
- ui.Shadow(
+ const ui.Shadow(
color: ui.Color.fromARGB(255, 0, 0, 0),
blurRadius: 3.0,
offset: ui.Offset(-3.0, 3.0),
),
- ui.Shadow(
+ const ui.Shadow(
color: ui.Color.fromARGB(255, 0, 0, 0),
blurRadius: 3.0,
offset: ui.Offset(3.0, -3.0),
),
- ui.Shadow(
+ const ui.Shadow(
color: ui.Color.fromARGB(255, 0, 0, 0),
blurRadius: 3.0,
offset: ui.Offset(-3.0, -3.0),
diff --git a/lib/web_ui/test/canvaskit/vertices_test.dart b/lib/web_ui/test/canvaskit/vertices_test.dart
index 42c6bdf..6182dff 100644
--- a/lib/web_ui/test/canvaskit/vertices_test.dart
+++ b/lib/web_ui/test/canvaskit/vertices_test.dart
@@ -39,17 +39,17 @@
CkVertices _testVertices() {
return ui.Vertices(
ui.VertexMode.triangles,
- <ui.Offset>[
+ const <ui.Offset>[
ui.Offset(0, 0),
ui.Offset(10, 10),
ui.Offset(0, 20),
],
- textureCoordinates: <ui.Offset>[
+ textureCoordinates: const <ui.Offset>[
ui.Offset(0, 0),
ui.Offset(10, 10),
ui.Offset(0, 20),
],
- colors: <ui.Color>[
+ colors: const <ui.Color>[
ui.Color.fromRGBO(255, 0, 0, 1.0),
ui.Color.fromRGBO(0, 255, 0, 1.0),
ui.Color.fromRGBO(0, 0, 255, 1.0),
diff --git a/lib/web_ui/test/clipboard_test.dart b/lib/web_ui/test/clipboard_test.dart
index 78172a7..2dcd505 100644
--- a/lib/web_ui/test/clipboard_test.dart
+++ b/lib/web_ui/test/clipboard_test.dart
@@ -69,7 +69,7 @@
final ByteData result = await completer.future;
expect(
() =>codec.decodeEnvelope(result),
- throwsA(TypeMatcher<PlatformException>()
+ throwsA(const TypeMatcher<PlatformException>()
.having((PlatformException e) => e.code, 'code', equals('copy_fail'))));
});
diff --git a/lib/web_ui/test/color_test.dart b/lib/web_ui/test/color_test.dart
index 8141af5..c03ea01 100644
--- a/lib/web_ui/test/color_test.dart
+++ b/lib/web_ui/test/color_test.dart
@@ -45,7 +45,7 @@
test('two colors are only == if they have the same runtime type', () {
expect(const Color(123), equals(const Color(123)));
expect(const Color(123),
- equals(Color(123)));
+ equals(const Color(123)));
expect(const Color(123), isNot(equals(const Color(321))));
expect(const Color(123), isNot(equals(const NotAColor(123))));
expect(const NotAColor(123), isNot(equals(const Color(123))));
@@ -137,14 +137,14 @@
// Regression test for https://github.com/flutter/flutter/issues/41257
// CupertinoDynamicColor was overriding base class and calling super(0).
test('subclass of Color can override value', () {
- final DynamicColorClass color = DynamicColorClass(0xF0E0D0C0);
+ const DynamicColorClass color = DynamicColorClass(0xF0E0D0C0);
expect(color.value, 0xF0E0D0C0);
// Call base class member, make sure it uses overridden value.
expect(color.red, 0xE0);
});
test('Paint converts Color subclasses to plain Color', () {
- final DynamicColorClass color = DynamicColorClass(0xF0E0D0C0);
+ const DynamicColorClass color = DynamicColorClass(0xF0E0D0C0);
final Paint paint = Paint()..color = color;
expect(paint.color.runtimeType, Color);
});
diff --git a/lib/web_ui/test/engine/history_test.dart b/lib/web_ui/test/engine/history_test.dart
index 3739ec4..531e8bd 100644
--- a/lib/web_ui/test/engine/history_test.dart
+++ b/lib/web_ui/test/engine/history_test.dart
@@ -53,7 +53,7 @@
test('basic setup works', () async {
final TestUrlStrategy strategy = TestUrlStrategy.fromEntry(
- TestHistoryEntry('initial state', null, '/initial'),
+ const TestHistoryEntry('initial state', null, '/initial'),
);
await window.debugInitializeHistory(strategy, useSingle: true);
@@ -79,7 +79,7 @@
test('browser back button pops routes correctly', () async {
final TestUrlStrategy strategy = TestUrlStrategy.fromEntry(
- TestHistoryEntry(null, null, '/home'),
+ const TestHistoryEntry(null, null, '/home'),
);
await window.debugInitializeHistory(strategy, useSingle: true);
@@ -116,7 +116,7 @@
test('multiple browser back clicks', () async {
final TestUrlStrategy strategy = TestUrlStrategy.fromEntry(
- TestHistoryEntry(null, null, '/home'),
+ const TestHistoryEntry(null, null, '/home'),
);
await window.debugInitializeHistory(strategy, useSingle: true);
@@ -185,7 +185,7 @@
test('handle user-provided url', () async {
final TestUrlStrategy strategy = TestUrlStrategy.fromEntry(
- TestHistoryEntry(null, null, '/home'),
+ const TestHistoryEntry(null, null, '/home'),
);
await window.debugInitializeHistory(strategy, useSingle: true);
@@ -228,7 +228,7 @@
test('user types unknown url', () async {
final TestUrlStrategy strategy = TestUrlStrategy.fromEntry(
- TestHistoryEntry(null, null, '/home'),
+ const TestHistoryEntry(null, null, '/home'),
);
await window.debugInitializeHistory(strategy, useSingle: true);
@@ -267,7 +267,7 @@
test('basic setup works', () async {
final TestUrlStrategy strategy = TestUrlStrategy.fromEntry(
- TestHistoryEntry('initial state', null, '/initial'),
+ const TestHistoryEntry('initial state', null, '/initial'),
);
await window.debugInitializeHistory(strategy, useSingle: false);
@@ -284,7 +284,7 @@
test('browser back button push route information correctly', () async {
final TestUrlStrategy strategy = TestUrlStrategy.fromEntry(
- TestHistoryEntry('initial state', null, '/home'),
+ const TestHistoryEntry('initial state', null, '/home'),
);
await window.debugInitializeHistory(strategy, useSingle: false);
@@ -325,7 +325,7 @@
test('multiple browser back clicks', () async {
final TestUrlStrategy strategy = TestUrlStrategy.fromEntry(
- TestHistoryEntry('initial state', null, '/home'),
+ const TestHistoryEntry('initial state', null, '/home'),
);
await window.debugInitializeHistory(strategy, useSingle: false);
@@ -377,7 +377,7 @@
test('handle user-provided url', () async {
final TestUrlStrategy strategy = TestUrlStrategy.fromEntry(
- TestHistoryEntry('initial state', null, '/home'),
+ const TestHistoryEntry('initial state', null, '/home'),
);
await window.debugInitializeHistory(strategy, useSingle: false);
@@ -422,7 +422,7 @@
test('forward button works', () async {
final TestUrlStrategy strategy = TestUrlStrategy.fromEntry(
- TestHistoryEntry('initial state', null, '/home'),
+ const TestHistoryEntry('initial state', null, '/home'),
);
await window.debugInitializeHistory(strategy, useSingle: false);
@@ -539,7 +539,7 @@
final Completer<void> completer = Completer<void>();
window.sendPlatformMessage(
'flutter/platform',
- codec.encodeMethodCall(MethodCall('SystemNavigator.pop')),
+ codec.encodeMethodCall(const MethodCall('SystemNavigator.pop')),
(_) => completer.complete(),
);
return completer.future;
diff --git a/lib/web_ui/test/engine/image_to_byte_data_test.dart b/lib/web_ui/test/engine/image_to_byte_data_test.dart
index 961cf11..a6d7bea 100644
--- a/lib/web_ui/test/engine/image_to_byte_data_test.dart
+++ b/lib/web_ui/test/engine/image_to_byte_data_test.dart
@@ -23,8 +23,8 @@
test('Picture.toImage().toByteData()', () async {
final EnginePictureRecorder recorder = EnginePictureRecorder();
final RecordingCanvas canvas =
- recorder.beginRecording(Rect.fromLTRB(0, 0, 2, 2));
- canvas.drawColor(Color(0xFFCCDD00), BlendMode.srcOver);
+ recorder.beginRecording(const Rect.fromLTRB(0, 0, 2, 2));
+ canvas.drawColor(const Color(0xFFCCDD00), BlendMode.srcOver);
final Picture testPicture = recorder.endRecording();
final Image testImage = await testPicture.toImage(2, 2);
final ByteData bytes =
diff --git a/lib/web_ui/test/engine/path_metrics_test.dart b/lib/web_ui/test/engine/path_metrics_test.dart
index 6522b6f..924ee64 100644
--- a/lib/web_ui/test/engine/path_metrics_test.dart
+++ b/lib/web_ui/test/engine/path_metrics_test.dart
@@ -88,7 +88,7 @@
test('addRect', () {
final Path path = Path();
- path.addRect(Rect.fromLTRB(20, 30, 220, 130));
+ path.addRect(const Rect.fromLTRB(20, 30, 220, 130));
final List<double> contourLengths = computeLengths(path.computeMetrics());
expect(contourLengths.length, 1);
expect(contourLengths[0], within(distance: kTolerance, from: 600.0));
@@ -96,7 +96,7 @@
test('addRRect with zero radius', () {
final Path path = Path();
- path.addRRect(RRect.fromLTRBR(20, 30, 220, 130, Radius.circular(0)));
+ path.addRRect(RRect.fromLTRBR(20, 30, 220, 130, const Radius.circular(0)));
final List<double> contourLengths = computeLengths(path.computeMetrics());
expect(contourLengths.length, 1);
expect(contourLengths[0], within(distance: kTolerance, from: 600.0));
@@ -104,7 +104,7 @@
test('addRRect with elliptical radius', () {
final Path path = Path();
- path.addRRect(RRect.fromLTRBR(20, 30, 220, 130, Radius.elliptical(8, 4)));
+ path.addRRect(RRect.fromLTRBR(20, 30, 220, 130, const Radius.elliptical(8, 4)));
final List<double> contourLengths = computeLengths(path.computeMetrics());
expect(contourLengths.length, 1);
expect(contourLengths[0], within(distance: kTolerance, from: 590.408));
diff --git a/lib/web_ui/test/engine/platform_dispatcher_test.dart b/lib/web_ui/test/engine/platform_dispatcher_test.dart
index 0e79caf..eb2bcdd 100644
--- a/lib/web_ui/test/engine/platform_dispatcher_test.dart
+++ b/lib/web_ui/test/engine/platform_dispatcher_test.dart
@@ -23,7 +23,7 @@
final Completer<ByteData?> completer = Completer<ByteData?>();
ui.PlatformDispatcher.instance.sendPlatformMessage(
'flutter/skia',
- codec.encodeMethodCall(MethodCall(
+ codec.encodeMethodCall(const MethodCall(
'Skia.setResourceCacheMaxBytes',
512 * 1000 * 1000,
)),
@@ -43,7 +43,7 @@
final Completer<ByteData?> completer = Completer<ByteData?>();
ui.PlatformDispatcher.instance.sendPlatformMessage(
'flutter/platform',
- codec.encodeMethodCall(MethodCall(
+ codec.encodeMethodCall(const MethodCall(
'HapticFeedback.vibrate',
)),
completer.complete,
@@ -67,7 +67,7 @@
final Completer<ByteData?> completer = Completer<ByteData?>();
ui.PlatformDispatcher.instance.sendPlatformMessage(
'flutter/platform',
- codec.encodeMethodCall(MethodCall(
+ codec.encodeMethodCall(const MethodCall(
'Clipboard.getData',
)),
completer.complete,
diff --git a/lib/web_ui/test/engine/platform_views/message_handler_test.dart b/lib/web_ui/test/engine/platform_views/message_handler_test.dart
index 3e78471..54d14bc 100644
--- a/lib/web_ui/test/engine/platform_views/message_handler_test.dart
+++ b/lib/web_ui/test/engine/platform_views/message_handler_test.dart
@@ -14,7 +14,7 @@
internalBootstrapBrowserTest(() => testMain);
}
-final MethodCodec codec = StandardMethodCodec();
+const MethodCodec codec = StandardMethodCodec();
void testMain() {
group('PlatformViewMessageHandler', () {
diff --git a/lib/web_ui/test/engine/pointer_binding_test.dart b/lib/web_ui/test/engine/pointer_binding_test.dart
index a12d927..a8e27fe 100644
--- a/lib/web_ui/test/engine/pointer_binding_test.dart
+++ b/lib/web_ui/test/engine/pointer_binding_test.dart
@@ -90,7 +90,7 @@
expect(event.client.x, equals(110));
expect(event.client.y, equals(111));
- events = expectCorrectTypes(context.multiTouchDown(<_TouchDetails>[
+ events = expectCorrectTypes(context.multiTouchDown(const <_TouchDetails>[
_TouchDetails(pointer: 100, clientX: 120, clientY: 121),
_TouchDetails(pointer: 101, clientX: 122, clientY: 123),
]));
@@ -143,7 +143,7 @@
expect(event.client.x, equals(214));
expect(event.client.y, equals(215));
- events = expectCorrectTypes(context.multiTouchMove(<_TouchDetails>[
+ events = expectCorrectTypes(context.multiTouchMove(const <_TouchDetails>[
_TouchDetails(pointer: 102, clientX: 220, clientY: 221),
_TouchDetails(pointer: 103, clientX: 222, clientY: 223),
]));
@@ -178,7 +178,7 @@
expect(event.client.x, equals(310));
expect(event.client.y, equals(311));
- events = expectCorrectTypes(context.multiTouchUp(<_TouchDetails>[
+ events = expectCorrectTypes(context.multiTouchUp(const <_TouchDetails>[
_TouchDetails(pointer: 104, clientX: 320, clientY: 321),
_TouchDetails(pointer: 105, clientX: 322, clientY: 323),
]));
@@ -204,7 +204,7 @@
expect(event.client.x, equals(400));
expect(event.client.y, equals(401));
- events = expectCorrectTypes(context.multiTouchCancel(<_TouchDetails>[
+ events = expectCorrectTypes(context.multiTouchCancel(const <_TouchDetails>[
_TouchDetails(pointer: 106, clientX: 500, clientY: 501),
_TouchDetails(pointer: 107, clientX: 502, clientY: 503),
]));
@@ -248,7 +248,7 @@
expect(event.changedTouches![0].client.x, equals(100));
expect(event.changedTouches![0].client.y, equals(101));
- events = expectCorrectTypes(context.multiTouchDown(<_TouchDetails>[
+ events = expectCorrectTypes(context.multiTouchDown(const <_TouchDetails>[
_TouchDetails(pointer: 100, clientX: 120, clientY: 121),
_TouchDetails(pointer: 101, clientX: 122, clientY: 123),
]));
@@ -269,7 +269,7 @@
expect(event.changedTouches![0].client.x, equals(200));
expect(event.changedTouches![0].client.y, equals(201));
- events = expectCorrectTypes(context.multiTouchMove(<_TouchDetails>[
+ events = expectCorrectTypes(context.multiTouchMove(const <_TouchDetails>[
_TouchDetails(pointer: 102, clientX: 220, clientY: 221),
_TouchDetails(pointer: 103, clientX: 222, clientY: 223),
]));
@@ -290,7 +290,7 @@
expect(event.changedTouches![0].client.x, equals(300));
expect(event.changedTouches![0].client.y, equals(301));
- events = expectCorrectTypes(context.multiTouchUp(<_TouchDetails>[
+ events = expectCorrectTypes(context.multiTouchUp(const <_TouchDetails>[
_TouchDetails(pointer: 104, clientX: 320, clientY: 321),
_TouchDetails(pointer: 105, clientX: 322, clientY: 323),
]));
@@ -304,7 +304,7 @@
expect(events[0].changedTouches![1].client.x, equals(322));
expect(events[0].changedTouches![1].client.y, equals(323));
- events = expectCorrectTypes(context.multiTouchCancel(<_TouchDetails>[
+ events = expectCorrectTypes(context.multiTouchCancel(const <_TouchDetails>[
_TouchDetails(pointer: 104, clientX: 320, clientY: 321),
_TouchDetails(pointer: 105, clientX: 322, clientY: 323),
]));
@@ -1826,7 +1826,7 @@
};
// Two pointers down
- context.multiTouchDown(<_TouchDetails>[
+ context.multiTouchDown(const <_TouchDetails>[
_TouchDetails(pointer: 2, clientX: 100, clientY: 101),
_TouchDetails(pointer: 3, clientX: 200, clientY: 201),
]).forEach(glassPane.dispatchEvent);
@@ -1873,7 +1873,7 @@
packets.clear();
// Two pointers move
- context.multiTouchMove(<_TouchDetails>[
+ context.multiTouchMove(const <_TouchDetails>[
_TouchDetails(pointer: 3, clientX: 300, clientY: 302),
_TouchDetails(pointer: 2, clientX: 400, clientY: 402),
]).forEach(glassPane.dispatchEvent);
@@ -1908,7 +1908,7 @@
packets.clear();
// One pointer up
- context.multiTouchUp(<_TouchDetails>[
+ context.multiTouchUp(const <_TouchDetails>[
_TouchDetails(pointer: 3, clientX: 300, clientY: 302),
]).forEach(glassPane.dispatchEvent);
expect(packets, hasLength(1));
@@ -1931,7 +1931,7 @@
packets.clear();
// Another pointer up
- context.multiTouchUp(<_TouchDetails>[
+ context.multiTouchUp(const <_TouchDetails>[
_TouchDetails(pointer: 2, clientX: 400, clientY: 402),
]).forEach(glassPane.dispatchEvent);
expect(packets, hasLength(1));
@@ -1954,7 +1954,7 @@
packets.clear();
// Again two pointers down (reuse pointer ID)
- context.multiTouchDown(<_TouchDetails>[
+ context.multiTouchDown(const <_TouchDetails>[
_TouchDetails(pointer: 3, clientX: 500, clientY: 501),
_TouchDetails(pointer: 2, clientX: 600, clientY: 601),
]).forEach(glassPane.dispatchEvent);
@@ -2016,14 +2016,14 @@
};
// Two pointers down
- context.multiTouchDown(<_TouchDetails>[
+ context.multiTouchDown(const <_TouchDetails>[
_TouchDetails(pointer: 2, clientX: 100, clientY: 101),
_TouchDetails(pointer: 3, clientX: 200, clientY: 201),
]).forEach(glassPane.dispatchEvent);
packets.clear(); // Down event is tested in other tests.
// One pointer cancel
- context.multiTouchCancel(<_TouchDetails>[
+ context.multiTouchCancel(const <_TouchDetails>[
_TouchDetails(pointer: 3, clientX: 300, clientY: 302),
]).forEach(glassPane.dispatchEvent);
expect(packets.length, 1);
@@ -2061,7 +2061,7 @@
packets.add(packet);
};
- context.multiTouchDown(<_TouchDetails>[
+ context.multiTouchDown(const <_TouchDetails>[
_TouchDetails(pointer: 1, clientX: 100, clientY: 101),
]).forEach(glassPane.dispatchEvent);
expect(packets, hasLength(1));
@@ -2074,7 +2074,7 @@
expect(packets[0].data[1].device, equals(1));
packets.clear();
- context.multiTouchDown(<_TouchDetails>[
+ context.multiTouchDown(const <_TouchDetails>[
_TouchDetails(pointer: 2, clientX: 200, clientY: 202),
]).forEach(glassPane.dispatchEvent);
// An add will be synthesized.
@@ -2158,7 +2158,7 @@
packets.add(packet);
};
- context.multiTouchDown(<_TouchDetails>[
+ context.multiTouchDown(const <_TouchDetails>[
_TouchDetails(pointer: 1, clientX: 20, clientY: 20),
]).forEach(glassPane.dispatchEvent);
expect(packets, hasLength(1));
@@ -2180,7 +2180,7 @@
expect(packets[0].data[1].physicalDeltaY, equals(0.0));
packets.clear();
- context.multiTouchMove(<_TouchDetails>[
+ context.multiTouchMove(const <_TouchDetails>[
_TouchDetails(pointer: 1, clientX: 40, clientY: 30),
]).forEach(glassPane.dispatchEvent);
expect(packets, hasLength(1));
@@ -2194,7 +2194,7 @@
expect(packets[0].data[0].physicalDeltaY, equals(10.0 * dpi));
packets.clear();
- context.multiTouchUp(<_TouchDetails>[
+ context.multiTouchUp(const <_TouchDetails>[
_TouchDetails(pointer: 1, clientX: 40, clientY: 30),
]).forEach(glassPane.dispatchEvent);
expect(packets, hasLength(1));
@@ -2216,7 +2216,7 @@
expect(packets[0].data[1].physicalDeltaY, equals(0.0));
packets.clear();
- context.multiTouchDown(<_TouchDetails>[
+ context.multiTouchDown(const <_TouchDetails>[
_TouchDetails(pointer: 2, clientX: 20, clientY: 10),
]).forEach(glassPane.dispatchEvent);
expect(packets, hasLength(1));
diff --git a/lib/web_ui/test/engine/recording_canvas_test.dart b/lib/web_ui/test/engine/recording_canvas_test.dart
index 1cf2351..6097a7d 100644
--- a/lib/web_ui/test/engine/recording_canvas_test.dart
+++ b/lib/web_ui/test/engine/recording_canvas_test.dart
@@ -24,7 +24,7 @@
});
group('drawDRRect', () {
- final RRect rrect = RRect.fromLTRBR(10, 10, 50, 50, Radius.circular(3));
+ final RRect rrect = RRect.fromLTRBR(10, 10, 50, 50, const Radius.circular(3));
final SurfacePaint somePaint = SurfacePaint()
..color = const Color(0xFFFF0000);
@@ -72,13 +72,13 @@
// This comes from github issue #40728
final RRect outer = RRect.fromRectAndCorners(
const Rect.fromLTWH(0, 0, 88, 48),
- topLeft: Radius.circular(6),
- bottomLeft: Radius.circular(6));
+ topLeft: const Radius.circular(6),
+ bottomLeft: const Radius.circular(6));
final RRect inner = outer.deflate(1);
// If these assertions fail, check [_measureBorderRadius] in recording_canvas.dart
- expect(inner.brRadius, equals(Radius.circular(-1)));
- expect(inner.trRadius, equals(Radius.circular(-1)));
+ expect(inner.brRadius, equals(const Radius.circular(-1)));
+ expect(inner.trRadius, equals(const Radius.circular(-1)));
underTest.drawDRRect(outer, inner, somePaint);
underTest.endRecording();
@@ -112,28 +112,28 @@
test('Filters out paint commands outside the clip rect', () {
// Outside to the left
- underTest.drawRect(Rect.fromLTWH(0.0, 20.0, 10.0, 10.0), SurfacePaint());
+ underTest.drawRect(const Rect.fromLTWH(0.0, 20.0, 10.0, 10.0), SurfacePaint());
// Outside above
- underTest.drawRect(Rect.fromLTWH(20.0, 0.0, 10.0, 10.0), SurfacePaint());
+ underTest.drawRect(const Rect.fromLTWH(20.0, 0.0, 10.0, 10.0), SurfacePaint());
// Visible
- underTest.drawRect(Rect.fromLTWH(20.0, 20.0, 10.0, 10.0), SurfacePaint());
+ underTest.drawRect(const Rect.fromLTWH(20.0, 20.0, 10.0, 10.0), SurfacePaint());
// Inside the layer clip rect but zero-size
- underTest.drawRect(Rect.fromLTRB(20.0, 20.0, 30.0, 20.0), SurfacePaint());
+ underTest.drawRect(const Rect.fromLTRB(20.0, 20.0, 30.0, 20.0), SurfacePaint());
// Inside the layer clip but clipped out by a canvas clip
underTest.save();
- underTest.clipRect(Rect.fromLTWH(0, 0, 10, 10), ClipOp.intersect);
- underTest.drawRect(Rect.fromLTWH(20.0, 20.0, 10.0, 10.0), SurfacePaint());
+ underTest.clipRect(const Rect.fromLTWH(0, 0, 10, 10), ClipOp.intersect);
+ underTest.drawRect(const Rect.fromLTWH(20.0, 20.0, 10.0, 10.0), SurfacePaint());
underTest.restore();
// Outside to the right
- underTest.drawRect(Rect.fromLTWH(40.0, 20.0, 10.0, 10.0), SurfacePaint());
+ underTest.drawRect(const Rect.fromLTWH(40.0, 20.0, 10.0, 10.0), SurfacePaint());
// Outside below
- underTest.drawRect(Rect.fromLTWH(20.0, 40.0, 10.0, 10.0), SurfacePaint());
+ underTest.drawRect(const Rect.fromLTWH(20.0, 40.0, 10.0, 10.0), SurfacePaint());
underTest.endRecording();
@@ -187,7 +187,7 @@
// Clip out a middle region that only contains 'drawRect'
mockCanvas.methodCallLog.clear();
- underTest.apply(mockCanvas, Rect.fromLTRB(15, 15, 35, 35));
+ underTest.apply(mockCanvas, const Rect.fromLTRB(15, 15, 35, 35));
expect(mockCanvas.methodCallLog, hasLength(4));
expect(mockCanvas.methodCallLog[0].methodName, 'drawRect');
expect(mockCanvas.methodCallLog[1].methodName, 'save');
@@ -197,7 +197,7 @@
// Regression test for https://github.com/flutter/flutter/issues/61697.
test('Allows restore calls after recording has ended', () {
- final RecordingCanvas rc = RecordingCanvas(Rect.fromLTRB(0, 0, 200, 400));
+ final RecordingCanvas rc = RecordingCanvas(const Rect.fromLTRB(0, 0, 200, 400));
rc.endRecording();
// Should not throw exception on restore.
expect(() => rc.restore(), returnsNormally);
@@ -205,7 +205,7 @@
// Regression test for https://github.com/flutter/flutter/issues/61697.
test('Allows restore calls even if recording is not ended', () {
- final RecordingCanvas rc = RecordingCanvas(Rect.fromLTRB(0, 0, 200, 400));
+ final RecordingCanvas rc = RecordingCanvas(const Rect.fromLTRB(0, 0, 200, 400));
// Should not throw exception on restore.
expect(() => rc.restore(), returnsNormally);
});
diff --git a/lib/web_ui/test/engine/semantics/text_field_test.dart b/lib/web_ui/test/engine/semantics/text_field_test.dart
index 275dc13..3b2366c6b 100644
--- a/lib/web_ui/test/engine/semantics/text_field_test.dart
+++ b/lib/web_ui/test/engine/semantics/text_field_test.dart
@@ -117,7 +117,7 @@
value: 'hello',
label: 'greeting',
isFocused: true,
- rect: ui.Rect.fromLTWH(0, 0, 10, 15),
+ rect: const ui.Rect.fromLTWH(0, 0, 10, 15),
);
final TextField textField = textFieldSemantics.debugRoleManagerFor(Role.textField)! as TextField;
@@ -134,7 +134,7 @@
value: 'bye',
label: 'farewell',
isFocused: false,
- rect: ui.Rect.fromLTWH(0, 0, 12, 17),
+ rect: const ui.Rect.fromLTWH(0, 0, 12, 17),
);
expect(html.document.activeElement, html.document.body);
@@ -325,7 +325,7 @@
width: 13,
globalTransform: Matrix4.translationValues(14, 15, 0).storage,
);
- final ui.Rect semanticsRect = ui.Rect.fromLTRB(0, 0, 100, 50);
+ const ui.Rect semanticsRect = ui.Rect.fromLTRB(0, 0, 100, 50);
testTextEditing.acceptCommand(
TextInputSetEditableSizeAndTransform(geometry: geometry),
@@ -361,14 +361,14 @@
isTextField: true,
value: 'Hello',
isFocused: focusFieldId == 1,
- rect: ui.Rect.fromLTRB(0, 0, 50, 10),
+ rect: const ui.Rect.fromLTRB(0, 0, 50, 10),
),
builder.updateNode(
id: 2,
isTextField: true,
value: 'World',
isFocused: focusFieldId == 2,
- rect: ui.Rect.fromLTRB(0, 20, 50, 10),
+ rect: const ui.Rect.fromLTRB(0, 20, 50, 10),
),
],
);
diff --git a/lib/web_ui/test/engine/surface/path/path_winding_test.dart b/lib/web_ui/test/engine/surface/path/path_winding_test.dart
index ef1d596..f927e8b 100644
--- a/lib/web_ui/test/engine/surface/path/path_winding_test.dart
+++ b/lib/web_ui/test/engine/surface/path/path_winding_test.dart
@@ -23,26 +23,26 @@
test('Circle should be convex', () {
final SurfacePath path = SurfacePath();
- path.addOval(Rect.fromLTRB(0, 0, 20, 20));
+ path.addOval(const Rect.fromLTRB(0, 0, 20, 20));
expect(path.isConvex, isTrue);
// 2nd circle.
- path.addOval(Rect.fromLTRB(0, 0, 20, 20));
+ path.addOval(const Rect.fromLTRB(0, 0, 20, 20));
expect(path.isConvex, isFalse);
});
test('addRect should be convex', () {
SurfacePath path = SurfacePath();
- path.addRect(Rect.fromLTRB(0, 0, 20, 20));
+ path.addRect(const Rect.fromLTRB(0, 0, 20, 20));
expect(path.isConvex, isTrue);
path = SurfacePath();
path.addRectWithDirection(
- Rect.fromLTRB(0, 0, 20, 20), SPathDirection.kCW, 0);
+ const Rect.fromLTRB(0, 0, 20, 20), SPathDirection.kCW, 0);
expect(path.isConvex, isTrue);
path = SurfacePath();
path.addRectWithDirection(
- Rect.fromLTRB(0, 0, 20, 20), SPathDirection.kCCW, 0);
+ const Rect.fromLTRB(0, 0, 20, 20), SPathDirection.kCCW, 0);
expect(path.isConvex, isTrue);
});
@@ -78,7 +78,7 @@
});
test('Convexity of path with infinite points should return unknown', () {
- final List<Offset> nonFinitePts = <Offset>[
+ const List<Offset> nonFinitePts = <Offset>[
Offset(double.infinity, 0),
Offset(0, double.infinity),
Offset(double.infinity, double.infinity),
@@ -93,7 +93,7 @@
];
final int nonFinitePointsCount = nonFinitePts.length;
- final List<Offset> axisAlignedPts = <Offset>[
+ const List<Offset> axisAlignedPts = <Offset>[
Offset(kScalarMax, 0),
Offset(0, kScalarMax),
Offset(kScalarMin, 0),
@@ -434,9 +434,9 @@
path.quadraticBezierTo(0.0, 200.0, 0.0, 100.0);
path.quadraticBezierTo(0.0, 0.0, 100.0, 0.0);
path.close();
- expect(path.contains(Offset(100, 20)), isTrue);
- expect(path.contains(Offset(100, 120)), isTrue);
- expect(path.contains(Offset(100, -10)), isFalse);
+ expect(path.contains(const Offset(100, 20)), isTrue);
+ expect(path.contains(const Offset(100, 120)), isTrue);
+ expect(path.contains(const Offset(100, -10)), isFalse);
});
});
}
diff --git a/lib/web_ui/test/engine/surface/platform_view_test.dart b/lib/web_ui/test/engine/surface/platform_view_test.dart
index f5fa697..dec4eef 100644
--- a/lib/web_ui/test/engine/surface/platform_view_test.dart
+++ b/lib/web_ui/test/engine/surface/platform_view_test.dart
@@ -61,7 +61,7 @@
});
test('returns false when other view is not a PlatformView', () {
- final PersistedOpacity anyView = PersistedOpacity(null, 1, Offset(0, 0))..build();
+ final PersistedOpacity anyView = PersistedOpacity(null, 1, const Offset(0, 0))..build();
expect(view.canUpdateAsMatch(anyView), isFalse);
});
});
diff --git a/lib/web_ui/test/engine/surface/scene_builder_test.dart b/lib/web_ui/test/engine/surface/scene_builder_test.dart
index b6defe9..77c89f9 100644
--- a/lib/web_ui/test/engine/surface/scene_builder_test.dart
+++ b/lib/web_ui/test/engine/surface/scene_builder_test.dart
@@ -333,7 +333,7 @@
builder.pushOffset(0, 0);
builder.pushClipRect(const ui.Rect.fromLTRB(0, 0, 1000, 1000)) as PersistedContainerSurface;
builder.pushTransform((Matrix4.identity()..scale(0.5, 0.5)).toFloat64());
- builder.addPicture(ui.Offset(1000, 1000), picture);
+ builder.addPicture(const ui.Offset(1000, 1000), picture);
builder.pop();
builder.pop();
builder.pop();
@@ -469,7 +469,7 @@
final EnginePictureRecorder recorder = EnginePictureRecorder();
final RecordingCanvas canvas = recorder.beginRecording(const ui.Rect.fromLTRB(0, 0, 400, 400));
final DomParagraph paragraph = (DomParagraphBuilder(EngineParagraphStyle())..addText(char)).build() as DomParagraph;
- paragraph.layout(ui.ParagraphConstraints(width: 1000));
+ paragraph.layout(const ui.ParagraphConstraints(width: 1000));
canvas.drawParagraph(paragraph, ui.Offset.zero);
final ui.EngineLayer newLayer = useOffset
? builder.pushOffset(0, 0, oldLayer: oldLayer == null ? null : oldLayer as ui.OffsetEngineLayer)
@@ -821,31 +821,31 @@
final RecordingCanvas canvas =
recorder.beginRecording(const ui.Rect.fromLTRB(0, 0, 400, 400));
final ui.Shader gradient = ui.Gradient.radial(
- ui.Offset(100, 100), 50,
- <ui.Color>[
- const ui.Color.fromARGB(255, 0, 0, 0),
- const ui.Color.fromARGB(255, 0, 0, 255),
+ const ui.Offset(100, 100), 50,
+ const <ui.Color>[
+ ui.Color.fromARGB(255, 0, 0, 0),
+ ui.Color.fromARGB(255, 0, 0, 255),
],
);
canvas.drawCircle(
- ui.Offset(offsetX + 10, offsetY + 10), 10,
+ const ui.Offset(offsetX + 10, offsetY + 10), 10,
SurfacePaint()
..style = ui.PaintingStyle.fill
..shader = gradient);
canvas.drawCircle(
- ui.Offset(offsetX + 60, offsetY + 10),
+ const ui.Offset(offsetX + 60, offsetY + 10),
10,
SurfacePaint()
..style = ui.PaintingStyle.fill
..color = const ui.Color.fromRGBO(255, 0, 0, 1));
canvas.drawCircle(
- ui.Offset(offsetX + 10, offsetY + 60),
+ const ui.Offset(offsetX + 10, offsetY + 60),
10,
SurfacePaint()
..style = ui.PaintingStyle.fill
..color = const ui.Color.fromRGBO(0, 255, 0, 1));
canvas.drawCircle(
- ui.Offset(offsetX + 60, offsetY + 60),
+ const ui.Offset(offsetX + 60, offsetY + 60),
10,
SurfacePaint()
..style = ui.PaintingStyle.fill
@@ -866,37 +866,37 @@
final RecordingCanvas canvas =
recorder.beginRecording(const ui.Rect.fromLTRB(0, 0, 400, 400));
final ui.Shader gradient = ui.Gradient.radial(
- ui.Offset(100, 100), 50,
- <ui.Color>[
- const ui.Color.fromARGB(255, 0, 0, 0),
- const ui.Color.fromARGB(255, 0, 0, 255),
+ const ui.Offset(100, 100), 50,
+ const <ui.Color>[
+ ui.Color.fromARGB(255, 0, 0, 0),
+ ui.Color.fromARGB(255, 0, 0, 255),
],
);
canvas.drawCircle(
- ui.Offset(offsetX + 10, offsetY + 10), 10,
+ const ui.Offset(offsetX + 10, offsetY + 10), 10,
SurfacePaint()
..style = ui.PaintingStyle.fill
..shader = gradient);
canvas.drawCircle(
- ui.Offset(offsetX + 60, offsetY + 10),
+ const ui.Offset(offsetX + 60, offsetY + 10),
10,
SurfacePaint()
..style = ui.PaintingStyle.fill
..color = const ui.Color.fromRGBO(255, 0, 0, 1));
canvas.drawCircle(
- ui.Offset(offsetX + 10, offsetY + 60),
+ const ui.Offset(offsetX + 10, offsetY + 60),
10,
SurfacePaint()
..style = ui.PaintingStyle.fill
..color = const ui.Color.fromRGBO(0, 255, 0, 1));
- canvas.drawImage(createTestImage(), ui.Offset(0, 0), SurfacePaint());
+ canvas.drawImage(createTestImage(), const ui.Offset(0, 0), SurfacePaint());
canvas.drawCircle(
- ui.Offset(offsetX + 10, offsetY + 10), 10,
+ const ui.Offset(offsetX + 10, offsetY + 10), 10,
SurfacePaint()
..style = ui.PaintingStyle.fill
..shader = gradient);
canvas.drawCircle(
- ui.Offset(offsetX + 60, offsetY + 60),
+ const ui.Offset(offsetX + 60, offsetY + 60),
10,
SurfacePaint()
..style = ui.PaintingStyle.fill
diff --git a/lib/web_ui/test/engine/surface/shaders/normalized_gradient_test.dart b/lib/web_ui/test/engine/surface/shaders/normalized_gradient_test.dart
index 86e424a..2aae2af 100644
--- a/lib/web_ui/test/engine/surface/shaders/normalized_gradient_test.dart
+++ b/lib/web_ui/test/engine/surface/shaders/normalized_gradient_test.dart
@@ -14,7 +14,7 @@
void testMain() {
group('Shader Normalized Gradient', () {
test('3 stop at start', () {
- final NormalizedGradient gradient = NormalizedGradient(<ui.Color>[
+ final NormalizedGradient gradient = NormalizedGradient(const <ui.Color>[
ui.Color(0xFF000000), ui.Color(0xFFFF7f3f)
], stops: <double>[0.0, 0.5]);
int res = _computeColorAt(gradient, 0.0);
@@ -30,7 +30,7 @@
});
test('3 stop at end', () {
- final NormalizedGradient gradient = NormalizedGradient(<ui.Color>[
+ final NormalizedGradient gradient = NormalizedGradient(const <ui.Color>[
ui.Color(0xFF000000), ui.Color(0xFFFF7f3f)
], stops: <double>[0.5, 1.0]);
int res = _computeColorAt(gradient, 0.0);
@@ -46,7 +46,7 @@
});
test('4 stop', () {
- final NormalizedGradient gradient = NormalizedGradient(<ui.Color>[
+ final NormalizedGradient gradient = NormalizedGradient(const <ui.Color>[
ui.Color(0xFF000000), ui.Color(0xFFFF7f3f)
], stops: <double>[0.25, 0.5]);
int res = _computeColorAt(gradient, 0.0);
@@ -64,7 +64,7 @@
});
test('5 stop', () {
- final NormalizedGradient gradient = NormalizedGradient(<ui.Color>[
+ final NormalizedGradient gradient = NormalizedGradient(const <ui.Color>[
ui.Color(0x10000000), ui.Color(0x20FF0000),
ui.Color(0x4000FF00), ui.Color(0x800000FF),
ui.Color(0xFFFFFFFF)
@@ -90,7 +90,7 @@
});
test('2 stops at ends', () {
- final NormalizedGradient gradient = NormalizedGradient(<ui.Color>[
+ final NormalizedGradient gradient = NormalizedGradient(const <ui.Color>[
ui.Color(0x00000000), ui.Color(0xFFFFFFFF)
]);
int res = _computeColorAt(gradient, 0.0);
diff --git a/lib/web_ui/test/engine/surface/surface_test.dart b/lib/web_ui/test/engine/surface/surface_test.dart
index a659632..aab307e 100644
--- a/lib/web_ui/test/engine/surface/surface_test.dart
+++ b/lib/web_ui/test/engine/surface/surface_test.dart
@@ -370,9 +370,9 @@
() {
final SceneBuilder builder1 = SceneBuilder();
final Path path = Path();
- path.addPolygon(<Offset>[Offset(50, 0), Offset(100, 80), Offset(20, 40)], true);
+ path.addPolygon(const <Offset>[Offset(50, 0), Offset(100, 80), Offset(20, 40)], true);
final PersistedPhysicalShape shape = builder1.pushPhysicalShape(path: path,
- color: Color(0xFF00FF00), elevation: 1) as PersistedPhysicalShape;
+ color: const Color(0xFF00FF00), elevation: 1) as PersistedPhysicalShape;
builder1.build();
expect(() => shape.apply(), returnsNormally);
});
diff --git a/lib/web_ui/test/engine/window_test.dart b/lib/web_ui/test/engine/window_test.dart
index 37105c4..dc7358c 100644
--- a/lib/web_ui/test/engine/window_test.dart
+++ b/lib/web_ui/test/engine/window_test.dart
@@ -145,11 +145,11 @@
expect(window.onPointerDataPacket, same(callback));
});
- EnginePlatformDispatcher.instance.invokeOnPointerDataPacket(ui.PointerDataPacket());
+ EnginePlatformDispatcher.instance.invokeOnPointerDataPacket(const ui.PointerDataPacket());
});
test('invokeOnKeyData returns normally when onKeyData is null', () {
- final ui.KeyData keyData = ui.KeyData(
+ const ui.KeyData keyData = ui.KeyData(
timeStamp: Duration(milliseconds: 1),
type: ui.KeyEventType.repeat,
physical: kPhysicalKeyA,
@@ -179,7 +179,7 @@
expect(window.onKeyData, same(onKeyData));
});
- final ui.KeyData keyData = ui.KeyData(
+ const ui.KeyData keyData = ui.KeyData(
timeStamp: Duration(milliseconds: 1),
type: ui.KeyEventType.repeat,
physical: kPhysicalKeyA,
@@ -304,9 +304,9 @@
js_util.setProperty(screen, 'orientation', null);
final Completer<bool> completer = Completer<bool>();
- final ByteData inputData = JSONMethodCodec().encodeMethodCall(MethodCall(
+ final ByteData inputData = const JSONMethodCodec().encodeMethodCall(const MethodCall(
'SystemChrome.setPreferredOrientations',
- const <dynamic>[]))!;
+ <dynamic>[]))!;
window.sendPlatformMessage(
'flutter/platform',
diff --git a/lib/web_ui/test/golden_tests/golden_failure_smoke_test.dart b/lib/web_ui/test/golden_tests/golden_failure_smoke_test.dart
index a7d20db..85297e5 100644
--- a/lib/web_ui/test/golden_tests/golden_failure_smoke_test.dart
+++ b/lib/web_ui/test/golden_tests/golden_failure_smoke_test.dart
@@ -16,6 +16,6 @@
void testMain() {
test('screenshot test reports failure', () async {
html.document.body!.innerHtml = 'Text that does not appear on the screenshot!';
- await matchGoldenFile('__local__/smoke_test.png', region: Rect.fromLTWH(0, 0, 320, 200));
+ await matchGoldenFile('__local__/smoke_test.png', region: const Rect.fromLTWH(0, 0, 320, 200));
});
}
diff --git a/lib/web_ui/test/golden_tests/golden_success_smoke_test.dart b/lib/web_ui/test/golden_tests/golden_success_smoke_test.dart
index 01baf0e..545aba3 100644
--- a/lib/web_ui/test/golden_tests/golden_success_smoke_test.dart
+++ b/lib/web_ui/test/golden_tests/golden_success_smoke_test.dart
@@ -22,7 +22,7 @@
html.document.body!.style.fontFamily = 'Roboto';
html.document.body!.innerHtml = 'Hello world!';
// TODO: https://github.com/flutter/flutter/issues/74702 , reduce webkit percentage.
- await matchGoldenFile('__local__/smoke_test.png', region: Rect.fromLTWH(0, 0, 320, 200),
+ await matchGoldenFile('__local__/smoke_test.png', region: const Rect.fromLTWH(0, 0, 320, 200),
maxDiffRatePercent: browserEngine == BrowserEngine.webkit ? 3.0 : 0.28);
});
}
diff --git a/lib/web_ui/test/html/bitmap_canvas_golden_test.dart b/lib/web_ui/test/html/bitmap_canvas_golden_test.dart
index 0c36f8f..c78e491 100644
--- a/lib/web_ui/test/html/bitmap_canvas_golden_test.dart
+++ b/lib/web_ui/test/html/bitmap_canvas_golden_test.dart
@@ -18,7 +18,7 @@
}
Future<void> testMain() async {
- final Rect region = Rect.fromLTWH(0, 0, 500, 100);
+ const Rect region = Rect.fromLTWH(0, 0, 500, 100);
late BitmapCanvas canvas;
@@ -202,7 +202,7 @@
final EngineParagraph paragraph = builder.build() as EngineParagraph;
paragraph.layout(const ParagraphConstraints(width: 100));
- final Rect canvasSize = Offset.zero & Size(500, 500);
+ final Rect canvasSize = Offset.zero & const Size(500, 500);
canvas = BitmapCanvas(canvasSize, RenderStrategy());
canvas.debugChildOverdraw = true;
diff --git a/lib/web_ui/test/html/canvas_clip_path_golden_test.dart b/lib/web_ui/test/html/canvas_clip_path_golden_test.dart
index a2e5074..5e0f2e2 100644
--- a/lib/web_ui/test/html/canvas_clip_path_golden_test.dart
+++ b/lib/web_ui/test/html/canvas_clip_path_golden_test.dart
@@ -55,7 +55,7 @@
const double testWidth = 200;
const double testHeight = 150;
final Path path = Path();
- path.addOval(Rect.fromLTWH(100, 30, testWidth, testHeight));
+ path.addOval(const Rect.fromLTWH(100, 30, testWidth, testHeight));
rc.clipPath(path);
final Path paintPath = Path();
paintPath.moveTo(testWidth / 2, 0);
@@ -65,7 +65,7 @@
rc.drawPath(
paintPath,
engine.SurfacePaint()
- ..color = Color(0xFF00FF00)
+ ..color = const Color(0xFF00FF00)
..style = PaintingStyle.fill);
rc.restore();
await canvasScreenshot(rc, 'triangle_clipped_by_oval',
@@ -81,11 +81,11 @@
const double testHeight = 150;
final Path paintPath = Path();
- paintPath.addRect(Rect.fromLTWH(-50, 0, testWidth, testHeight));
+ paintPath.addRect(const Rect.fromLTWH(-50, 0, testWidth, testHeight));
paintPath.close();
rc.drawPath(paintPath,
engine.SurfacePaint()
- ..color = Color(0xFF000000)
+ ..color = const Color(0xFF000000)
..style = PaintingStyle.stroke);
final Path path = Path();
@@ -94,8 +94,8 @@
path.lineTo(-200, 150);
path.close();
rc.clipPath(path);
- rc.drawImageRect(createTestImage(), Rect.fromLTRB(0, 0, testWidth, testHeight),
- Rect.fromLTWH(-50, 0, testWidth, testHeight), engine.SurfacePaint());
+ rc.drawImageRect(createTestImage(), const Rect.fromLTRB(0, 0, testWidth, testHeight),
+ const Rect.fromLTWH(-50, 0, testWidth, testHeight), engine.SurfacePaint());
rc.restore();
await canvasScreenshot(rc, 'image_clipped_by_triangle_off_screen');
});
@@ -109,18 +109,18 @@
const double testHeight = 150;
final Path paintPath = Path();
- paintPath.addRect(Rect.fromLTWH(-50, 0, testWidth, testHeight));
+ paintPath.addRect(const Rect.fromLTWH(-50, 0, testWidth, testHeight));
paintPath.close();
rc.drawPath(paintPath,
engine.SurfacePaint()
- ..color = Color(0xFF000000)
+ ..color = const Color(0xFF000000)
..style = PaintingStyle.stroke);
final Path path = Path();
- path.addOval(Rect.fromLTRB(-200, 0, 100, 150));
+ path.addOval(const Rect.fromLTRB(-200, 0, 100, 150));
rc.clipPath(path);
- rc.drawImageRect(createTestImage(), Rect.fromLTRB(0, 0, testWidth, testHeight),
- Rect.fromLTWH(-50, 0, testWidth, testHeight), engine.SurfacePaint());
+ rc.drawImageRect(createTestImage(), const Rect.fromLTRB(0, 0, testWidth, testHeight),
+ const Rect.fromLTWH(-50, 0, testWidth, testHeight), engine.SurfacePaint());
rc.restore();
await canvasScreenshot(rc, 'image_clipped_by_oval_path');
});
diff --git a/lib/web_ui/test/html/canvas_context_golden_test.dart b/lib/web_ui/test/html/canvas_context_golden_test.dart
index 8b97c56..975cc38 100644
--- a/lib/web_ui/test/html/canvas_context_golden_test.dart
+++ b/lib/web_ui/test/html/canvas_context_golden_test.dart
@@ -57,11 +57,11 @@
final engine.RecordingCanvas rc =
engine.RecordingCanvas(const Rect.fromLTRB(0, 0, 400, 300));
final engine.SurfacePaint paint = Paint() as engine.SurfacePaint
- ..color = Color(0xFF00FF00)
+ ..color = const Color(0xFF00FF00)
..style = PaintingStyle.fill;
rc.save();
final Path ovalPath = Path();
- ovalPath.addOval(Rect.fromLTWH(100, 30, 200, 100));
+ ovalPath.addOval(const Rect.fromLTWH(100, 30, 200, 100));
rc.clipPath(ovalPath);
rc.translate(-500, -500);
rc.save();
@@ -76,7 +76,7 @@
rc.restore();
// The rectangle should paint without clipping since we restored
// context.
- rc.drawRect(Rect.fromLTWH(0, 0, 4, 200), paint);
+ rc.drawRect(const Rect.fromLTWH(0, 0, 4, 200), paint);
await _checkScreenshot(rc, 'context_save_restore_transform');
});
@@ -84,24 +84,24 @@
final engine.RecordingCanvas rc =
engine.RecordingCanvas(const Rect.fromLTRB(0, 0, 400, 300));
final Paint goodPaint = Paint()
- ..color = Color(0x8000FF00)
+ ..color = const Color(0x8000FF00)
..style = PaintingStyle.fill;
final Paint badPaint = Paint()
- ..color = Color(0xFFFF0000)
+ ..color = const Color(0xFFFF0000)
..style = PaintingStyle.fill;
rc.save();
final Path ovalPath = Path();
- ovalPath.addOval(Rect.fromLTWH(100, 30, 200, 100));
+ ovalPath.addOval(const Rect.fromLTWH(100, 30, 200, 100));
rc.clipPath(ovalPath);
rc.translate(-500, -500);
rc.save();
rc.restore();
// The rectangle should be clipped against oval.
- rc.drawRect(Rect.fromLTWH(0, 0, 300, 300), badPaint as engine.SurfacePaint);
+ rc.drawRect(const Rect.fromLTWH(0, 0, 300, 300), badPaint as engine.SurfacePaint);
rc.restore();
// The rectangle should paint without clipping since we restored
// context.
- rc.drawRect(Rect.fromLTWH(0, 0, 200, 200), goodPaint as engine.SurfacePaint);
+ rc.drawRect(const Rect.fromLTWH(0, 0, 200, 200), goodPaint as engine.SurfacePaint);
await _checkScreenshot(rc, 'context_save_restore_clip');
});
}
diff --git a/lib/web_ui/test/html/canvas_reuse_golden_test.dart b/lib/web_ui/test/html/canvas_reuse_golden_test.dart
index a21b83c..5fb44af 100644
--- a/lib/web_ui/test/html/canvas_reuse_golden_test.dart
+++ b/lib/web_ui/test/html/canvas_reuse_golden_test.dart
@@ -73,7 +73,7 @@
final Path path2 = Path()
..moveTo(3, 0)
..quadraticBezierTo(100, 0, 100, 100);
- rc2.drawImage(_createRealTestImage(), Offset(0, 0), SurfacePaint());
+ rc2.drawImage(_createRealTestImage(), const Offset(0, 0), SurfacePaint());
rc2.drawPath(path2, testPaint);
rc2.endRecording();
rc2.apply(engineCanvas, screenRect);
diff --git a/lib/web_ui/test/html/canvas_winding_rule_golden_test.dart b/lib/web_ui/test/html/canvas_winding_rule_golden_test.dart
index bf30a4a..7dd6ec7 100644
--- a/lib/web_ui/test/html/canvas_winding_rule_golden_test.dart
+++ b/lib/web_ui/test/html/canvas_winding_rule_golden_test.dart
@@ -16,7 +16,7 @@
}
Future<void> testMain() async {
- final Rect region = Rect.fromLTWH(0, 0, 500, 500);
+ const Rect region = Rect.fromLTWH(0, 0, 500, 500);
late BitmapCanvas canvas;
@@ -37,18 +37,18 @@
}
void paintPaths(BitmapCanvas canvas) {
- canvas.drawRect(Rect.fromLTRB(0, 0, 500, 500),
+ canvas.drawRect(const Rect.fromLTRB(0, 0, 500, 500),
SurfacePaintData()
- ..color = Color(0xFFFFFFFF)
+ ..color = const Color(0xFFFFFFFF)
..style = PaintingStyle.fill); // white
final SurfacePaint paintFill = SurfacePaint()
..style = PaintingStyle.fill
- ..color = Color(0xFF00B0FF);
+ ..color = const Color(0xFF00B0FF);
final SurfacePaint paintStroke = SurfacePaint()
..style = PaintingStyle.stroke
..strokeWidth = 2
- ..color = Color(0xFFE00000);
+ ..color = const Color(0xFFE00000);
final Path path1 = Path()
..fillType = PathFillType.evenOdd
..moveTo(50, 0)
@@ -57,8 +57,8 @@
..lineTo(2, 35)
..lineTo(79, 90)
..close()
- ..addRect(Rect.fromLTWH(20, 100, 200, 50))
- ..addRect(Rect.fromLTWH(40, 120, 160, 10));
+ ..addRect(const Rect.fromLTWH(20, 100, 200, 50))
+ ..addRect(const Rect.fromLTWH(40, 120, 160, 10));
final Path path2 = Path()
..fillType = PathFillType.nonZero
..moveTo(50, 200)
@@ -67,8 +67,8 @@
..lineTo(2, 235)
..lineTo(79, 290)
..close()
- ..addRect(Rect.fromLTWH(20, 300, 200, 50))
- ..addRect(Rect.fromLTWH(40, 320, 160, 10));
+ ..addRect(const Rect.fromLTWH(20, 300, 200, 50))
+ ..addRect(const Rect.fromLTWH(40, 320, 160, 10));
canvas.drawPath(path1, paintFill.paintData);
canvas.drawPath(path2, paintFill.paintData);
canvas.drawPath(path1, paintStroke.paintData);
diff --git a/lib/web_ui/test/html/clip_op_golden_test.dart b/lib/web_ui/test/html/clip_op_golden_test.dart
index 791b07f..e8196dc 100644
--- a/lib/web_ui/test/html/clip_op_golden_test.dart
+++ b/lib/web_ui/test/html/clip_op_golden_test.dart
@@ -21,7 +21,7 @@
test('Clips using difference', () async {
const Rect region = Rect.fromLTRB(0, 0, 400, 300);
final RecordingCanvas canvas = RecordingCanvas(region);
- final Rect titleRect = Rect.fromLTWH(20, 0, 50, 20);
+ const Rect titleRect = Rect.fromLTWH(20, 0, 50, 20);
final SurfacePaint paint = SurfacePaint()
..style = PaintingStyle.stroke
..color = const Color(0xff000000)
diff --git a/lib/web_ui/test/html/compositing/backdrop_filter_golden_test.dart b/lib/web_ui/test/html/compositing/backdrop_filter_golden_test.dart
index c9d4eb3..e26dfcc 100644
--- a/lib/web_ui/test/html/compositing/backdrop_filter_golden_test.dart
+++ b/lib/web_ui/test/html/compositing/backdrop_filter_golden_test.dart
@@ -32,7 +32,7 @@
// the clip boundary around backdrop filter. However there should be only
// one red dot since the other one should be blurred by filter.
test('Background should only blur at ancestor clip boundary', () async {
- final Rect region = Rect.fromLTWH(0, 0, 190, 130);
+ const Rect region = Rect.fromLTWH(0, 0, 190, 130);
final SurfaceSceneBuilder builder = SurfaceSceneBuilder();
final Picture backgroundPicture = _drawBackground(region);
@@ -63,7 +63,7 @@
});
test('Background should only blur at ancestor clip boundary after move', () async {
- final Rect region = Rect.fromLTWH(0, 0, 190, 130);
+ const Rect region = Rect.fromLTWH(0, 0, 190, 130);
final SurfaceSceneBuilder builder = SurfaceSceneBuilder();
final Picture backgroundPicture = _drawBackground(region);
@@ -115,7 +115,7 @@
// The blur filter should be applied to the background inside the clip even
// though there are no children of the backdrop filter.
test('Background should blur even if child does not paint', () async {
- final Rect region = Rect.fromLTWH(0, 0, 190, 130);
+ const Rect region = Rect.fromLTWH(0, 0, 190, 130);
final SurfaceSceneBuilder builder = SurfaceSceneBuilder();
final Picture backgroundPicture = _drawBackground(region);
@@ -180,7 +180,7 @@
region.deflate(8.0),
SurfacePaint()
..style = PaintingStyle.fill
- ..color = Color(0xFFE0FFE0)
+ ..color = const Color(0xFFE0FFE0)
);
return recorder.endRecording();
}
diff --git a/lib/web_ui/test/html/compositing/canvas_blend_golden_test.dart b/lib/web_ui/test/html/compositing/canvas_blend_golden_test.dart
index 8b844f2..c56a161 100644
--- a/lib/web_ui/test/html/compositing/canvas_blend_golden_test.dart
+++ b/lib/web_ui/test/html/compositing/canvas_blend_golden_test.dart
@@ -30,12 +30,12 @@
RecordingCanvas(const Rect.fromLTRB(0, 0, 400, 300));
rc.save();
rc.drawRect(
- Rect.fromLTRB(0, 0, 400, 400),
+ const Rect.fromLTRB(0, 0, 400, 400),
SurfacePaint()
..style = PaintingStyle.fill
..color = const Color.fromARGB(255, 255, 255, 255));
rc.drawCircle(
- Offset(100, 100),
+ const Offset(100, 100),
80.0,
SurfacePaint()
..style = PaintingStyle.fill
@@ -43,7 +43,7 @@
..blendMode = BlendMode.difference);
rc.drawCircle(
- Offset(170, 100),
+ const Offset(170, 100),
80.0,
SurfacePaint()
..style = PaintingStyle.fill
@@ -51,7 +51,7 @@
..color = const Color.fromARGB(128, 0, 255, 0));
rc.drawCircle(
- Offset(135, 170),
+ const Offset(135, 170),
80.0,
SurfacePaint()
..style = PaintingStyle.fill
@@ -69,19 +69,19 @@
RecordingCanvas(const Rect.fromLTRB(0, 0, 400, 300));
rc.save();
rc.drawRect(
- Rect.fromLTRB(0, 0, 400, 400),
+ const Rect.fromLTRB(0, 0, 400, 400),
SurfacePaint()
..style = PaintingStyle.fill
..color = const Color.fromARGB(255, 255, 255, 255));
rc.drawCircle(
- Offset(100, 100),
+ const Offset(100, 100),
80.0,
SurfacePaint()
..style = PaintingStyle.fill
..color = const Color.fromARGB(128, 255, 0, 0)
..blendMode = BlendMode.difference);
rc.drawCircle(
- Offset(170, 100),
+ const Offset(170, 100),
80.0,
SurfacePaint()
..style = PaintingStyle.fill
@@ -89,12 +89,12 @@
..color = const Color.fromARGB(128, 0, 255, 0));
rc.drawCircle(
- Offset(135, 170),
+ const Offset(135, 170),
80.0,
SurfacePaint()
..style = PaintingStyle.fill
..color = const Color.fromARGB(128, 255, 0, 0));
- rc.drawImage(createTestImage(), Offset(135.0, 130.0),
+ rc.drawImage(createTestImage(), const Offset(135.0, 130.0),
SurfacePaint()..blendMode = BlendMode.multiply);
rc.restore();
await canvasScreenshot(rc, 'canvas_blend_image_multiply',
diff --git a/lib/web_ui/test/html/compositing/canvas_image_blend_mode_golden_test.dart b/lib/web_ui/test/html/compositing/canvas_image_blend_mode_golden_test.dart
index 45226de..527bb01 100644
--- a/lib/web_ui/test/html/compositing/canvas_image_blend_mode_golden_test.dart
+++ b/lib/web_ui/test/html/compositing/canvas_image_blend_mode_golden_test.dart
@@ -101,11 +101,11 @@
final RecordingCanvas rc = RecordingCanvas(
const Rect.fromLTRB(0, 0, 400, 400));
rc.save();
- rc.drawRect(Rect.fromLTWH(0, 50, 200, 50), makePaint()
+ rc.drawRect(const Rect.fromLTWH(0, 50, 200, 50), makePaint()
..color = white);
- rc.drawImage(createFlutterLogoTestImage(), Offset(0, 50),
+ rc.drawImage(createFlutterLogoTestImage(), const Offset(0, 50),
makePaint()
- ..colorFilter = EngineColorFilter.mode(red, BlendMode.srcIn));
+ ..colorFilter = const EngineColorFilter.mode(red, BlendMode.srcIn));
final Paragraph paragraph = createTestParagraph();
const double textLeft = 80.0;
diff --git a/lib/web_ui/test/html/compositing/canvas_image_filter_golden_test.dart b/lib/web_ui/test/html/compositing/canvas_image_filter_golden_test.dart
index 9828053..f1302de 100644
--- a/lib/web_ui/test/html/compositing/canvas_image_filter_golden_test.dart
+++ b/lib/web_ui/test/html/compositing/canvas_image_filter_golden_test.dart
@@ -26,10 +26,10 @@
final RecordingCanvas canvas = RecordingCanvas(region);
canvas.drawImage(
createFlutterLogoTestImage(),
- Offset(10, 10),
+ const Offset(10, 10),
makePaint()
..colorFilter =
- EngineColorFilter.mode(Color(0x40000000), BlendMode.dstATop));
+ const EngineColorFilter.mode(Color(0x40000000), BlendMode.dstATop));
await canvasScreenshot(canvas, 'image_color_fiter_dstatop', region: region);
});
@@ -37,9 +37,9 @@
final RecordingCanvas canvas = RecordingCanvas(region);
canvas.drawImage(
createFlutterLogoTestImage(),
- Offset(10, 10),
+ const Offset(10, 10),
makePaint()
- ..colorFilter = EngineColorFilter.matrix(<double>[
+ ..colorFilter = const EngineColorFilter.matrix(<double>[
0.2126, 0.7152, 0.0722, 0, 0, //
0.2126, 0.7152, 0.0722, 0, 0, //
0.2126, 0.7152, 0.0722, 0, 0, //
diff --git a/lib/web_ui/test/html/compositing/canvas_mask_filter_golden_test.dart b/lib/web_ui/test/html/compositing/canvas_mask_filter_golden_test.dart
index 2c918bf..548db3b 100644
--- a/lib/web_ui/test/html/compositing/canvas_mask_filter_golden_test.dart
+++ b/lib/web_ui/test/html/compositing/canvas_mask_filter_golden_test.dart
@@ -42,7 +42,7 @@
rc.translate(0, 75);
final SurfacePaint paint = SurfacePaint()
- ..maskFilter = ui.MaskFilter.blur(ui.BlurStyle.normal, 5);
+ ..maskFilter = const ui.MaskFilter.blur(ui.BlurStyle.normal, 5);
rc.translate(50, 0);
rc.drawRect(
@@ -51,21 +51,21 @@
);
rc.translate(100, 0);
- paint.color = ui.Color(0xFF00FF00);
+ paint.color = const ui.Color(0xFF00FF00);
rc.drawRRect(
ui.RRect.fromRectAndRadius(
ui.Rect.fromCircle(center: ui.Offset.zero, radius: 30),
- ui.Radius.circular(20),
+ const ui.Radius.circular(20),
),
paint,
);
rc.translate(100, 0);
- paint.color = ui.Color(0xFF0000FF);
+ paint.color = const ui.Color(0xFF0000FF);
rc.drawCircle(ui.Offset.zero, 30, paint);
rc.translate(100, 0);
- paint.color = ui.Color(0xFF00FFFF);
+ paint.color = const ui.Color(0xFF00FFFF);
rc.drawPath(
SurfacePath()
..moveTo(-20, 0)
@@ -77,37 +77,37 @@
);
rc.translate(100, 0);
- paint.color = ui.Color(0xFFFF00FF);
+ paint.color = const ui.Color(0xFFFF00FF);
rc.drawOval(
ui.Rect.fromCenter(center: ui.Offset.zero, width: 40, height: 100),
paint,
);
rc.translate(100, 0);
- paint.color = ui.Color(0xFF888800);
+ paint.color = const ui.Color(0xFF888800);
paint.strokeWidth = 5;
rc.drawLine(
- ui.Offset(-20, -50),
- ui.Offset(20, 50),
+ const ui.Offset(-20, -50),
+ const ui.Offset(20, 50),
paint,
);
rc.translate(100, 0);
- paint.color = ui.Color(0xFF888888);
+ paint.color = const ui.Color(0xFF888888);
rc.drawDRRect(
ui.RRect.fromRectAndRadius(
ui.Rect.fromCircle(center: ui.Offset.zero, radius: 35),
- ui.Radius.circular(20),
+ const ui.Radius.circular(20),
),
ui.RRect.fromRectAndRadius(
ui.Rect.fromCircle(center: ui.Offset.zero, radius: 15),
- ui.Radius.circular(7),
+ const ui.Radius.circular(7),
),
paint,
);
rc.translate(100, 0);
- paint.color = ui.Color(0xFF6500C9);
+ paint.color = const ui.Color(0xFF6500C9);
rc.drawRawPoints(
ui.PointMode.points,
Float32List.fromList(<double>[-10, -10, -10, 10, 10, -10, 10, 10]),
@@ -127,9 +127,9 @@
rc.translate(150, 150);
final SurfacePaint paint = SurfacePaint()
- ..maskFilter = ui.MaskFilter.blur(ui.BlurStyle.normal, 5);
+ ..maskFilter = const ui.MaskFilter.blur(ui.BlurStyle.normal, 5);
- final List<ui.Color> colors = <ui.Color>[
+ const List<ui.Color> colors = <ui.Color>[
ui.Color(0xFF000000),
ui.Color(0xFF00FF00),
ui.Color(0xFF0000FF),
@@ -166,7 +166,7 @@
rc.translate(0, 75);
final SurfacePaint paint = SurfacePaint()
- ..maskFilter = ui.MaskFilter.blur(ui.BlurStyle.normal, 5);
+ ..maskFilter = const ui.MaskFilter.blur(ui.BlurStyle.normal, 5);
rc.translate(75, 0);
rc.drawRect(
diff --git a/lib/web_ui/test/html/compositing/color_filter_golden_test.dart b/lib/web_ui/test/html/compositing/color_filter_golden_test.dart
index 94cfb87..4b7f380 100644
--- a/lib/web_ui/test/html/compositing/color_filter_golden_test.dart
+++ b/lib/web_ui/test/html/compositing/color_filter_golden_test.dart
@@ -12,7 +12,7 @@
import 'package:web_engine_tester/golden_tester.dart';
-final Rect region = Rect.fromLTWH(0, 0, 500, 500);
+const Rect region = Rect.fromLTWH(0, 0, 500, 500);
void main() {
internalBootstrapBrowserTest(() => testMain);
@@ -36,7 +36,7 @@
final Picture backgroundPicture = _drawBackground();
builder.addPicture(Offset.zero, backgroundPicture);
builder.pushColorFilter(
- EngineColorFilter.mode(Color(0xF0000080), BlendMode.color));
+ const EngineColorFilter.mode(Color(0xF0000080), BlendMode.color));
final Picture circles1 = _drawTestPictureWithCircles(30, 30);
builder.addPicture(Offset.zero, circles1);
builder.pop();
@@ -74,10 +74,10 @@
final Picture backgroundPicture = _drawBackground();
builder.addPicture(Offset.zero, backgroundPicture);
builder.pushColorFilter(
- ColorFilter.mode(
- Color(0xFFFF0000),
- BlendMode.srcIn,
- ));
+ const ColorFilter.mode(
+ Color(0xFFFF0000),
+ BlendMode.srcIn,
+ ));
final Picture circles1 = _drawTestPictureWithCircles(30, 30);
builder.addPicture(Offset.zero, circles1);
builder.pop();
@@ -94,19 +94,19 @@
final SurfaceSceneBuilder builder = SurfaceSceneBuilder();
final Path path = Path();
path.addRRect(RRect.fromRectAndRadius(
- Rect.fromLTRB(0, 0, 400, 400), Radius.circular(2)));
+ const Rect.fromLTRB(0, 0, 400, 400), const Radius.circular(2)));
final PhysicalShapeEngineLayer oldLayer = builder.pushPhysicalShape(
- path: path, color: Color(0xFFFFFFFF), elevation: 0);
+ path: path, color: const Color(0xFFFFFFFF), elevation: 0);
final Picture circles1 = _drawTestPictureWithImage(
- ColorFilter.mode(Color(0x3C4043), BlendMode.overlay));
- builder.addPicture(Offset(10, 0), circles1);
+ const ColorFilter.mode(Color(0x3C4043), BlendMode.overlay));
+ builder.addPicture(const Offset(10, 0), circles1);
builder.pop();
builder.build();
final SurfaceSceneBuilder builder2 = SurfaceSceneBuilder();
builder2.pushPhysicalShape(
- path: path, color: Color(0xFFFFFFFF), elevation: 0, oldLayer: oldLayer);
- builder2.addPicture(Offset(10, 0), circles1);
+ path: path, color: const Color(0xFFFFFFFF), elevation: 0, oldLayer: oldLayer);
+ builder2.addPicture(const Offset(10, 0), circles1);
builder2.pop();
html.document.body!.append(builder2.build().webOnlyRootElement!);
@@ -153,8 +153,8 @@
final Image testImage = createTestImage();
canvas.drawImageRect(
testImage,
- Rect.fromLTWH(0, 0, 200, 150),
- Rect.fromLTWH(0, 0, 300, 300),
+ const Rect.fromLTWH(0, 0, 200, 150),
+ const Rect.fromLTWH(0, 0, 300, 300),
(Paint()
..style = PaintingStyle.fill
..colorFilter = filter
@@ -168,10 +168,10 @@
final RecordingCanvas canvas =
recorder.beginRecording(const Rect.fromLTRB(0, 0, 400, 400));
canvas.drawRect(
- Rect.fromLTWH(8, 8, 400.0 - 16, 400.0 - 16),
+ const Rect.fromLTWH(8, 8, 400.0 - 16, 400.0 - 16),
(Paint()
..style = PaintingStyle.fill
- ..color = Color(0xFFE0FFE0)) as SurfacePaint);
+ ..color = const Color(0xFFE0FFE0)) as SurfacePaint);
return recorder.endRecording();
}
diff --git a/lib/web_ui/test/html/compositing/compositing_golden_test.dart b/lib/web_ui/test/html/compositing/compositing_golden_test.dart
index 3ba16cf..7093905 100644
--- a/lib/web_ui/test/html/compositing/compositing_golden_test.dart
+++ b/lib/web_ui/test/html/compositing/compositing_golden_test.dart
@@ -13,7 +13,7 @@
import '../../matchers.dart';
-final ui.Rect region = ui.Rect.fromLTWH(0, 0, 500, 100);
+const ui.Rect region = ui.Rect.fromLTWH(0, 0, 500, 100);
void main() {
internalBootstrapBrowserTest(() => testMain);
@@ -76,7 +76,7 @@
builder.pushTransform(
Matrix4.diagonal3Values(1, -1, 1).toFloat64(),
);
- builder.pushClipRect(ui.Rect.fromLTRB(10, 10, 60, 60),
+ builder.pushClipRect(const ui.Rect.fromLTRB(10, 10, 60, 60),
clipBehavior: ui.Clip.none);
_drawTestPicture(builder);
builder.pop();
@@ -217,7 +217,7 @@
builder.pushOffset(140, 0);
builder.pushPhysicalShape(
- path: ui.Path()..addOval(ui.Rect.fromLTRB(10, 10, 60, 60)),
+ path: ui.Path()..addOval(const ui.Rect.fromLTRB(10, 10, 60, 60)),
clipBehavior: ui.Clip.hardEdge,
color: const ui.Color(0xFFA0FFFF),
elevation: 4,
@@ -230,7 +230,7 @@
builder.pushPhysicalShape(
path: ui.Path()
..addRRect(ui.RRect.fromRectAndRadius(
- ui.Rect.fromLTRB(10, 10, 60, 60), ui.Radius.circular(10.0))),
+ const ui.Rect.fromLTRB(10, 10, 60, 60), const ui.Radius.circular(10.0))),
clipBehavior: ui.Clip.hardEdge,
color: const ui.Color(0xFFA0FFFF),
elevation: 4,
@@ -308,7 +308,7 @@
/// Update shape from arbitrary path to rect.
final SurfaceSceneBuilder builder4 = SurfaceSceneBuilder();
final ui.PhysicalShapeEngineLayer oldShapeLayer4 = builder4.pushPhysicalShape(
- path: ui.Path()..addOval(ui.Rect.fromLTRB(10, 10, 60, 60)),
+ path: ui.Path()..addOval(const ui.Rect.fromLTRB(10, 10, 60, 60)),
clipBehavior: ui.Clip.hardEdge,
color: const ui.Color(0xFF00FF00),
elevation: 6,
diff --git a/lib/web_ui/test/html/compositing/dom_mask_filter_golden_test.dart b/lib/web_ui/test/html/compositing/dom_mask_filter_golden_test.dart
index 601ed52..37baeeb 100644
--- a/lib/web_ui/test/html/compositing/dom_mask_filter_golden_test.dart
+++ b/lib/web_ui/test/html/compositing/dom_mask_filter_golden_test.dart
@@ -29,7 +29,7 @@
RecordingCanvas(const Rect.fromLTRB(0, 0, 500, 500));
for (int blurSigma = 1; blurSigma < 10; blurSigma += 2) {
final SurfacePaint paint = SurfacePaint()
- ..color = Color(0xFF2fdfd2)
+ ..color = const Color(0xFF2fdfd2)
..maskFilter = MaskFilter.blur(BlurStyle.normal, blurSigma.toDouble());
rc.drawRect(Rect.fromLTWH(15.0, 15.0 + blurSigma * 40, 200, 20), paint);
}
diff --git a/lib/web_ui/test/html/drawing/canvas_arc_golden_test.dart b/lib/web_ui/test/html/drawing/canvas_arc_golden_test.dart
index 84bf8c5..5454e1a 100644
--- a/lib/web_ui/test/html/drawing/canvas_arc_golden_test.dart
+++ b/lib/web_ui/test/html/drawing/canvas_arc_golden_test.dart
@@ -16,7 +16,7 @@
}
Future<void> testMain() async {
- final Rect region = Rect.fromLTWH(0, 0, 400, 600);
+ const Rect region = Rect.fromLTWH(0, 0, 400, 600);
late BitmapCanvas canvas;
@@ -29,21 +29,21 @@
});
test('draws arcs with largeArc , anticlockwise variations', () async {
- paintArc(canvas, Offset(0, 0),
+ paintArc(canvas, const Offset(0, 0),
largeArc: false, clockwise: false, distance: 20);
- paintArc(canvas, Offset(200, 0),
+ paintArc(canvas, const Offset(200, 0),
largeArc: true, clockwise: false, distance: 20);
- paintArc(canvas, Offset(0, 150),
+ paintArc(canvas, const Offset(0, 150),
largeArc: false, clockwise: true, distance: 20);
- paintArc(canvas, Offset(200, 150),
+ paintArc(canvas, const Offset(200, 150),
largeArc: true, clockwise: true, distance: 20);
- paintArc(canvas, Offset(0, 300),
+ paintArc(canvas, const Offset(0, 300),
largeArc: false, clockwise: false, distance: -20);
- paintArc(canvas, Offset(200, 300),
+ paintArc(canvas, const Offset(200, 300),
largeArc: true, clockwise: false, distance: -20);
- paintArc(canvas, Offset(0, 400),
+ paintArc(canvas, const Offset(0, 400),
largeArc: false, clockwise: true, distance: -20);
- paintArc(canvas, Offset(200, 400),
+ paintArc(canvas, const Offset(200, 400),
largeArc: true, clockwise: true, distance: -20);
@@ -52,14 +52,14 @@
});
test('Path.addArc that starts new path has correct start point', () async {
- final Rect rect = Rect.fromLTWH(20, 20, 200, 200);
+ const Rect rect = Rect.fromLTWH(20, 20, 200, 200);
final Path p = Path()
..fillType = PathFillType.evenOdd
..addRect(rect)
..addArc(Rect.fromCircle(center: rect.center,
radius: rect.size.shortestSide / 2), 0.25 * math.pi, 1.5 * math.pi);
canvas.drawPath(p, SurfacePaintData()
- ..color = Color(0xFFFF9800) // orange
+ ..color = const Color(0xFFFF9800) // orange
..style = PaintingStyle.fill);
html.document.body!.append(canvas.rootElement);
@@ -70,14 +70,14 @@
final Path path = Path();
path.moveTo(149.999999999999997, 50);
path.lineTo(149.999999999999997, 20);
- path.arcTo(Rect.fromLTRB(20, 20, 280, 280), 4.71238898038469,
+ path.arcTo(const Rect.fromLTRB(20, 20, 280, 280), 4.71238898038469,
5.759586531581287 - 4.71238898038469, true);
path.lineTo(236.60254037844385, 99.99999999999999);
- path.arcTo(Rect.fromLTRB(50, 50, 250, 250), 5.759586531581287,
+ path.arcTo(const Rect.fromLTRB(50, 50, 250, 250), 5.759586531581287,
4.71238898038469 - 5.759586531581287, true);
path.lineTo(149.999999999999997, 20);
canvas.drawPath(path, SurfacePaintData()
- ..color = Color(0xFFFF9800) // orange
+ ..color = const Color(0xFFFF9800) // orange
..style = PaintingStyle.fill);
html.document.body!.append(canvas.rootElement);
@@ -96,7 +96,7 @@
Rect.fromLTRB(startP.dx, startP.dy, endP.dx, endP.dy),
SurfacePaintData()
..strokeWidth = 1
- ..color = Color(0xFFFF9800) // orange
+ ..color = const Color(0xFFFF9800) // orange
..style = PaintingStyle.stroke);
final Path path = Path();
path.moveTo(startP.dx, startP.dy);
@@ -109,6 +109,6 @@
path,
SurfacePaintData()
..strokeWidth = 2
- ..color = Color(0x61000000) // black38
+ ..color = const Color(0x61000000) // black38
..style = PaintingStyle.stroke);
}
diff --git a/lib/web_ui/test/html/drawing/canvas_draw_color_golden_test.dart b/lib/web_ui/test/html/drawing/canvas_draw_color_golden_test.dart
index a6b42da..e304a41 100644
--- a/lib/web_ui/test/html/drawing/canvas_draw_color_golden_test.dart
+++ b/lib/web_ui/test/html/drawing/canvas_draw_color_golden_test.dart
@@ -31,7 +31,7 @@
});
test('drawColor should cover entire viewport', () async {
- final Rect region = Rect.fromLTWH(0, 0, 400, 400);
+ const Rect region = Rect.fromLTWH(0, 0, 400, 400);
final SurfaceSceneBuilder builder = SurfaceSceneBuilder();
final Picture testPicture = _drawTestPicture(region, useColor: true);
@@ -40,7 +40,7 @@
}, skip: true); // TODO: matchGolden fails when a div covers viewport.
test('drawPaint should cover entire viewport', () async {
- final Rect region = Rect.fromLTWH(0, 0, 400, 400);
+ const Rect region = Rect.fromLTWH(0, 0, 400, 400);
final SurfaceSceneBuilder builder = SurfaceSceneBuilder();
final Picture testPicture = _drawTestPicture(region, useColor: false);
@@ -51,14 +51,14 @@
Picture _drawTestPicture(Rect region, {bool useColor = false}) {
final EnginePictureRecorder recorder = PictureRecorder() as EnginePictureRecorder;
- final Rect r = Rect.fromLTWH(0, 0, 200, 200);
+ const Rect r = Rect.fromLTWH(0, 0, 200, 200);
final RecordingCanvas canvas = recorder.beginRecording(r);
canvas.drawRect(
region.deflate(8.0),
Paint() as SurfacePaint
..style = PaintingStyle.fill
- ..color = Color(0xFFE0E0E0)
+ ..color = const Color(0xFFE0E0E0)
);
canvas.transform(Matrix4.translationValues(50, 50, 0).storage);
diff --git a/lib/web_ui/test/html/drawing/canvas_draw_image_golden_test.dart b/lib/web_ui/test/html/drawing/canvas_draw_image_golden_test.dart
index 00601c0..627e6c4 100644
--- a/lib/web_ui/test/html/drawing/canvas_draw_image_golden_test.dart
+++ b/lib/web_ui/test/html/drawing/canvas_draw_image_golden_test.dart
@@ -31,7 +31,7 @@
final RecordingCanvas rc =
RecordingCanvas(const Rect.fromLTRB(0, 0, 400, 300));
rc.save();
- rc.drawImage(createTestImage(), Offset(0, 0), SurfacePaint());
+ rc.drawImage(createTestImage(), const Offset(0, 0), SurfacePaint());
rc.restore();
await canvasScreenshot(rc, 'draw_image',
region: const Rect.fromLTWH(0, 0, 500, 500));
@@ -43,7 +43,7 @@
rc.save();
rc.translate(50.0, 100.0);
rc.rotate(math.pi / 4.0);
- rc.drawImage(createTestImage(), Offset(0, 0), SurfacePaint());
+ rc.drawImage(createTestImage(), const Offset(0, 0), SurfacePaint());
rc.restore();
await canvasScreenshot(rc, 'draw_image_with_transform',
region: const Rect.fromLTWH(0, 0, 500, 500));
@@ -55,7 +55,7 @@
rc.save();
rc.translate(50.0, 100.0);
rc.rotate(math.pi / 4.0);
- rc.drawImage(createTestImage(), Offset(30, 20), SurfacePaint());
+ rc.drawImage(createTestImage(), const Offset(30, 20), SurfacePaint());
rc.restore();
await canvasScreenshot(rc, 'draw_image_with_transform_and_offset',
region: const Rect.fromLTWH(0, 0, 500, 500));
@@ -102,7 +102,7 @@
final double testHeight = testImage.height.toDouble();
rc.save();
rc.clipRRect(RRect.fromLTRBR(
- 100, 30, 2 * testWidth, 2 * testHeight, Radius.circular(16)));
+ 100, 30, 2 * testWidth, 2 * testHeight, const Radius.circular(16)));
rc.drawImageRect(
testImage,
Rect.fromLTRB(testWidth / 2, 0, testWidth, testHeight),
@@ -144,11 +144,11 @@
rc.drawImageRect(testImage, Rect.fromLTRB(0, 0, testWidth, testHeight),
Rect.fromLTRB(100, 30, 2 * testWidth, 2 * testHeight), SurfacePaint());
rc.drawCircle(
- Offset(100, 100),
+ const Offset(100, 100),
50.0,
SurfacePaint()
..strokeWidth = 3
- ..color = Color.fromARGB(128, 0, 0, 0));
+ ..color = const Color.fromARGB(128, 0, 0, 0));
rc.restore();
await canvasScreenshot(rc, 'draw_circle_on_image',
region: const Rect.fromLTWH(0, 0, 500, 500));
@@ -164,11 +164,11 @@
final double testWidth = testImage.width.toDouble();
final double testHeight = testImage.height.toDouble();
rc.drawCircle(
- Offset(100, 100),
+ const Offset(100, 100),
50.0,
SurfacePaint()
..strokeWidth = 3
- ..color = Color.fromARGB(128, 0, 0, 0));
+ ..color = const Color.fromARGB(128, 0, 0, 0));
rc.drawImageRect(testImage, Rect.fromLTRB(0, 0, testWidth, testHeight),
Rect.fromLTRB(100, 30, 2 * testWidth, 2 * testHeight), SurfacePaint());
rc.restore();
@@ -185,15 +185,15 @@
final Image testImage = createTestImage();
final double testWidth = testImage.width.toDouble();
final double testHeight = testImage.height.toDouble();
- rc.clipRect(Rect.fromLTRB(75, 75, 160, 160), ClipOp.intersect);
+ rc.clipRect(const Rect.fromLTRB(75, 75, 160, 160), ClipOp.intersect);
rc.drawImageRect(testImage, Rect.fromLTRB(0, 0, testWidth, testHeight),
Rect.fromLTRB(100, 30, 2 * testWidth, 2 * testHeight), SurfacePaint());
rc.drawCircle(
- Offset(100, 100),
+ const Offset(100, 100),
50.0,
SurfacePaint()
..strokeWidth = 3
- ..color = Color.fromARGB(128, 0, 0, 0));
+ ..color = const Color.fromARGB(128, 0, 0, 0));
rc.restore();
await canvasScreenshot(rc, 'draw_circle_on_image_clip_rect',
region: const Rect.fromLTWH(0, 0, 500, 500));
@@ -212,15 +212,15 @@
rc.translate(100, 100);
rc.rotate(math.pi / 4.0);
rc.translate(-100, -100);
- rc.clipRect(Rect.fromLTRB(75, 75, 160, 160), ClipOp.intersect);
+ rc.clipRect(const Rect.fromLTRB(75, 75, 160, 160), ClipOp.intersect);
rc.drawImageRect(testImage, Rect.fromLTRB(0, 0, testWidth, testHeight),
Rect.fromLTRB(100, 30, 2 * testWidth, 2 * testHeight), SurfacePaint());
rc.drawCircle(
- Offset(100, 100),
+ const Offset(100, 100),
50.0,
SurfacePaint()
..strokeWidth = 3
- ..color = Color.fromARGB(128, 0, 0, 0));
+ ..color = const Color.fromARGB(128, 0, 0, 0));
rc.restore();
await canvasScreenshot(rc, 'draw_circle_on_image_clip_rect_with_transform',
region: const Rect.fromLTWH(0, 0, 500, 500));
@@ -240,15 +240,15 @@
rc.rotate(-math.pi / 4.0);
rc.save();
rc.translate(-100, -100);
- rc.clipRect(Rect.fromLTRB(75, 75, 160, 160), ClipOp.intersect);
+ rc.clipRect(const Rect.fromLTRB(75, 75, 160, 160), ClipOp.intersect);
rc.drawImageRect(testImage, Rect.fromLTRB(0, 0, testWidth, testHeight),
Rect.fromLTRB(100, 30, 2 * testWidth, 2 * testHeight), SurfacePaint());
rc.drawCircle(
- Offset(100, 100),
+ const Offset(100, 100),
50.0,
SurfacePaint()
..strokeWidth = 3
- ..color = Color.fromARGB(128, 0, 0, 0));
+ ..color = const Color.fromARGB(128, 0, 0, 0));
rc.restore();
rc.restore();
await canvasScreenshot(rc, 'draw_circle_on_image_clip_rect_with_stack',
@@ -264,15 +264,15 @@
final Image testImage = createTestImage();
final double testWidth = testImage.width.toDouble();
final double testHeight = testImage.height.toDouble();
- rc.clipRRect(RRect.fromLTRBR(75, 75, 160, 160, Radius.circular(5)));
+ rc.clipRRect(RRect.fromLTRBR(75, 75, 160, 160, const Radius.circular(5)));
rc.drawImageRect(testImage, Rect.fromLTRB(0, 0, testWidth, testHeight),
Rect.fromLTRB(100, 30, 2 * testWidth, 2 * testHeight), SurfacePaint());
rc.drawCircle(
- Offset(100, 100),
+ const Offset(100, 100),
50.0,
SurfacePaint()
..strokeWidth = 3
- ..color = Color.fromARGB(128, 0, 0, 0));
+ ..color = const Color.fromARGB(128, 0, 0, 0));
rc.restore();
await canvasScreenshot(rc, 'draw_circle_on_image_clip_rrect',
region: const Rect.fromLTWH(0, 0, 500, 500));
@@ -296,11 +296,11 @@
rc.drawImageRect(testImage, Rect.fromLTRB(0, 0, testWidth, testHeight),
Rect.fromLTRB(100, 30, 2 * testWidth, 2 * testHeight), SurfacePaint());
rc.drawCircle(
- Offset(100, 100),
+ const Offset(100, 100),
50.0,
SurfacePaint()
..strokeWidth = 3
- ..color = Color.fromARGB(128, 0, 0, 0));
+ ..color = const Color.fromARGB(128, 0, 0, 0));
rc.restore();
await canvasScreenshot(rc, 'draw_circle_on_image_clip_path',
region: const Rect.fromLTWH(0, 0, 500, 500));
@@ -319,20 +319,20 @@
final Image testImage = createTestImage();
final double testWidth = testImage.width.toDouble();
final double testHeight = testImage.height.toDouble();
- final Color orange = Color(0xFFFF9800);
+ const Color orange = Color(0xFFFF9800);
final Paragraph paragraph1 = createTestParagraph(
'Should be below below below below below',
color: orange);
paragraph1.layout(const ParagraphConstraints(width: 400.0));
rc.drawParagraph(paragraph1, const Offset(20, 100));
rc.drawImageRect(testImage, Rect.fromLTRB(0, 0, testWidth, testHeight),
- Rect.fromLTRB(100, 100, 200, 200), SurfacePaint());
+ const Rect.fromLTRB(100, 100, 200, 200), SurfacePaint());
rc.drawRect(
- Rect.fromLTWH(50, 50, 100, 200),
+ const Rect.fromLTWH(50, 50, 100, 200),
SurfacePaint()
..strokeWidth = 3
- ..color = Color(0xA0000000));
- final Color cyan = Color(0xFF0097A7);
+ ..color = const Color(0xA0000000));
+ const Color cyan = Color(0xFF0097A7);
final Paragraph paragraph2 = createTestParagraph(
'Should be above above above above above',
color: cyan);
@@ -343,7 +343,7 @@
rc,
'draw_text_composite_order_below',
maxDiffRatePercent: 1.1,
- region: Rect.fromLTWH(0, 0, 350, 300),
+ region: const Rect.fromLTWH(0, 0, 350, 300),
);
});
@@ -353,13 +353,13 @@
final EnginePictureRecorder recorder = EnginePictureRecorder();
final Canvas canvas = Canvas(recorder, region);
final Image testImage = createNineSliceImage();
- canvas.clipRect(Rect.fromLTWH(0, 0, 420, 200));
- canvas.drawImageNine(testImage, Rect.fromLTWH(20, 20, 20, 20),
- Rect.fromLTWH(20, 20, 400, 400), SurfacePaint());
+ canvas.clipRect(const Rect.fromLTWH(0, 0, 420, 200));
+ canvas.drawImageNine(testImage, const Rect.fromLTWH(20, 20, 20, 20),
+ const Rect.fromLTWH(20, 20, 400, 400), SurfacePaint());
final Picture picture = recorder.endRecording();
final SurfaceSceneBuilder builder = SurfaceSceneBuilder();
- builder.addPicture(Offset(0, 0), picture);
+ builder.addPicture(const Offset(0, 0), picture);
// Wrap in <flt-scene> so that our CSS selectors kick in.
final html.Element sceneElement = html.Element.tag('flt-scene');
@@ -383,16 +383,16 @@
final EnginePictureRecorder recorder = EnginePictureRecorder();
final Canvas canvas = Canvas(recorder, region);
final Image testImage = createNineSliceImage();
- canvas.clipRect(Rect.fromLTWH(0, 0, 100, 100));
+ canvas.clipRect(const Rect.fromLTWH(0, 0, 100, 100));
// The testImage is 60x60 and the center slice is 20x20 so the edges
// of the image are 40x40. Drawing into a destination that is smaller
// than that will not provide enough room to draw the center portion.
- canvas.drawImageNine(testImage, Rect.fromLTWH(20, 20, 20, 20),
- Rect.fromLTWH(20, 20, 36, 36), SurfacePaint());
+ canvas.drawImageNine(testImage, const Rect.fromLTWH(20, 20, 20, 20),
+ const Rect.fromLTWH(20, 20, 36, 36), SurfacePaint());
final Picture picture = recorder.endRecording();
final SurfaceSceneBuilder builder = SurfaceSceneBuilder();
- builder.addPicture(Offset(0, 0), picture);
+ builder.addPicture(const Offset(0, 0), picture);
// Wrap in <flt-scene> so that our CSS selectors kick in.
final html.Element sceneElement = html.Element.tag('flt-scene');
@@ -434,12 +434,12 @@
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());
+ canvas.drawImage(createTestImage(), const Offset(0, 0), SurfacePaint());
final Matrix4 transform = Matrix4.identity()
..setRotationY(0.8)
..setEntry(3, 2, 0.0005); // perspective
canvas.transform(transform.storage);
- canvas.drawImage(createTestImage(), Offset(0, 100), SurfacePaint());
+ canvas.drawImage(createTestImage(), const Offset(0, 100), SurfacePaint());
await canvasScreenshot(canvas, 'draw_3d_image',
region: region,
maxDiffRatePercent: 6.0,
@@ -450,17 +450,17 @@
test('Should render image with perspective inside clip area', () async {
const Rect region = Rect.fromLTRB(0, 0, 200, 200);
final RecordingCanvas canvas = RecordingCanvas(region);
- canvas.drawRect(region, SurfacePaint()..color = Color(0xFFE0E0E0));
+ canvas.drawRect(region, SurfacePaint()..color = const Color(0xFFE0E0E0));
canvas.translate(10, 10);
- canvas.drawImage(createTestImage(), Offset(0, 0), SurfacePaint());
+ canvas.drawImage(createTestImage(), const Offset(0, 0), SurfacePaint());
final Matrix4 transform = Matrix4.identity()
..setRotationY(0.8)
..setEntry(3, 2, 0.0005); // perspective
canvas.transform(transform.storage);
canvas.clipRect(region, ClipOp.intersect);
- canvas.drawRect(Rect.fromLTWH(0, 0, 100, 200), SurfacePaint()..color = Color(0x801080E0));
- canvas.drawImage(createTestImage(), Offset(0, 100), SurfacePaint());
- canvas.drawRect(Rect.fromLTWH(50, 150, 50, 20), SurfacePaint()..color = Color(0x80000000));
+ canvas.drawRect(const Rect.fromLTWH(0, 0, 100, 200), SurfacePaint()..color = const Color(0x801080E0));
+ canvas.drawImage(createTestImage(), const Offset(0, 100), SurfacePaint());
+ canvas.drawRect(const Rect.fromLTWH(50, 150, 50, 20), SurfacePaint()..color = const Color(0x80000000));
await canvasScreenshot(canvas, 'draw_3d_image_clipped',
region: region,
maxDiffRatePercent: 5.0,
@@ -470,21 +470,21 @@
test('Should render rect with perspective transform', () async {
const Rect region = Rect.fromLTRB(0, 0, 400, 400);
final RecordingCanvas canvas = RecordingCanvas(region);
- canvas.drawRect(region, SurfacePaint()..color = Color(0xFFE0E0E0));
+ canvas.drawRect(region, SurfacePaint()..color = const Color(0xFFE0E0E0));
canvas.translate(20, 20);
- canvas.drawRect(Rect.fromLTWH(0, 0, 100, 40),
- SurfacePaint()..color = Color(0xFF000000));
+ canvas.drawRect(const Rect.fromLTWH(0, 0, 100, 40),
+ SurfacePaint()..color = const Color(0xFF000000));
final Matrix4 transform = Matrix4.identity()
..setRotationY(0.8)
..setEntry(3, 2, 0.001); // perspective
canvas.transform(transform.storage);
canvas.clipRect(region, ClipOp.intersect);
- canvas.drawRect(Rect.fromLTWH(0, 60, 120, 40), SurfacePaint()..color = Color(0x801080E0));
- canvas.drawRect(Rect.fromLTWH(300, 250, 120, 40), SurfacePaint()..color = Color(0x80E010E0));
- canvas.drawRRect(RRect.fromRectAndRadius(Rect.fromLTWH(0, 120, 160, 40), Radius.circular(5)),
- SurfacePaint()..color = Color(0x801080E0));
- canvas.drawRRect(RRect.fromRectAndRadius(Rect.fromLTWH(300, 320, 90, 40), Radius.circular(20)),
- SurfacePaint()..color = Color(0x80E010E0));
+ canvas.drawRect(const Rect.fromLTWH(0, 60, 120, 40), SurfacePaint()..color = const Color(0x801080E0));
+ canvas.drawRect(const Rect.fromLTWH(300, 250, 120, 40), SurfacePaint()..color = const Color(0x80E010E0));
+ canvas.drawRRect(RRect.fromRectAndRadius(const Rect.fromLTWH(0, 120, 160, 40), const Radius.circular(5)),
+ SurfacePaint()..color = const Color(0x801080E0));
+ canvas.drawRRect(RRect.fromRectAndRadius(const Rect.fromLTWH(300, 320, 90, 40), const Radius.circular(20)),
+ SurfacePaint()..color = const Color(0x80E010E0));
await canvasScreenshot(canvas, 'draw_3d_rect_clipped',
region: region,
maxDiffRatePercent: 1.0,
@@ -494,22 +494,22 @@
test('Should render color and ovals with perspective transform', () async {
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);
+ canvas.drawRect(region, SurfacePaint()..color = const Color(0xFFFF0000));
+ canvas.drawColor(const Color(0xFFE0E0E0), BlendMode.src);
canvas.translate(20, 20);
- canvas.drawRect(Rect.fromLTWH(0, 0, 100, 40),
- SurfacePaint()..color = Color(0xFF000000));
+ canvas.drawRect(const Rect.fromLTWH(0, 0, 100, 40),
+ SurfacePaint()..color = const Color(0xFF000000));
final Matrix4 transform = Matrix4.identity()
..setRotationY(0.8)
..setEntry(3, 2, 0.001); // perspective
canvas.transform(transform.storage);
canvas.clipRect(region, ClipOp.intersect);
- canvas.drawOval(Rect.fromLTWH(0, 120, 130, 40),
- SurfacePaint()..color = Color(0x801080E0));
- canvas.drawOval(Rect.fromLTWH(300, 290, 90, 40),
- SurfacePaint()..color = Color(0x80E010E0));
- canvas.drawCircle(Offset(60, 240), 50, SurfacePaint()..color = Color(0x801080E0));
- canvas.drawCircle(Offset(360, 370), 30, SurfacePaint()..color = Color(0x80E010E0));
+ canvas.drawOval(const Rect.fromLTWH(0, 120, 130, 40),
+ SurfacePaint()..color = const Color(0x801080E0));
+ canvas.drawOval(const Rect.fromLTWH(300, 290, 90, 40),
+ SurfacePaint()..color = const Color(0x80E010E0));
+ canvas.drawCircle(const Offset(60, 240), 50, SurfacePaint()..color = const Color(0x801080E0));
+ canvas.drawCircle(const Offset(360, 370), 30, SurfacePaint()..color = const Color(0x80E010E0));
await canvasScreenshot(canvas, 'draw_3d_oval_clipped',
region: region,
maxDiffRatePercent: 1.0,
@@ -519,29 +519,29 @@
test('Should render path with perspective transform', () async {
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);
+ canvas.drawRect(region, SurfacePaint()..color = const Color(0xFFFF0000));
+ canvas.drawColor(const Color(0xFFE0E0E0), BlendMode.src);
canvas.translate(20, 20);
- canvas.drawRect(Rect.fromLTWH(0, 0, 100, 20),
- SurfacePaint()..color = Color(0xFF000000));
+ canvas.drawRect(const Rect.fromLTWH(0, 0, 100, 20),
+ SurfacePaint()..color = const Color(0xFF000000));
final Matrix4 transform = Matrix4.identity()
..setRotationY(0.8)
..setEntry(3, 2, 0.001); // perspective
canvas.transform(transform.storage);
- canvas.drawRect(Rect.fromLTWH(0, 120, 130, 40),
- SurfacePaint()..color = Color(0x801080E0));
- canvas.drawOval(Rect.fromLTWH(300, 290, 90, 40),
- SurfacePaint()..color = Color(0x80E010E0));
+ canvas.drawRect(const Rect.fromLTWH(0, 120, 130, 40),
+ SurfacePaint()..color = const Color(0x801080E0));
+ canvas.drawOval(const Rect.fromLTWH(300, 290, 90, 40),
+ SurfacePaint()..color = const Color(0x80E010E0));
final Path path = Path();
path.moveTo(50, 50);
path.lineTo(100, 50);
path.lineTo(100, 100);
path.close();
- canvas.drawPath(path, SurfacePaint()..color = Color(0x801080E0));
+ canvas.drawPath(path, SurfacePaint()..color = const Color(0x801080E0));
- canvas.drawCircle(Offset(50, 50), 4, SurfacePaint()..color = Color(0xFF000000));
- canvas.drawCircle(Offset(100, 100), 4, SurfacePaint()..color = Color(0xFF000000));
- canvas.drawCircle(Offset(100, 50), 4, SurfacePaint()..color = Color(0xFF000000));
+ canvas.drawCircle(const Offset(50, 50), 4, SurfacePaint()..color = const Color(0xFF000000));
+ canvas.drawCircle(const Offset(100, 100), 4, SurfacePaint()..color = const Color(0xFF000000));
+ canvas.drawCircle(const Offset(100, 50), 4, SurfacePaint()..color = const Color(0xFF000000));
await canvasScreenshot(canvas, 'draw_3d_path',
region: region,
maxDiffRatePercent: 1.0,
@@ -551,30 +551,30 @@
test('Should render path with perspective transform', () async {
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);
+ canvas.drawRect(region, SurfacePaint()..color = const Color(0xFFFF0000));
+ canvas.drawColor(const Color(0xFFE0E0E0), BlendMode.src);
canvas.translate(20, 20);
- canvas.drawRect(Rect.fromLTWH(0, 0, 100, 20),
- SurfacePaint()..color = Color(0xFF000000));
+ canvas.drawRect(const Rect.fromLTWH(0, 0, 100, 20),
+ SurfacePaint()..color = const Color(0xFF000000));
final Matrix4 transform = Matrix4.identity()
..setRotationY(0.8)
..setEntry(3, 2, 0.001); // perspective
canvas.transform(transform.storage);
//canvas.clipRect(region, ClipOp.intersect);
- canvas.drawRect(Rect.fromLTWH(0, 120, 130, 40),
- SurfacePaint()..color = Color(0x801080E0));
- canvas.drawOval(Rect.fromLTWH(300, 290, 90, 40),
- SurfacePaint()..color = Color(0x80E010E0));
+ canvas.drawRect(const Rect.fromLTWH(0, 120, 130, 40),
+ SurfacePaint()..color = const Color(0x801080E0));
+ canvas.drawOval(const Rect.fromLTWH(300, 290, 90, 40),
+ SurfacePaint()..color = const Color(0x80E010E0));
final Path path = Path();
path.moveTo(50, 50);
path.lineTo(100, 50);
path.lineTo(100, 100);
path.close();
- canvas.drawPath(path, SurfacePaint()..color = Color(0x801080E0));
+ canvas.drawPath(path, SurfacePaint()..color = const Color(0x801080E0));
- canvas.drawCircle(Offset(50, 50), 4, SurfacePaint()..color = Color(0xFF000000));
- canvas.drawCircle(Offset(100, 100), 4, SurfacePaint()..color = Color(0xFF000000));
- canvas.drawCircle(Offset(100, 50), 4, SurfacePaint()..color = Color(0xFF000000));
+ canvas.drawCircle(const Offset(50, 50), 4, SurfacePaint()..color = const Color(0xFF000000));
+ canvas.drawCircle(const Offset(100, 100), 4, SurfacePaint()..color = const Color(0xFF000000));
+ canvas.drawCircle(const Offset(100, 50), 4, SurfacePaint()..color = const Color(0xFF000000));
await canvasScreenshot(canvas, 'draw_3d_path_clipped',
region: region,
maxDiffRatePercent: 1.0,
diff --git a/lib/web_ui/test/html/drawing/canvas_draw_picture_golden_test.dart b/lib/web_ui/test/html/drawing/canvas_draw_picture_golden_test.dart
index 7b46d6f..ea43649 100644
--- a/lib/web_ui/test/html/drawing/canvas_draw_picture_golden_test.dart
+++ b/lib/web_ui/test/html/drawing/canvas_draw_picture_golden_test.dart
@@ -11,7 +11,7 @@
import '../screenshot.dart';
-final Rect region = Rect.fromLTWH(0, 0, 500, 100);
+const Rect region = Rect.fromLTWH(0, 0, 500, 100);
void main() {
internalBootstrapBrowserTest(() => testMain);
@@ -94,7 +94,7 @@
final RecordingCanvas canvas =
recorder.beginRecording(const Rect.fromLTRB(0, 0, 100, 100));
canvas.drawPicture(greenRectPicture);
- builder.addPicture(Offset(10, 10), recorder.endRecording());
+ builder.addPicture(const Offset(10, 10), recorder.endRecording());
await sceneScreenshot(builder, 'canvas_draw_picture_in_picture_rect',
region: region);
@@ -112,9 +112,9 @@
canvas.debugEnforceArbitraryPaint();
if (clipped) {
canvas.clipRRect(
- RRect.fromLTRBR(0, 0, targetSize, targetSize, Radius.circular(4)));
+ RRect.fromLTRBR(0, 0, targetSize, targetSize, const Radius.circular(4)));
}
- canvas.drawImageRect(sharedImage!, Rect.fromLTWH(0, 0, 20, 20),
+ canvas.drawImageRect(sharedImage!, const Rect.fromLTWH(0, 0, 20, 20),
Rect.fromLTWH(0, 0, targetSize, targetSize), makePaint());
final Picture picture = recorder.endRecording();
builder.addPicture(
@@ -127,7 +127,7 @@
final EnginePictureRecorder recorder = PictureRecorder() as EnginePictureRecorder;
final RecordingCanvas canvas =
recorder.beginRecording(const Rect.fromLTRB(0, 0, 100, 100));
- canvas.drawRect(Rect.fromLTWH(20, 20, 50, 50),
+ canvas.drawRect(const Rect.fromLTWH(20, 20, 50, 50),
makePaint()..color = const Color(0xFF00FF00));
return recorder.endRecording();
}
diff --git a/lib/web_ui/test/html/drawing/canvas_draw_points_golden_test.dart b/lib/web_ui/test/html/drawing/canvas_draw_points_golden_test.dart
index 0fe95cf..f871e38 100644
--- a/lib/web_ui/test/html/drawing/canvas_draw_points_golden_test.dart
+++ b/lib/web_ui/test/html/drawing/canvas_draw_points_golden_test.dart
@@ -17,7 +17,7 @@
}
Future<void> testMain() async {
- final Rect region = Rect.fromLTWH(0, 0, 400, 600);
+ const Rect region = Rect.fromLTWH(0, 0, 400, 600);
late BitmapCanvas canvas;
@@ -32,22 +32,22 @@
test('draws points in all 3 modes', () async {
final SurfacePaintData paint = SurfacePaintData();
paint.strokeWidth = 2.0;
- paint.color = Color(0xFF0000FF);
- final Float32List points = offsetListToFloat32List(<Offset>[
+ paint.color = const Color(0xFF0000FF);
+ final Float32List points = offsetListToFloat32List(const <Offset>[
Offset(10, 10),
Offset(50, 10),
Offset(70, 70),
Offset(170, 70)
]);
canvas.drawPoints(PointMode.points, points, paint);
- final Float32List points2 = offsetListToFloat32List(<Offset>[
+ final Float32List points2 = offsetListToFloat32List(const <Offset>[
Offset(10, 110),
Offset(50, 110),
Offset(70, 170),
Offset(170, 170)
]);
canvas.drawPoints(PointMode.lines, points2, paint);
- final Float32List points3 = offsetListToFloat32List(<Offset>[
+ final Float32List points3 = offsetListToFloat32List(const <Offset>[
Offset(10, 210),
Offset(50, 210),
Offset(70, 270),
@@ -61,17 +61,17 @@
test('Should draw points with strokeWidth', () async {
final SurfacePaintData nullStrokePaint =
- SurfacePaintData()..color = Color(0xffff0000);
+ SurfacePaintData()..color = const Color(0xffff0000);
canvas.drawPoints(PointMode.lines, Float32List.fromList(<double>[
30.0, 20.0, 200.0, 20.0]), nullStrokePaint);
final SurfacePaintData strokePaint1 = SurfacePaintData()
..strokeWidth = 1.0
- ..color = Color(0xff0000ff);
+ ..color = const Color(0xff0000ff);
canvas.drawPoints(PointMode.lines, Float32List.fromList(<double>[
30.0, 30.0, 200.0, 30.0]), strokePaint1);
final SurfacePaintData strokePaint3 = SurfacePaintData()
..strokeWidth = 3.0
- ..color = Color(0xff00a000);
+ ..color = const Color(0xff00a000);
canvas.drawPoints(PointMode.lines, Float32List.fromList(<double>[
30.0, 40.0, 200.0, 40.0]), strokePaint3);
canvas.drawPoints(PointMode.points, Float32List.fromList(<double>[
diff --git a/lib/web_ui/test/html/drawing/canvas_lines_golden_test.dart b/lib/web_ui/test/html/drawing/canvas_lines_golden_test.dart
index fba2a26..349b83c 100644
--- a/lib/web_ui/test/html/drawing/canvas_lines_golden_test.dart
+++ b/lib/web_ui/test/html/drawing/canvas_lines_golden_test.dart
@@ -16,7 +16,7 @@
}
Future<void> testMain() async {
- final Rect region = Rect.fromLTWH(0, 0, 300, 300);
+ const Rect region = Rect.fromLTWH(0, 0, 300, 300);
late BitmapCanvas canvas;
@@ -42,33 +42,33 @@
..strokeWidth = 1.0
..style = PaintingStyle.stroke;
final SurfacePaintData paint1 = SurfacePaintData()
- ..color = Color(0xFF9E9E9E) // Colors.grey
+ ..color = const Color(0xFF9E9E9E) // Colors.grey
..strokeWidth = 1.0
..style = PaintingStyle.stroke;
final SurfacePaintData paint2 = SurfacePaintData()
- ..color = Color(0x7fff0000)
+ ..color = const Color(0x7fff0000)
..strokeWidth = 1.0
..style = PaintingStyle.stroke;
final SurfacePaintData paint3 = SurfacePaintData()
- ..color = Color(0xFF4CAF50) //Colors.green
+ ..color = const Color(0xFF4CAF50) //Colors.green
..strokeWidth = 1.0
..style = PaintingStyle.stroke;
// Draw markers around 100x100 box
- canvas.drawLine(Offset(50, 40), Offset(148, 40), nullPaint);
- canvas.drawLine(Offset(50, 50), Offset(52, 50), paint1);
- canvas.drawLine(Offset(150, 50), Offset(148, 50), paint1);
- canvas.drawLine(Offset(50, 150), Offset(52, 150), paint1);
- canvas.drawLine(Offset(150, 150), Offset(148, 150), paint1);
+ canvas.drawLine(const Offset(50, 40), const Offset(148, 40), nullPaint);
+ canvas.drawLine(const Offset(50, 50), const Offset(52, 50), paint1);
+ canvas.drawLine(const Offset(150, 50), const Offset(148, 50), paint1);
+ canvas.drawLine(const Offset(50, 150), const Offset(52, 150), paint1);
+ canvas.drawLine(const Offset(150, 150), const Offset(148, 150), paint1);
// Draw diagonal
- canvas.drawLine(Offset(50, 50), Offset(150, 150), paint2);
+ canvas.drawLine(const Offset(50, 50), const Offset(150, 150), paint2);
// Draw horizontal
paint3.strokeWidth = 1.0;
- paint3.color = Color(0xFFFF0000);
- canvas.drawLine(Offset(50, 55), Offset(150, 55), paint3);
+ paint3.color = const Color(0xFFFF0000);
+ canvas.drawLine(const Offset(50, 55), const Offset(150, 55), paint3);
paint3.strokeWidth = 2.0;
- paint3.color = Color(0xFF2196F3); // Colors.blue;
- canvas.drawLine(Offset(50, 60), Offset(150, 60), paint3);
+ paint3.color = const Color(0xFF2196F3); // Colors.blue;
+ canvas.drawLine(const Offset(50, 60), const Offset(150, 60), paint3);
paint3.strokeWidth = 4.0;
- paint3.color = Color(0xFFFF9800); // Colors.orange;
- canvas.drawLine(Offset(50, 70), Offset(150, 70), paint3);
+ paint3.color = const Color(0xFFFF9800); // Colors.orange;
+ canvas.drawLine(const Offset(50, 70), const Offset(150, 70), paint3);
}
diff --git a/lib/web_ui/test/html/drawing/canvas_rect_golden_test.dart b/lib/web_ui/test/html/drawing/canvas_rect_golden_test.dart
index 3ccf6d3..fb81bfd 100644
--- a/lib/web_ui/test/html/drawing/canvas_rect_golden_test.dart
+++ b/lib/web_ui/test/html/drawing/canvas_rect_golden_test.dart
@@ -16,7 +16,7 @@
}
Future<void> testMain() async {
- final Rect region = Rect.fromLTWH(0, 0, 150, 420);
+ const Rect region = Rect.fromLTWH(0, 0, 150, 420);
late BitmapCanvas canvas;
@@ -39,28 +39,28 @@
void paintRects(BitmapCanvas canvas) {
- canvas.drawRect(Rect.fromLTRB(30, 40, 100, 50),
+ canvas.drawRect(const Rect.fromLTRB(30, 40, 100, 50),
SurfacePaintData()
- ..color = Color(0xFF4CAF50) //Colors.green
+ ..color = const Color(0xFF4CAF50) //Colors.green
..strokeWidth = 1.0
..style = PaintingStyle.stroke);
// swap left and right.
- canvas.drawRect(Rect.fromLTRB(100, 150, 30, 140),
+ canvas.drawRect(const Rect.fromLTRB(100, 150, 30, 140),
SurfacePaintData()
- ..color = Color(0xFFF44336) //Colors.red
+ ..color = const Color(0xFFF44336) //Colors.red
..strokeWidth = 1.0
..style = PaintingStyle.stroke);
// Repeat above for fill
- canvas.drawRect(Rect.fromLTRB(30, 240, 100, 250),
+ canvas.drawRect(const Rect.fromLTRB(30, 240, 100, 250),
SurfacePaintData()
- ..color = Color(0xFF4CAF50) //Colors.green
+ ..color = const Color(0xFF4CAF50) //Colors.green
..style = PaintingStyle.fill);
// swap left and right.
- canvas.drawRect(Rect.fromLTRB(100, 350, 30, 340),
+ canvas.drawRect(const Rect.fromLTRB(100, 350, 30, 340),
SurfacePaintData()
- ..color = Color(0xFFF44336) //Colors.red
+ ..color = const Color(0xFFF44336) //Colors.red
..style = PaintingStyle.fill);
}
diff --git a/lib/web_ui/test/html/drawing/canvas_rrect_golden_test.dart b/lib/web_ui/test/html/drawing/canvas_rrect_golden_test.dart
index 0717d6c..f7d6d43 100644
--- a/lib/web_ui/test/html/drawing/canvas_rrect_golden_test.dart
+++ b/lib/web_ui/test/html/drawing/canvas_rrect_golden_test.dart
@@ -16,7 +16,7 @@
}
Future<void> testMain() async {
- final Rect region = Rect.fromLTWH(8, 8, 500, 100); // Compensate for old scuba tester padding
+ const Rect region = Rect.fromLTWH(8, 8, 500, 100); // Compensate for old scuba tester padding
late BitmapCanvas canvas;
@@ -56,13 +56,13 @@
canvas.translate(35, 320);
canvas.drawRRect(
RRect.fromRectAndRadius(
- Rect.fromLTRB(-30, -100, 30, -300),
- Radius.circular(30)),
+ const Rect.fromLTRB(-30, -100, 30, -300),
+ const Radius.circular(30)),
niceRRectPaint);
canvas.drawPath(Path()..moveTo(0, 0)..lineTo(20, 0), niceRRectPaint);
html.document.body!.append(canvas.rootElement);
await matchGoldenFile('canvas_rrect_flipped.png',
- region: Rect.fromLTWH(0, 0, 100, 200));
+ region: const Rect.fromLTWH(0, 0, 100, 200));
});
test('round rect with big radius scale down smaller radius', () async {
diff --git a/lib/web_ui/test/html/drawing/canvas_stroke_joins_golden_test.dart b/lib/web_ui/test/html/drawing/canvas_stroke_joins_golden_test.dart
index ab82aaa..6eff9c3 100644
--- a/lib/web_ui/test/html/drawing/canvas_stroke_joins_golden_test.dart
+++ b/lib/web_ui/test/html/drawing/canvas_stroke_joins_golden_test.dart
@@ -16,7 +16,7 @@
}
Future<void> testMain() async {
- final Rect region = Rect.fromLTWH(0, 0, 300, 300);
+ const Rect region = Rect.fromLTWH(0, 0, 300, 300);
late BitmapCanvas canvas;
@@ -39,19 +39,20 @@
}
void paintStrokeJoins(BitmapCanvas canvas) {
- canvas.drawRect(Rect.fromLTRB(0, 0, 300, 300),
+ canvas.drawRect(const Rect.fromLTRB(0, 0, 300, 300),
SurfacePaintData()
- ..color = Color(0xFFFFFFFF)
+ ..color = const Color(0xFFFFFFFF)
..style = PaintingStyle.fill); // white
- Offset start = Offset(20, 10);
- Offset mid = Offset(120, 10);
- Offset end = Offset(120, 20);
+ Offset start = const Offset(20, 10);
+ Offset mid = const Offset(120, 10);
+ Offset end = const Offset(120, 20);
final List<StrokeCap> strokeCaps = <StrokeCap>[StrokeCap.butt, StrokeCap.round, StrokeCap.square];
for (final StrokeCap cap in strokeCaps) {
final List<StrokeJoin> joints = <StrokeJoin>[StrokeJoin.miter, StrokeJoin.bevel, StrokeJoin.round];
- final List<Color> colors = <Color>[Color(0xFFF44336), Color(0xFF4CAF50), Color(0xFF2196F3)]; // red, green, blue
+ const List<Color> colors = <Color>[
+ Color(0xFFF44336), Color(0xFF4CAF50), Color(0xFF2196F3)]; // red, green, blue
for (int i = 0; i < joints.length; i++) {
final StrokeJoin join = joints[i];
final Color color = colors[i % colors.length];
diff --git a/lib/web_ui/test/html/drawing/canvas_stroke_rects_golden_test.dart b/lib/web_ui/test/html/drawing/canvas_stroke_rects_golden_test.dart
index 3ed09d8..9339bca 100644
--- a/lib/web_ui/test/html/drawing/canvas_stroke_rects_golden_test.dart
+++ b/lib/web_ui/test/html/drawing/canvas_stroke_rects_golden_test.dart
@@ -17,7 +17,7 @@
}
Future<void> testMain() async {
- final Rect region = Rect.fromLTWH(0, 0, 300, 300);
+ const Rect region = Rect.fromLTWH(0, 0, 300, 300);
late BitmapCanvas canvas;
@@ -40,31 +40,31 @@
}
void paintSideBySideRects(BitmapCanvas canvas) {
- canvas.drawRect(Rect.fromLTRB(0, 0, 300, 300),
+ canvas.drawRect(const Rect.fromLTRB(0, 0, 300, 300),
SurfacePaintData()
- ..color = Color(0xFFFFFFFF)
+ ..color = const Color(0xFFFFFFFF)
..style = PaintingStyle.fill); // white
- canvas.drawRect(Rect.fromLTRB(0, 20, 40, 60),
+ canvas.drawRect(const Rect.fromLTRB(0, 20, 40, 60),
SurfacePaintData()
..style = PaintingStyle.fill
- ..color = Color(0x7f0000ff));
- canvas.drawRect(Rect.fromLTRB(40, 20, 80, 60),
+ ..color = const Color(0x7f0000ff));
+ canvas.drawRect(const Rect.fromLTRB(40, 20, 80, 60),
SurfacePaintData()
..style = PaintingStyle.stroke
..strokeWidth = 4
- ..color = Color(0x7fff0000));
+ ..color = const Color(0x7fff0000));
// Rotate 30 degrees (in rad: deg*pi/180)
canvas.transform(Matrix4.rotationZ(30.0 * math.pi / 180.0).storage);
- canvas.drawRect(Rect.fromLTRB(100, 60, 140, 100),
+ canvas.drawRect(const Rect.fromLTRB(100, 60, 140, 100),
SurfacePaintData()
..style = PaintingStyle.fill
- ..color = Color(0x7fff00ff));
- canvas.drawRect(Rect.fromLTRB(140, 60, 180, 100),
+ ..color = const Color(0x7fff00ff));
+ canvas.drawRect(const Rect.fromLTRB(140, 60, 180, 100),
SurfacePaintData()
..style = PaintingStyle.stroke
..strokeWidth = 4
- ..color = Color(0x7fffff00));
+ ..color = const Color(0x7fffff00));
}
diff --git a/lib/web_ui/test/html/drawing/conic_golden_test.dart b/lib/web_ui/test/html/drawing/conic_golden_test.dart
index 6434f43..ce028b6 100644
--- a/lib/web_ui/test/html/drawing/conic_golden_test.dart
+++ b/lib/web_ui/test/html/drawing/conic_golden_test.dart
@@ -16,7 +16,7 @@
}
Future<void> testMain() async {
- final Rect region = Rect.fromLTWH(8, 8, 600, 800); // Compensate for old scuba tester padding
+ const Rect region = Rect.fromLTWH(8, 8, 600, 800); // Compensate for old scuba tester padding
Future<void> testPath(Path path, String scubaFileName) async {
const Rect canvasBounds = Rect.fromLTWH(0, 0, 600, 800);
diff --git a/lib/web_ui/test/html/drawing/draw_vertices_golden_test.dart b/lib/web_ui/test/html/drawing/draw_vertices_golden_test.dart
index eae813e..cdaa6b4 100644
--- a/lib/web_ui/test/html/drawing/draw_vertices_golden_test.dart
+++ b/lib/web_ui/test/html/drawing/draw_vertices_golden_test.dart
@@ -88,7 +88,7 @@
420.0
]));
await _testVertices('draw_vertices_hairline_triangle', vertices,
- BlendMode.srcOver, Paint()..color = Color.fromARGB(255, 0, 128, 0));
+ BlendMode.srcOver, Paint()..color = const Color.fromARGB(255, 0, 128, 0));
});
test(
@@ -192,7 +192,7 @@
]));
await _testVertices('draw_vertices_hairline_triangle_fan', vertices,
- BlendMode.srcOver, Paint()..color = Color.fromARGB(255, 0, 128, 0));
+ BlendMode.srcOver, Paint()..color = const Color.fromARGB(255, 0, 128, 0));
});
test('Should draw hairline triangleStrip.', () async {
@@ -213,7 +213,7 @@
420.0
]));
await _testVertices('draw_vertices_hairline_triangle_strip', vertices,
- BlendMode.srcOver, Paint()..color = Color.fromARGB(255, 0, 128, 0));
+ BlendMode.srcOver, Paint()..color = const Color.fromARGB(255, 0, 128, 0));
});
test('Should draw triangles with colors.', () async {
@@ -244,7 +244,7 @@
colors: colors);
await _testVertices('draw_vertices_triangles', vertices, BlendMode.srcOver,
- Paint()..color = Color.fromARGB(255, 0, 128, 0));
+ Paint()..color = const Color.fromARGB(255, 0, 128, 0));
});
test('Should draw triangles with colors and indices.', () async {
@@ -306,7 +306,7 @@
colors: colors);
await _testVertices('draw_vertices_triangle_fan', vertices,
- BlendMode.srcOver, Paint()..color = Color.fromARGB(255, 0, 128, 0));
+ BlendMode.srcOver, Paint()..color = const Color.fromARGB(255, 0, 128, 0));
});
test('Should draw triangleStrip with colors.', () async {
@@ -336,7 +336,7 @@
]),
colors: colors);
await _testVertices('draw_vertices_triangle_strip', vertices,
- BlendMode.srcOver, Paint()..color = Color.fromARGB(255, 0, 128, 0));
+ BlendMode.srcOver, Paint()..color = const Color.fromARGB(255, 0, 128, 0));
});
Future<void> testTexture(TileMode tileMode, String filename) async {
diff --git a/lib/web_ui/test/html/paragraph/bidi_golden_test.dart b/lib/web_ui/test/html/paragraph/bidi_golden_test.dart
index 2292f75..49b5aca 100644
--- a/lib/web_ui/test/html/paragraph/bidi_golden_test.dart
+++ b/lib/web_ui/test/html/paragraph/bidi_golden_test.dart
@@ -57,7 +57,7 @@
const double height = 40;
// Border for ltr paragraphs.
- final Rect ltrBox = Rect.fromLTWH(0, 0, 320, 5 * height).inflate(5).translate(10, 10);
+ final Rect ltrBox = const Rect.fromLTWH(0, 0, 320, 5 * height).inflate(5).translate(10, 10);
canvas.drawRect(
ltrBox,
SurfacePaintData()
@@ -96,7 +96,7 @@
const double height = 40;
// Border for ltr paragraphs.
- final Rect ltrBox = Rect.fromLTWH(0, 0, 320, 5 * height).inflate(5).translate(10, 10);
+ final Rect ltrBox = const Rect.fromLTWH(0, 0, 320, 5 * height).inflate(5).translate(10, 10);
canvas.drawRect(
ltrBox,
SurfacePaintData()
@@ -161,7 +161,7 @@
const double height = 40;
// Border for ltr paragraphs.
- final Rect ltrBox = Rect.fromLTWH(0, 0, 320, 5 * height).inflate(5).translate(10, 10);
+ final Rect ltrBox = const Rect.fromLTWH(0, 0, 320, 5 * height).inflate(5).translate(10, 10);
canvas.drawRect(
ltrBox,
SurfacePaintData()
@@ -200,7 +200,7 @@
const double height = 40;
// Border for ltr paragraphs.
- final Rect ltrBox = Rect.fromLTWH(0, 0, 320, 5 * height).inflate(5).translate(10, 10);
+ final Rect ltrBox = const Rect.fromLTWH(0, 0, 320, 5 * height).inflate(5).translate(10, 10);
canvas.drawRect(
ltrBox,
SurfacePaintData()
@@ -263,13 +263,13 @@
}
test('multiline bidi', () {
- final Rect bounds = Rect.fromLTWH(0, 0, 400, 500);
+ const Rect bounds = Rect.fromLTWH(0, 0, 400, 500);
final BitmapCanvas canvas = BitmapCanvas(bounds, RenderStrategy());
const double height = 95;
// Border for ltr paragraphs.
- final Rect ltrBox = Rect.fromLTWH(0, 0, 150, 5 * height).inflate(5).translate(10, 10);
+ final Rect ltrBox = const Rect.fromLTWH(0, 0, 150, 5 * height).inflate(5).translate(10, 10);
canvas.drawRect(
ltrBox,
SurfacePaintData()
@@ -307,7 +307,7 @@
const double height = 95;
- final Rect ltrBox = Rect.fromLTWH(0, 0, 150, 5 * height).inflate(5).translate(10, 10);
+ final Rect ltrBox = const Rect.fromLTWH(0, 0, 150, 5 * height).inflate(5).translate(10, 10);
canvas.drawRect(
ltrBox,
SurfacePaintData()
@@ -383,7 +383,7 @@
const double height = 95;
// Border for ltr paragraphs.
- final Rect ltrBox = Rect.fromLTWH(0, 0, 150, 5 * height).inflate(5).translate(10, 10);
+ final Rect ltrBox = const Rect.fromLTWH(0, 0, 150, 5 * height).inflate(5).translate(10, 10);
canvas.drawRect(
ltrBox,
SurfacePaintData()
@@ -422,7 +422,7 @@
const double height = 95;
// Border for ltr paragraphs.
- final Rect ltrBox = Rect.fromLTWH(0, 0, 150, 5 * height).inflate(5).translate(10, 10);
+ final Rect ltrBox = const Rect.fromLTWH(0, 0, 150, 5 * height).inflate(5).translate(10, 10);
canvas.drawRect(
ltrBox,
SurfacePaintData()
@@ -502,7 +502,7 @@
const double height = 95;
// Border for ltr paragraphs.
- final Rect ltrBox = Rect.fromLTWH(0, 0, 150, 5 * height).inflate(5).translate(10, 10);
+ final Rect ltrBox = const Rect.fromLTWH(0, 0, 150, 5 * height).inflate(5).translate(10, 10);
canvas.drawRect(
ltrBox,
SurfacePaintData()
@@ -541,7 +541,7 @@
const double height = 95;
// Border for ltr paragraphs.
- final Rect ltrBox = Rect.fromLTWH(0, 0, 150, 5 * height).inflate(5).translate(10, 10);
+ final Rect ltrBox = const Rect.fromLTWH(0, 0, 150, 5 * height).inflate(5).translate(10, 10);
canvas.drawRect(
ltrBox,
SurfacePaintData()
diff --git a/lib/web_ui/test/html/paragraph/general_golden_test.dart b/lib/web_ui/test/html/paragraph/general_golden_test.dart
index c51d841..261c452 100644
--- a/lib/web_ui/test/html/paragraph/general_golden_test.dart
+++ b/lib/web_ui/test/html/paragraph/general_golden_test.dart
@@ -180,9 +180,9 @@
canvas.restore();
}
- drawParagraphAt(Offset(50.0, 0.0), TextAlign.left);
- drawParagraphAt(Offset(150.0, 0.0), TextAlign.center);
- drawParagraphAt(Offset(250.0, 0.0), TextAlign.right);
+ drawParagraphAt(const Offset(50.0, 0.0), TextAlign.left);
+ drawParagraphAt(const Offset(150.0, 0.0), TextAlign.center);
+ drawParagraphAt(const Offset(250.0, 0.0), TextAlign.right);
}
test('alignment and transform', () {
@@ -234,7 +234,7 @@
html.document.body!.style.fontSize = '100px';
final DomCanvas canvas = DomCanvas(domRenderer.createElement('flt-picture'));
- Offset offset = Offset(10.0, 10.0);
+ Offset offset = const Offset(10.0, 10.0);
final CanvasParagraph paragraph = rich(
EngineParagraphStyle(fontFamily: 'Roboto'),
@@ -372,13 +372,13 @@
void testFontFeatures(EngineCanvas canvas) {
const String text = 'Aa Bb Dd Ee Ff Difficult';
- final FontFeature enableSmallCaps = FontFeature('smcp');
- final FontFeature disableSmallCaps = FontFeature('smcp', 0);
+ const FontFeature enableSmallCaps = FontFeature('smcp');
+ const FontFeature disableSmallCaps = FontFeature('smcp', 0);
const String numeric = '123.4560';
- final FontFeature enableOnum = FontFeature('onum');
+ const FontFeature enableOnum = FontFeature('onum');
- final FontFeature disableLigatures = FontFeature('liga', 0);
+ const FontFeature disableLigatures = FontFeature('liga', 0);
final CanvasParagraph paragraph = rich(
EngineParagraphStyle(fontFamily: 'Roboto'),
diff --git a/lib/web_ui/test/html/paragraph/placeholders_golden_test.dart b/lib/web_ui/test/html/paragraph/placeholders_golden_test.dart
index b9d7c43..f8d1ae1 100644
--- a/lib/web_ui/test/html/paragraph/placeholders_golden_test.dart
+++ b/lib/web_ui/test/html/paragraph/placeholders_golden_test.dart
@@ -129,7 +129,7 @@
const Rect bounds = Rect.fromLTWH(0, 0, 420, 300);
final BitmapCanvas canvas = BitmapCanvas(bounds, RenderStrategy());
- Offset offset = Offset(10, 10);
+ Offset offset = const Offset(10, 10);
// First paragraph with a placeholder at the beginning.
final CanvasParagraph paragraph1 = rich(
diff --git a/lib/web_ui/test/html/paragraph/shadows_golden_test.dart b/lib/web_ui/test/html/paragraph/shadows_golden_test.dart
index e37feb5..8d16908 100644
--- a/lib/web_ui/test/html/paragraph/shadows_golden_test.dart
+++ b/lib/web_ui/test/html/paragraph/shadows_golden_test.dart
@@ -29,8 +29,8 @@
fontSize: 32.0,
color: blue,
shadows: <Shadow>[
- Shadow(color: red, blurRadius:2.0, offset: Offset(4.0, 2.0)),
- Shadow(color: green, blurRadius: 3.0),
+ const Shadow(color: red, blurRadius:2.0, offset: Offset(4.0, 2.0)),
+ const Shadow(color: green, blurRadius: 3.0),
],
));
builder.addText('Lorem ');
@@ -38,7 +38,7 @@
color: green,
background: Paint()..color = yellow,
shadows: <Shadow>[
- Shadow(color: black, blurRadius: 10.0),
+ const Shadow(color: black, blurRadius: 10.0),
],
));
builder.addText('ipsum');
diff --git a/lib/web_ui/test/html/paragraph/text_placeholders_golden_test.dart b/lib/web_ui/test/html/paragraph/text_placeholders_golden_test.dart
index 6ea8599..3ea6514 100644
--- a/lib/web_ui/test/html/paragraph/text_placeholders_golden_test.dart
+++ b/lib/web_ui/test/html/paragraph/text_placeholders_golden_test.dart
@@ -135,5 +135,5 @@
);
builder.pushStyle(TextStyle(color: blue, fontFamily: 'Roboto', fontSize: 14));
builder.addText(after);
- return builder.build()..layout(ParagraphConstraints(width: 200.0));
+ return builder.build()..layout(const ParagraphConstraints(width: 200.0));
}
diff --git a/lib/web_ui/test/html/paragraph/text_style_golden_test.dart b/lib/web_ui/test/html/paragraph/text_style_golden_test.dart
index dfc9447..017ca92 100644
--- a/lib/web_ui/test/html/paragraph/text_style_golden_test.dart
+++ b/lib/web_ui/test/html/paragraph/text_style_golden_test.dart
@@ -177,9 +177,9 @@
fontFamily: 'Roboto',
fontSize: 30,
shadows: <Shadow>[
- Shadow(
+ const Shadow(
blurRadius: 0,
- color: const Color.fromRGBO(255, 0, 255, 1.0),
+ color: Color.fromRGBO(255, 0, 255, 1.0),
offset: Offset(10, 5),
),
],
@@ -199,14 +199,14 @@
fontFamily: 'Roboto',
fontSize: 30,
shadows: <Shadow>[
- Shadow(
+ const Shadow(
blurRadius: 0,
- color: const Color.fromRGBO(255, 0, 255, 1.0),
+ color: Color.fromRGBO(255, 0, 255, 1.0),
offset: Offset(10, 5),
),
- Shadow(
+ const Shadow(
blurRadius: 0,
- color: const Color.fromRGBO(0, 255, 255, 1.0),
+ color: Color.fromRGBO(0, 255, 255, 1.0),
offset: Offset(-10, -5),
),
],
@@ -241,7 +241,7 @@
return scuba.diffCanvasScreenshot(
canvas,
'text_strut_style_disabled',
- region: Rect.fromLTRB(0, 0, 100, 100),
+ region: const Rect.fromLTRB(0, 0, 100, 100),
maxDiffRatePercent: 0.0,
);
});
diff --git a/lib/web_ui/test/html/path_to_svg_golden_test.dart b/lib/web_ui/test/html/path_to_svg_golden_test.dart
index 05a6c44..a93a9a3 100644
--- a/lib/web_ui/test/html/path_to_svg_golden_test.dart
+++ b/lib/web_ui/test/html/path_to_svg_golden_test.dart
@@ -23,7 +23,7 @@
}
Future<void> testMain() async {
- final Rect region =
+ const Rect region =
Rect.fromLTWH(8, 8, 600, 400); // Compensate for old scuba tester padding
Future<void> testPath(Path path, String scubaFileName,
diff --git a/lib/web_ui/test/html/path_transform_golden_test.dart b/lib/web_ui/test/html/path_transform_golden_test.dart
index 40a2b6e..12e4d3b 100644
--- a/lib/web_ui/test/html/path_transform_golden_test.dart
+++ b/lib/web_ui/test/html/path_transform_golden_test.dart
@@ -80,7 +80,7 @@
final RecordingCanvas rc =
RecordingCanvas(const Rect.fromLTRB(0, 0, 500, 500));
final Path path = Path();
- path.addRect(Rect.fromLTRB(50, 40, 300, 100));
+ path.addRect(const Rect.fromLTRB(50, 40, 300, 100));
rc.drawPath(
path,
SurfacePaint()
@@ -170,8 +170,8 @@
final Path path = Path();
path.moveTo(350, 280);
- path.arcToPoint(Offset(450, 90),
- radius: Radius.elliptical(200, 50),
+ path.arcToPoint(const Offset(450, 90),
+ radius: const Radius.elliptical(200, 50),
rotation: -math.pi / 6.0,
largeArc: true,
clockwise: true);
@@ -204,7 +204,7 @@
RecordingCanvas(const Rect.fromLTRB(0, 0, 500, 500));
final Path path = Path();
- path.addRRect(RRect.fromLTRBR(50, 50, 300, 200, Radius.elliptical(4, 8)));
+ path.addRRect(RRect.fromLTRBR(50, 50, 300, 200, const Radius.elliptical(4, 8)));
rc.drawPath(
path,
diff --git a/lib/web_ui/test/html/picture_golden_test.dart b/lib/web_ui/test/html/picture_golden_test.dart
index 27b63b6..1ab71d7 100644
--- a/lib/web_ui/test/html/picture_golden_test.dart
+++ b/lib/web_ui/test/html/picture_golden_test.dart
@@ -19,12 +19,12 @@
group('Picture', () {
test('toImage produces an image', () async {
final EnginePictureRecorder recorder = EnginePictureRecorder();
- final RecordingCanvas canvas = recorder.beginRecording(ui.Rect.fromLTRB(0, 0, 200, 100));
+ final RecordingCanvas canvas = recorder.beginRecording(const ui.Rect.fromLTRB(0, 0, 200, 100));
canvas.drawCircle(
const ui.Offset(100, 50),
40,
SurfacePaint()
- ..color = ui.Color.fromARGB(255, 255, 100, 100),
+ ..color = const ui.Color.fromARGB(255, 255, 100, 100),
);
final ui.Picture picture = recorder.endRecording();
final HtmlImage image = await picture.toImage(200, 100) as HtmlImage;
@@ -35,7 +35,7 @@
try {
await matchGoldenFile(
'picture_to_image.png',
- region: ui.Rect.fromLTRB(0, 0, 200, 100),
+ region: const ui.Rect.fromLTRB(0, 0, 200, 100),
);
} finally {
image.imgElement.remove();
diff --git a/lib/web_ui/test/html/recording_canvas_golden_test.dart b/lib/web_ui/test/html/recording_canvas_golden_test.dart
index 059db58..9e33a58 100644
--- a/lib/web_ui/test/html/recording_canvas_golden_test.dart
+++ b/lib/web_ui/test/html/recording_canvas_golden_test.dart
@@ -514,7 +514,7 @@
rc.translate(50.0, 100.0);
final Path path = Path();
// Draw a vertical small line (caret).
- path.addPolygon(<Offset>[Offset(0, 10), Offset(20,5), Offset(50,10)],
+ path.addPolygon(const <Offset>[Offset(0, 10), Offset(20,5), Offset(50,10)],
false);
path.lineTo(60, 80);
path.lineTo(0, 80);
@@ -549,14 +549,14 @@
},
(RecordingCanvas canvas, SurfacePaint paint) {
canvas.drawRRect(
- RRect.fromLTRBR(0.0, 0.0, 20.0, 20.0, Radius.circular(7.0)),
+ RRect.fromLTRBR(0.0, 0.0, 20.0, 20.0, const Radius.circular(7.0)),
paint,
);
},
(RecordingCanvas canvas, SurfacePaint paint) {
canvas.drawDRRect(
- RRect.fromLTRBR(0.0, 0.0, 20.0, 20.0, Radius.circular(5.0)),
- RRect.fromLTRBR(4.0, 4.0, 16.0, 16.0, Radius.circular(5.0)),
+ RRect.fromLTRBR(0.0, 0.0, 20.0, 20.0, const Radius.circular(5.0)),
+ RRect.fromLTRBR(4.0, 4.0, 16.0, 16.0, const Radius.circular(5.0)),
paint,
);
},
diff --git a/lib/web_ui/test/html/shaders/gradient_golden_test.dart b/lib/web_ui/test/html/shaders/gradient_golden_test.dart
index 7ba2f83..98a0684 100644
--- a/lib/web_ui/test/html/shaders/gradient_golden_test.dart
+++ b/lib/web_ui/test/html/shaders/gradient_golden_test.dart
@@ -62,23 +62,23 @@
final SurfacePaint borderPaint = SurfacePaint()
..style = PaintingStyle.stroke
..strokeWidth = 1
- ..color = Color(0xFF000000);
+ ..color = const Color(0xFF000000);
- final List<Color> colors = <Color>[
+ const List<Color> colors = <Color>[
Color(0xFF000000),
Color(0xFFFF3C38),
Color(0xFFFF8C42),
Color(0xFFFFF275),
Color(0xFF6699CC),
Color(0xFF656D78),];
- final List<double> stops = <double>[0.0, 0.05, 0.4, 0.6, 0.9, 1.0];
+ const List<double> stops = <double>[0.0, 0.05, 0.4, 0.6, 0.9, 1.0];
- GradientSweep sweepGradient = GradientSweep(Offset(0.5, 0.5),
+ GradientSweep sweepGradient = GradientSweep(const Offset(0.5, 0.5),
colors, stops, TileMode.clamp,
0, 360.0 / 180.0 * math.pi,
Matrix4.rotationZ(math.pi / 6.0).storage);
- final GradientSweep sweepGradientRotated = GradientSweep(Offset(0.5, 0.5),
+ final GradientSweep sweepGradientRotated = GradientSweep(const Offset(0.5, 0.5),
colors, stops, TileMode.clamp,
0, 360.0 / 180.0 * math.pi,
Matrix4.rotationZ(math.pi / 6.0).storage);
@@ -86,7 +86,7 @@
const double kBoxWidth = 150;
const double kBoxHeight = 80;
// Gradient with default center.
- Rect rectBounds = Rect.fromLTWH(10, 20, kBoxWidth, kBoxHeight);
+ Rect rectBounds = const Rect.fromLTWH(10, 20, kBoxWidth, kBoxHeight);
canvas.drawRect(rectBounds,
SurfacePaint()..shader = engineGradientToShader(sweepGradient, rectBounds));
canvas.drawRect(rectBounds, borderPaint);
@@ -98,7 +98,7 @@
canvas.drawRect(rectBounds, borderPaint);
// Gradient with start/endangle.
- sweepGradient = GradientSweep(Offset(0.5, 0.5),
+ sweepGradient = GradientSweep(const Offset(0.5, 0.5),
colors, stops, TileMode.clamp,
math.pi / 6, 3 * math.pi / 4,
Matrix4.rotationZ(math.pi / 6.0).storage);
@@ -109,8 +109,8 @@
canvas.drawRect(rectBounds, borderPaint);
// Tile mode repeat
- rectBounds = Rect.fromLTWH(10, 110, kBoxWidth, kBoxHeight);
- sweepGradient = GradientSweep(Offset(0.5, 0.5),
+ rectBounds = const Rect.fromLTWH(10, 110, kBoxWidth, kBoxHeight);
+ sweepGradient = GradientSweep(const Offset(0.5, 0.5),
colors, stops, TileMode.repeated,
math.pi / 6, 3 * math.pi / 4,
Matrix4.rotationZ(math.pi / 6.0).storage);
@@ -121,7 +121,7 @@
// Tile mode mirror
rectBounds = rectBounds.translate(kBoxWidth + 10, 0);
- sweepGradient = GradientSweep(Offset(0.5, 0.5),
+ sweepGradient = GradientSweep(const Offset(0.5, 0.5),
colors, stops, TileMode.mirror,
math.pi / 6, 3 * math.pi / 4,
Matrix4.rotationZ(math.pi / 6.0).storage);
@@ -141,9 +141,9 @@
final SurfacePaint borderPaint = SurfacePaint()
..style = PaintingStyle.stroke
..strokeWidth = 1
- ..color = Color(0xFF000000);
+ ..color = const Color(0xFF000000);
- final List<Color> colors = <Color>[
+ const List<Color> colors = <Color>[
Color(0xFF000000),
Color(0xFFFF3C38),
Color(0xFFFF8C42),
@@ -152,12 +152,12 @@
Color(0xFF656D78),];
final List<double> stops = <double>[0.0, 0.05, 0.4, 0.6, 0.9, 1.0];
- GradientSweep sweepGradient = GradientSweep(Offset(0.5, 0.5),
+ GradientSweep sweepGradient = GradientSweep(const Offset(0.5, 0.5),
colors, stops, TileMode.clamp,
0, 360.0 / 180.0 * math.pi,
Matrix4.rotationZ(math.pi / 6.0).storage);
- final GradientSweep sweepGradientRotated = GradientSweep(Offset(0.5, 0.5),
+ final GradientSweep sweepGradientRotated = GradientSweep(const Offset(0.5, 0.5),
colors, stops, TileMode.clamp,
0, 360.0 / 180.0 * math.pi,
Matrix4.rotationZ(math.pi / 6.0).storage);
@@ -165,7 +165,7 @@
const double kBoxWidth = 150;
const double kBoxHeight = 80;
// Gradient with default center.
- Rect rectBounds = Rect.fromLTWH(10, 20, kBoxWidth, kBoxHeight);
+ Rect rectBounds = const Rect.fromLTWH(10, 20, kBoxWidth, kBoxHeight);
canvas.drawOval(rectBounds,
SurfacePaint()..shader = engineGradientToShader(sweepGradient, rectBounds));
canvas.drawRect(rectBounds, borderPaint);
@@ -177,7 +177,7 @@
canvas.drawRect(rectBounds, borderPaint);
// Gradient with start/endangle.
- sweepGradient = GradientSweep(Offset(0.5, 0.5),
+ sweepGradient = GradientSweep(const Offset(0.5, 0.5),
colors, stops, TileMode.clamp,
math.pi / 6, 3 * math.pi / 4,
Matrix4.rotationZ(math.pi / 6.0).storage);
@@ -188,8 +188,8 @@
canvas.drawRect(rectBounds, borderPaint);
// Tile mode repeat
- rectBounds = Rect.fromLTWH(10, 110, kBoxWidth, kBoxHeight);
- sweepGradient = GradientSweep(Offset(0.5, 0.5),
+ rectBounds = const Rect.fromLTWH(10, 110, kBoxWidth, kBoxHeight);
+ sweepGradient = GradientSweep(const Offset(0.5, 0.5),
colors, stops, TileMode.repeated,
math.pi / 6, 3 * math.pi / 4,
Matrix4.rotationZ(math.pi / 6.0).storage);
@@ -200,7 +200,7 @@
// Tile mode mirror
rectBounds = rectBounds.translate(kBoxWidth + 10, 0);
- sweepGradient = GradientSweep(Offset(0.5, 0.5),
+ sweepGradient = GradientSweep(const Offset(0.5, 0.5),
colors, stops, TileMode.mirror,
math.pi / 6, 3 * math.pi / 4,
Matrix4.rotationZ(math.pi / 6.0).storage);
@@ -220,23 +220,23 @@
final SurfacePaint borderPaint = SurfacePaint()
..style = PaintingStyle.stroke
..strokeWidth = 1
- ..color = Color(0xFF000000);
+ ..color = const Color(0xFF000000);
- final List<Color> colors = <Color>[
+ const List<Color> colors = <Color>[
Color(0xFF000000),
Color(0xFFFF3C38),
Color(0xFFFF8C42),
Color(0xFFFFF275),
Color(0xFF6699CC),
Color(0xFF656D78),];
- final List<double> stops = <double>[0.0, 0.05, 0.4, 0.6, 0.9, 1.0];
+ const List<double> stops = <double>[0.0, 0.05, 0.4, 0.6, 0.9, 1.0];
- GradientSweep sweepGradient = GradientSweep(Offset(0.5, 0.5),
+ GradientSweep sweepGradient = GradientSweep(const Offset(0.5, 0.5),
colors, stops, TileMode.clamp,
0, 360.0 / 180.0 * math.pi,
Matrix4.rotationZ(math.pi / 6.0).storage);
- final GradientSweep sweepGradientRotated = GradientSweep(Offset(0.5, 0.5),
+ final GradientSweep sweepGradientRotated = GradientSweep(const Offset(0.5, 0.5),
colors, stops, TileMode.clamp,
0, 360.0 / 180.0 * math.pi,
Matrix4.rotationZ(math.pi / 6.0).storage);
@@ -244,7 +244,7 @@
const double kBoxWidth = 150;
const double kBoxHeight = 80;
// Gradient with default center.
- Rect rectBounds = Rect.fromLTWH(10, 20, kBoxWidth, kBoxHeight);
+ Rect rectBounds = const Rect.fromLTWH(10, 20, kBoxWidth, kBoxHeight);
Path path = samplePathFromRect(rectBounds);
canvas.drawPath(path,
SurfacePaint()..shader = engineGradientToShader(sweepGradient, rectBounds));
@@ -258,7 +258,7 @@
canvas.drawRect(rectBounds, borderPaint);
// Gradient with start/endangle.
- sweepGradient = GradientSweep(Offset(0.5, 0.5),
+ sweepGradient = GradientSweep(const Offset(0.5, 0.5),
colors, stops, TileMode.clamp,
math.pi / 6, 3 * math.pi / 4,
Matrix4.rotationZ(math.pi / 6.0).storage);
@@ -270,8 +270,8 @@
canvas.drawRect(rectBounds, borderPaint);
// Tile mode repeat
- rectBounds = Rect.fromLTWH(10, 110, kBoxWidth, kBoxHeight);
- sweepGradient = GradientSweep(Offset(0.5, 0.5),
+ rectBounds = const Rect.fromLTWH(10, 110, kBoxWidth, kBoxHeight);
+ sweepGradient = GradientSweep(const Offset(0.5, 0.5),
colors, stops, TileMode.repeated,
math.pi / 6, 3 * math.pi / 4,
Matrix4.rotationZ(math.pi / 6.0).storage);
@@ -283,7 +283,7 @@
// Tile mode mirror
rectBounds = rectBounds.translate(kBoxWidth + 10, 0);
- sweepGradient = GradientSweep(Offset(0.5, 0.5),
+ sweepGradient = GradientSweep(const Offset(0.5, 0.5),
colors, stops, TileMode.mirror,
math.pi / 6, 3 * math.pi / 4,
Matrix4.rotationZ(math.pi / 6.0).storage);
@@ -305,34 +305,34 @@
final SurfacePaint borderPaint = SurfacePaint()
..style = PaintingStyle.stroke
..strokeWidth = 1
- ..color = Color(0xFF000000);
+ ..color = const Color(0xFF000000);
- final List<Color> colors = <Color>[
+ const List<Color> colors = <Color>[
Color(0xFF000000),
Color(0xFFFF3C38),
Color(0xFFFF8C42),
Color(0xFFFFF275),
Color(0xFF6699CC),
Color(0xFF656D78),];
- final List<double> stops = <double>[0.0, 0.05, 0.4, 0.6, 0.9, 1.0];
+ const List<double> stops = <double>[0.0, 0.05, 0.4, 0.6, 0.9, 1.0];
- GradientLinear linearGradient = GradientLinear(Offset(50, 50),
- Offset(200,130),
+ GradientLinear linearGradient = GradientLinear(const Offset(50, 50),
+ const Offset(200,130),
colors, stops, TileMode.clamp,
Matrix4.identity().storage);
const double kBoxWidth = 150;
const double kBoxHeight = 80;
// Gradient with default center.
- Rect rectBounds = Rect.fromLTWH(10, 20, kBoxWidth, kBoxHeight);
+ Rect rectBounds = const Rect.fromLTWH(10, 20, kBoxWidth, kBoxHeight);
canvas.drawRect(rectBounds,
SurfacePaint()..shader = engineLinearGradientToShader(linearGradient, rectBounds));
canvas.drawRect(rectBounds, borderPaint);
// Tile mode repeat
- rectBounds = Rect.fromLTWH(10, 110, kBoxWidth, kBoxHeight);
- linearGradient = GradientLinear(Offset(50, 50),
- Offset(200,130),
+ rectBounds = const Rect.fromLTWH(10, 110, kBoxWidth, kBoxHeight);
+ linearGradient = GradientLinear(const Offset(50, 50),
+ const Offset(200,130),
colors, stops, TileMode.repeated,
Matrix4.identity().storage);
@@ -353,22 +353,22 @@
final SurfacePaint borderPaint = SurfacePaint()
..style = PaintingStyle.stroke
..strokeWidth = 1
- ..color = Color(0xFF000000);
+ ..color = const Color(0xFF000000);
- final List<Color> colors = <Color>[
+ const List<Color> colors = <Color>[
Color(0xFF000000),
Color(0xFFFF3C38)];
- final List<double> stops = <double>[0.0, 10.0];
+ const List<double> stops = <double>[0.0, 10.0];
- final GradientLinear linearGradient = GradientLinear(Offset(50, 50),
- Offset(200,130),
+ final GradientLinear linearGradient = GradientLinear(const Offset(50, 50),
+ const Offset(200,130),
colors, stops, TileMode.clamp,
Matrix4.identity().storage);
const double kBoxWidth = 150;
const double kBoxHeight = 80;
// Gradient with default center.
- final Rect rectBounds = Rect.fromLTWH(10, 20, kBoxWidth, kBoxHeight);
+ const Rect rectBounds = Rect.fromLTWH(10, 20, kBoxWidth, kBoxHeight);
canvas.drawRect(rectBounds,
SurfacePaint()..shader = engineLinearGradientToShader(linearGradient, rectBounds));
canvas.drawRect(rectBounds, borderPaint);
@@ -388,34 +388,34 @@
final SurfacePaint borderPaint = SurfacePaint()
..style = PaintingStyle.stroke
..strokeWidth = 1
- ..color = Color(0xFF000000);
+ ..color = const Color(0xFF000000);
- final List<Color> colors = <Color>[
+ const List<Color> colors = <Color>[
Color(0xFF000000),
Color(0xFFFF3C38),
Color(0xFFFF8C42),
Color(0xFFFFF275),
Color(0xFF6699CC),
Color(0xFF656D78),];
- final List<double> stops = <double>[0.0, 0.05, 0.4, 0.6, 0.9, 1.0];
+ const List<double> stops = <double>[0.0, 0.05, 0.4, 0.6, 0.9, 1.0];
- GradientLinear linearGradient = GradientLinear(Offset(50, 50),
- Offset(200,130),
+ GradientLinear linearGradient = GradientLinear(const Offset(50, 50),
+ const Offset(200,130),
colors, stops, TileMode.clamp,
Matrix4.identity().storage);
const double kBoxWidth = 150;
const double kBoxHeight = 80;
// Gradient with default center.
- Rect rectBounds = Rect.fromLTWH(10, 20, kBoxWidth, kBoxHeight);
+ Rect rectBounds = const Rect.fromLTWH(10, 20, kBoxWidth, kBoxHeight);
canvas.drawRect(rectBounds,
SurfacePaint()..shader = engineLinearGradientToShader(linearGradient, rectBounds));
canvas.drawRect(rectBounds, borderPaint);
// Tile mode repeat
- rectBounds = Rect.fromLTWH(10, 110, kBoxWidth, kBoxHeight);
- linearGradient = GradientLinear(Offset(50, 50),
- Offset(200,130),
+ rectBounds = const Rect.fromLTWH(10, 110, kBoxWidth, kBoxHeight);
+ linearGradient = GradientLinear(const Offset(50, 50),
+ const Offset(200,130),
colors, stops, TileMode.clamp,
Matrix4.identity().storage);
diff --git a/lib/web_ui/test/html/shaders/linear_gradient_golden_test.dart b/lib/web_ui/test/html/shaders/linear_gradient_golden_test.dart
index 3b99048..67db2f1 100644
--- a/lib/web_ui/test/html/shaders/linear_gradient_golden_test.dart
+++ b/lib/web_ui/test/html/shaders/linear_gradient_golden_test.dart
@@ -33,7 +33,7 @@
final SurfacePaint paint = SurfacePaint()..shader = Gradient.linear(
Offset(shaderRect.left, shaderRect.top),
Offset(shaderRect.right, shaderRect.bottom),
- <Color>[Color(0xFFcfdfd2), Color(0xFF042a85)]);
+ const <Color>[Color(0xFFcfdfd2), Color(0xFF042a85)]);
rc.drawRect(shaderRect, paint);
expect(rc.renderStrategy.hasArbitraryPaint, isTrue);
await canvasScreenshot(rc, 'linear_gradient_rect',
@@ -59,12 +59,12 @@
..shader = Gradient.linear(
Offset(shaderRect.left, shaderRect.top),
Offset(shaderRect.right, shaderRect.bottom),
- <Color>[Color(0xFFFF0000), Color(0xFF042a85)],
+ const <Color>[Color(0xFFFF0000), Color(0xFF042a85)],
null,
TileMode.clamp,
matrix.toFloat64());
rc.drawRect(shaderRect, SurfacePaint()
- ..color = Color(0xFF000000));
+ ..color = const Color(0xFF000000));
rc.drawOval(shaderRect, paint);
yOffset += 120;
}
@@ -82,8 +82,8 @@
final SurfacePaint paint = SurfacePaint()..shader = Gradient.linear(
Offset(shaderRect.left, shaderRect.top),
Offset(shaderRect.right, shaderRect.bottom),
- <Color>[Color(0xFFcfdfd2), Color(0xFF042a85)]);
- rc.drawRRect(RRect.fromRectAndRadius(shaderRect, Radius.circular(16)), paint);
+ const <Color>[Color(0xFFcfdfd2), Color(0xFF042a85)]);
+ rc.drawRRect(RRect.fromRectAndRadius(shaderRect, const Radius.circular(16)), paint);
expect(rc.renderStrategy.hasArbitraryPaint, isTrue);
await canvasScreenshot(rc, 'linear_gradient_rounded_rect',
region: screenRect,
@@ -101,14 +101,14 @@
..shader = Gradient.linear(
Offset(shaderRect.left, shaderRect.top),
Offset(shaderRect.left + shaderRect.width / 2, shaderRect.top),
- <Color>[Color(0xFFFF0000), Color(0xFF042a85)],
+ const <Color>[Color(0xFFFF0000), Color(0xFF042a85)],
null,
TileMode.repeated,
Matrix4
.rotationZ((angle / 180) * math.pi)
.toFloat64());
rc.drawRect(shaderRect, SurfacePaint()
- ..color = Color(0xFF000000));
+ ..color = const Color(0xFF000000));
rc.drawOval(shaderRect, paint);
yOffset += 120;
}
@@ -128,14 +128,14 @@
..shader = Gradient.linear(
Offset(shaderRect.left, shaderRect.top),
Offset(shaderRect.left + shaderRect.width / 2, shaderRect.top),
- <Color>[Color(0xFFFF0000), Color(0xFF042a85)],
+ const <Color>[Color(0xFFFF0000), Color(0xFF042a85)],
null,
TileMode.mirror,
Matrix4
.rotationZ((angle / 180) * math.pi)
.toFloat64());
rc.drawRect(shaderRect, SurfacePaint()
- ..color = Color(0xFF000000));
+ ..color = const Color(0xFF000000));
rc.drawOval(shaderRect, paint);
yOffset += 120;
}
diff --git a/lib/web_ui/test/html/shaders/shader_mask_golden_test.dart b/lib/web_ui/test/html/shaders/shader_mask_golden_test.dart
index 9254540..84c1daf 100644
--- a/lib/web_ui/test/html/shaders/shader_mask_golden_test.dart
+++ b/lib/web_ui/test/html/shaders/shader_mask_golden_test.dart
@@ -47,58 +47,58 @@
test('Renders shader mask with linear gradient BlendMode dst', () async {
_renderCirclesScene(BlendMode.dst);
await matchGoldenFile('shadermask_linear_dst.png',
- region: Rect.fromLTWH(0, 0, 360, 200));
+ region: const Rect.fromLTWH(0, 0, 360, 200));
}, skip: isWebkit);
/// Should render the gradient only where circles have alpha channel.
test('Renders shader mask with linear gradient BlendMode srcIn', () async {
_renderCirclesScene(BlendMode.srcIn);
await matchGoldenFile('shadermask_linear_srcin.png',
- region: Rect.fromLTWH(0, 0, 360, 200));
+ region: const Rect.fromLTWH(0, 0, 360, 200));
}, skip: isWebkit);
test('Renders shader mask with linear gradient BlendMode color', () async {
_renderCirclesScene(BlendMode.color);
await matchGoldenFile('shadermask_linear_color.png',
- region: Rect.fromLTWH(0, 0, 360, 200));
+ region: const Rect.fromLTWH(0, 0, 360, 200));
}, skip: isWebkit);
test('Renders shader mask with linear gradient BlendMode xor', () async {
_renderCirclesScene(BlendMode.xor);
await matchGoldenFile('shadermask_linear_xor.png',
- region: Rect.fromLTWH(0, 0, 360, 200));
+ region: const Rect.fromLTWH(0, 0, 360, 200));
}, skip: isWebkit);
test('Renders shader mask with linear gradient BlendMode plus', () async {
_renderCirclesScene(BlendMode.plus);
await matchGoldenFile('shadermask_linear_plus.png',
- region: Rect.fromLTWH(0, 0, 360, 200));
+ region: const Rect.fromLTWH(0, 0, 360, 200));
}, skip: isWebkit);
test('Renders shader mask with linear gradient BlendMode modulate', () async {
_renderCirclesScene(BlendMode.modulate);
await matchGoldenFile('shadermask_linear_modulate.png',
- region: Rect.fromLTWH(0, 0, 360, 200));
+ region: const Rect.fromLTWH(0, 0, 360, 200));
}, skip: isWebkit);
test('Renders shader mask with linear gradient BlendMode overlay', () async {
_renderCirclesScene(BlendMode.overlay);
await matchGoldenFile('shadermask_linear_overlay.png',
- region: Rect.fromLTWH(0, 0, 360, 200));
+ region: const Rect.fromLTWH(0, 0, 360, 200));
}, skip: isWebkit);
/// Should render the gradient opaque on top of content.
test('Renders shader mask with linear gradient BlendMode src', () async {
_renderCirclesScene(BlendMode.src);
await matchGoldenFile('shadermask_linear_src.png',
- region: Rect.fromLTWH(0, 0, 360, 200));
+ region: const Rect.fromLTWH(0, 0, 360, 200));
}, skip: isWebkit);
/// Should render text with gradient.
test('Renders text with linear gradient shader mask', () async {
_renderTextScene(BlendMode.srcIn);
await matchGoldenFile('shadermask_linear_text.png',
- region: Rect.fromLTWH(0, 0, 360, 200), maxDiffRatePercent: 2.0);
+ region: const Rect.fromLTWH(0, 0, 360, 200), maxDiffRatePercent: 2.0);
}, skip: isWebkit);
}
@@ -130,13 +130,13 @@
}
void _renderCirclesScene(BlendMode blendMode) {
- final Rect region = Rect.fromLTWH(0, 0, 400, 400);
+ const Rect region = Rect.fromLTWH(0, 0, 400, 400);
final SurfaceSceneBuilder builder = SurfaceSceneBuilder();
final Picture circles1 = _drawTestPictureWithCircles(region, 10, 10);
builder.addPicture(Offset.zero, circles1);
- final List<Color> colors = <Color>[
+ const List<Color> colors = <Color>[
Color(0xFF000000),
Color(0xFFFF3C38),
Color(0xFFFF8C42),
@@ -144,9 +144,9 @@
Color(0xFF6699CC),
Color(0xFF656D78),
];
- final List<double> stops = <double>[0.0, 0.05, 0.4, 0.6, 0.9, 1.0];
+ const List<double> stops = <double>[0.0, 0.05, 0.4, 0.6, 0.9, 1.0];
- final Rect shaderBounds = Rect.fromLTWH(180, 10, 140, 140);
+ const Rect shaderBounds = Rect.fromLTWH(180, 10, 140, 140);
final EngineGradient shader = GradientLinear(
Offset(200 - shaderBounds.left, 30 - shaderBounds.top),
@@ -174,24 +174,24 @@
);
final CanvasParagraphBuilder builder = CanvasParagraphBuilder(paragraphStyle);
- builder.pushStyle(EngineTextStyle.only(color: Color(0xFFFF0000)));
+ builder.pushStyle(EngineTextStyle.only(color: const Color(0xFFFF0000)));
builder.addText(text);
final CanvasParagraph paragraph = builder.build();
const double maxWidth = 200 - 10;
- paragraph.layout(ParagraphConstraints(width: maxWidth));
+ paragraph.layout(const ParagraphConstraints(width: maxWidth));
canvas.drawParagraph(paragraph, Offset(offsetX, offsetY));
return recorder.endRecording();
}
void _renderTextScene(BlendMode blendMode) {
- final Rect region = Rect.fromLTWH(0, 0, 600, 400);
+ const Rect region = Rect.fromLTWH(0, 0, 600, 400);
final SurfaceSceneBuilder builder = SurfaceSceneBuilder();
final Picture textPicture = _drawTestPictureWithText(region, 10, 10);
builder.addPicture(Offset.zero, textPicture);
- final List<Color> colors = <Color>[
+ const List<Color> colors = <Color>[
Color(0xFF000000),
Color(0xFFFF3C38),
Color(0xFFFF8C42),
@@ -199,9 +199,9 @@
Color(0xFF6699CC),
Color(0xFF656D78),
];
- final List<double> stops = <double>[0.0, 0.05, 0.4, 0.6, 0.9, 1.0];
+ const List<double> stops = <double>[0.0, 0.05, 0.4, 0.6, 0.9, 1.0];
- final Rect shaderBounds = Rect.fromLTWH(180, 10, 140, 140);
+ const Rect shaderBounds = Rect.fromLTWH(180, 10, 140, 140);
final EngineGradient shader = GradientLinear(
Offset(200 - shaderBounds.left, 30 - shaderBounds.top),
diff --git a/lib/web_ui/test/html/shadow_golden_test.dart b/lib/web_ui/test/html/shadow_golden_test.dart
index 2d8f23f..b1b4c75 100644
--- a/lib/web_ui/test/html/shadow_golden_test.dart
+++ b/lib/web_ui/test/html/shadow_golden_test.dart
@@ -20,7 +20,7 @@
}
Future<void> testMain() async {
- final Rect region = Rect.fromLTWH(0, 0, 550, 300);
+ const Rect region = Rect.fromLTWH(0, 0, 550, 300);
late SurfaceSceneBuilder builder;
@@ -36,7 +36,7 @@
canvas.drawRect(
const Rect.fromLTRB(0.0, 0.0, 20.0, 20.0),
SurfacePaint()
- ..color = Color.fromARGB(255, 0, 0, 255)
+ ..color = const Color.fromARGB(255, 0, 0, 255)
..style = PaintingStyle.stroke
..strokeWidth = 1.0,
);
@@ -51,7 +51,7 @@
canvas.drawRect(
shadowBounds,
SurfacePaint()
- ..color = Color.fromARGB(255, 0, 255, 0)
+ ..color = const Color.fromARGB(255, 0, 255, 0)
..style = PaintingStyle.stroke
..strokeWidth = 1.0,
);
@@ -66,7 +66,7 @@
path: path,
elevation: elevation,
shadowColor: _kShadowColor,
- color: Color.fromARGB(255, 255, 255, 255),
+ color: const Color.fromARGB(255, 255, 255, 255),
);
builder.pop(); // physical shape
_paintShapeOutline();
@@ -121,7 +121,7 @@
SurfacePaint()
..style = PaintingStyle.stroke
..strokeWidth = 1
- ..color = Color.fromARGB(255, 0, 0, 255),
+ ..color = const Color.fromARGB(255, 0, 0, 255),
);
builder.addPicture(Offset.zero, recorder.endRecording());
_paintShadowBounds(path, elevation);
diff --git a/lib/web_ui/test/keyboard_converter_test.dart b/lib/web_ui/test/keyboard_converter_test.dart
index 30d2fbe..abb8660 100644
--- a/lib/web_ui/test/keyboard_converter_test.dart
+++ b/lib/web_ui/test/keyboard_converter_test.dart
@@ -58,7 +58,7 @@
..onPreventDefault = onPreventDefault
);
expectKeyData(keyDataList.last,
- timeStamp: Duration(milliseconds: 1),
+ timeStamp: const Duration(milliseconds: 1),
type: ui.KeyEventType.down,
physical: kPhysicalKeyA,
logical: kLogicalKeyA,
@@ -72,7 +72,7 @@
..onPreventDefault = onPreventDefault
);
expectKeyData(keyDataList.last,
- timeStamp: Duration(milliseconds: 1, microseconds: 500),
+ timeStamp: const Duration(milliseconds: 1, microseconds: 500),
type: ui.KeyEventType.repeat,
physical: kPhysicalKeyA,
logical: kLogicalKeyA,
@@ -85,7 +85,7 @@
..onPreventDefault = onPreventDefault
);
expectKeyData(keyDataList.last,
- timeStamp: Duration(seconds: 1, milliseconds: 500),
+ timeStamp: const Duration(seconds: 1, milliseconds: 500),
type: ui.KeyEventType.repeat,
physical: kPhysicalKeyA,
logical: kLogicalKeyA,
@@ -98,7 +98,7 @@
..onPreventDefault = onPreventDefault
);
expectKeyData(keyDataList.last,
- timeStamp: Duration(seconds: 2, microseconds: 500),
+ timeStamp: const Duration(seconds: 2, microseconds: 500),
type: ui.KeyEventType.up,
physical: kPhysicalKeyA,
logical: kLogicalKeyA,
@@ -464,7 +464,7 @@
keyDataList.clear();
preventedDefault = false;
- async.elapse(Duration(microseconds: 1));
+ async.elapse(const Duration(microseconds: 1));
expect(keyDataList, hasLength(1));
expectKeyData(keyDataList.last,
type: ui.KeyEventType.up,
@@ -490,7 +490,7 @@
keyDataList.clear();
preventedDefault = false;
- async.elapse(Duration(microseconds: 1));
+ async.elapse(const Duration(microseconds: 1));
expect(keyDataList, hasLength(1));
expectKeyData(keyDataList.last,
type: ui.KeyEventType.up,
@@ -516,7 +516,7 @@
// Schedules are canceled after disposal
converter.dispose();
- async.elapse(Duration(seconds: 10));
+ async.elapse(const Duration(seconds: 10));
expect(keyDataList, isEmpty);
});
@@ -537,7 +537,7 @@
);
keyDataList.clear();
- async.elapse(Duration(seconds: 10));
+ async.elapse(const Duration(seconds: 10));
expect(keyDataList, isEmpty);
converter.handleEvent(keyUpEvent('CapsLock', 'CapsLock'));
@@ -550,7 +550,7 @@
);
keyDataList.clear();
- async.elapse(Duration(seconds: 10));
+ async.elapse(const Duration(seconds: 10));
expect(keyDataList, isEmpty);
converter.handleEvent(keyDownEvent('CapsLock', 'CapsLock'));
@@ -578,7 +578,7 @@
});
converter.handleEvent(keyDownEvent('MetaLeft', 'Meta', kMeta, kLocationLeft)..timeStamp = 100);
- async.elapse(Duration(milliseconds: 100));
+ async.elapse(const Duration(milliseconds: 100));
converter.handleEvent(keyDownEvent('KeyA', 'a', kMeta)..timeStamp = 200);
expectKeyData(keyDataList.last,
@@ -592,7 +592,7 @@
// Keyup of KeyA is omitted due to being a shortcut.
- async.elapse(Duration(milliseconds: 2500));
+ async.elapse(const Duration(milliseconds: 2500));
expectKeyData(keyDataList.last,
timeStamp: const Duration(milliseconds: 1200),
type: ui.KeyEventType.up,
@@ -611,7 +611,7 @@
logical: kLogicalMetaLeft,
character: null,
);
- async.elapse(Duration(milliseconds: 100));
+ async.elapse(const Duration(milliseconds: 100));
// Key A states are cleared
converter.handleEvent(keyDownEvent('KeyA', 'a')..timeStamp = 2800);
@@ -622,7 +622,7 @@
logical: kLogicalKeyA,
character: 'a',
);
- async.elapse(Duration(milliseconds: 100));
+ async.elapse(const Duration(milliseconds: 100));
converter.handleEvent(keyUpEvent('KeyA', 'a')..timeStamp = 2900);
expectKeyData(keyDataList.last,
@@ -642,20 +642,20 @@
});
converter.handleEvent(keyDownEvent('MetaLeft', 'Meta', kMeta, kLocationLeft)..timeStamp = 100);
- async.elapse(Duration(milliseconds: 100));
+ async.elapse(const Duration(milliseconds: 100));
converter.handleEvent(keyDownEvent('KeyA', 'a', kMeta)..timeStamp = 200);
- async.elapse(Duration(milliseconds: 400));
+ async.elapse(const Duration(milliseconds: 400));
converter.handleEvent(keyRepeatedDownEvent('KeyA', 'a', kMeta)..timeStamp = 600);
- async.elapse(Duration(milliseconds: 50));
+ async.elapse(const Duration(milliseconds: 50));
converter.handleEvent(keyRepeatedDownEvent('KeyA', 'a', kMeta)..timeStamp = 650);
- async.elapse(Duration(milliseconds: 50));
+ async.elapse(const Duration(milliseconds: 50));
converter.handleEvent(keyRepeatedDownEvent('KeyA', 'a', kMeta)..timeStamp = 700);
// Keyup of KeyA is omitted due to being a shortcut.
- async.elapse(Duration(milliseconds: 2500));
+ async.elapse(const Duration(milliseconds: 2500));
expectKeyData(keyDataList.last,
timeStamp: const Duration(milliseconds: 1700),
type: ui.KeyEventType.up,
@@ -674,7 +674,7 @@
logical: kLogicalMetaLeft,
character: null,
);
- async.elapse(Duration(milliseconds: 100));
+ async.elapse(const Duration(milliseconds: 100));
// Key A states are cleared
converter.handleEvent(keyDownEvent('KeyA', 'a')..timeStamp = 3300);
@@ -685,7 +685,7 @@
logical: kLogicalKeyA,
character: 'a',
);
- async.elapse(Duration(milliseconds: 100));
+ async.elapse(const Duration(milliseconds: 100));
converter.handleEvent(keyUpEvent('KeyA', 'a')..timeStamp = 3400);
expectKeyData(keyDataList.last,
@@ -705,7 +705,7 @@
});
converter.handleEvent(keyDownEvent('MetaLeft', 'Meta', kMeta, kLocationLeft)..timeStamp = 100);
- async.elapse(Duration(milliseconds: 100));
+ async.elapse(const Duration(milliseconds: 100));
converter.handleEvent(keyDownEvent('KeyA', 'a', kCtrl)..timeStamp = 200);
expectKeyData(keyDataList.last,
@@ -716,10 +716,10 @@
character: 'a',
);
keyDataList.clear();
- async.elapse(Duration(milliseconds: 500));
+ async.elapse(const Duration(milliseconds: 500));
converter.handleEvent(keyUpEvent('MetaLeft', 'Meta', 0, kLocationLeft)..timeStamp = 700);
- async.elapse(Duration(milliseconds: 100));
+ async.elapse(const Duration(milliseconds: 100));
converter.handleEvent(keyUpEvent('KeyA', 'a')..timeStamp = 800);
expectKeyData(keyDataList.last,
@@ -730,7 +730,7 @@
character: null,
);
keyDataList.clear();
- async.elapse(Duration(milliseconds: 2000));
+ async.elapse(const Duration(milliseconds: 2000));
expect(keyDataList, isEmpty);
// Key A states are cleared
@@ -742,7 +742,7 @@
logical: kLogicalKeyA,
character: 'a',
);
- async.elapse(Duration(milliseconds: 100));
+ async.elapse(const Duration(milliseconds: 100));
converter.handleEvent(keyUpEvent('KeyA', 'a')..timeStamp = 2900);
expectKeyData(keyDataList.last,
@@ -771,7 +771,7 @@
);
keyDataList.clear();
- async.elapse(Duration(seconds: 10));
+ async.elapse(const Duration(seconds: 10));
expect(keyDataList, isEmpty);
converter.handleEvent(keyUpEvent('ScrollLock', 'ScrollLock'));
diff --git a/lib/web_ui/test/keyboard_test.dart b/lib/web_ui/test/keyboard_test.dart
index 05096b8..23c8a1c 100644
--- a/lib/web_ui/test/keyboard_test.dart
+++ b/lib/web_ui/test/keyboard_test.dart
@@ -362,7 +362,7 @@
isMetaPressed: true,
isAltPressed: true,
);
- async.elapse(Duration(milliseconds: 10));
+ async.elapse(const Duration(milliseconds: 10));
dispatchKeyboardEvent(
'keyup',
key: 'Meta',
@@ -416,10 +416,10 @@
messages.clear();
// Still too eary to synthesize a keyup event.
- async.elapse(Duration(milliseconds: 50));
+ async.elapse(const Duration(milliseconds: 50));
expect(messages, isEmpty);
- async.elapse(Duration(seconds: 3));
+ async.elapse(const Duration(seconds: 3));
expect(messages, <Map<String, dynamic>>[
<String, dynamic>{
'type': 'keyup',
@@ -465,7 +465,7 @@
isMetaPressed: true,
isAltPressed: true,
);
- async.elapse(Duration(milliseconds: 10));
+ async.elapse(const Duration(milliseconds: 10));
dispatchKeyboardEvent(
'keyup',
key: 'Meta',
@@ -480,7 +480,7 @@
// Spend more than 2 seconds sending repeat events and make sure no
// keyup was synthesized.
for (int i = 0; i < 20; i++) {
- async.elapse(Duration(milliseconds: 100));
+ async.elapse(const Duration(milliseconds: 100));
dispatchKeyboardEvent(
'keydown',
key: 'i',
@@ -531,7 +531,7 @@
// Wait for a long-enough period of time and no events
// should be synthesized
- async.elapse(Duration(seconds: 3));
+ async.elapse(const Duration(seconds: 3));
expect(messages, hasLength(0));
Keyboard.instance!.dispose();
@@ -567,7 +567,7 @@
isMetaPressed: true,
isAltPressed: true,
);
- async.elapse(Duration(milliseconds: 10));
+ async.elapse(const Duration(milliseconds: 10));
dispatchKeyboardEvent(
'keyup',
key: 'Meta',
@@ -580,7 +580,7 @@
// There has been no repeat events for "AltLeft" nor "i". Only "i" should
// synthesize a keyup event.
- async.elapse(Duration(seconds: 3));
+ async.elapse(const Duration(seconds: 3));
expect(messages, <Map<String, dynamic>>[
<String, dynamic>{
'type': 'keyup',
diff --git a/lib/web_ui/test/paragraph_test.dart b/lib/web_ui/test/paragraph_test.dart
index 12af864..681bb73 100644
--- a/lib/web_ui/test/paragraph_test.dart
+++ b/lib/web_ui/test/paragraph_test.dart
@@ -161,33 +161,33 @@
// At the beginning of the line.
expect(
- paragraph.getPositionForOffset(Offset(0, 5)),
- TextPosition(offset: 0, affinity: TextAffinity.downstream),
+ paragraph.getPositionForOffset(const Offset(0, 5)),
+ const TextPosition(offset: 0, affinity: TextAffinity.downstream),
);
// Below the line.
expect(
- paragraph.getPositionForOffset(Offset(0, 12)),
- TextPosition(offset: 8, affinity: TextAffinity.upstream),
+ paragraph.getPositionForOffset(const Offset(0, 12)),
+ const TextPosition(offset: 8, affinity: TextAffinity.upstream),
);
// Above the line.
expect(
- paragraph.getPositionForOffset(Offset(0, -5)),
- TextPosition(offset: 0, affinity: TextAffinity.downstream),
+ paragraph.getPositionForOffset(const Offset(0, -5)),
+ const TextPosition(offset: 0, affinity: TextAffinity.downstream),
);
// At the end of the line.
expect(
- paragraph.getPositionForOffset(Offset(80, 5)),
- TextPosition(offset: 8, affinity: TextAffinity.upstream),
+ paragraph.getPositionForOffset(const Offset(80, 5)),
+ const TextPosition(offset: 8, affinity: TextAffinity.upstream),
);
// On the left side of "b".
expect(
- paragraph.getPositionForOffset(Offset(14, 5)),
- TextPosition(offset: 1, affinity: TextAffinity.downstream),
+ paragraph.getPositionForOffset(const Offset(14, 5)),
+ const TextPosition(offset: 1, affinity: TextAffinity.downstream),
);
// On the right side of "b".
expect(
- paragraph.getPositionForOffset(Offset(16, 5)),
- TextPosition(offset: 2, affinity: TextAffinity.upstream),
+ paragraph.getPositionForOffset(const Offset(16, 5)),
+ const TextPosition(offset: 2, affinity: TextAffinity.upstream),
);
});
@@ -215,79 +215,79 @@
// At the beginning of the first line.
expect(
- paragraph.getPositionForOffset(Offset(0, 5)),
- TextPosition(offset: 0, affinity: TextAffinity.downstream),
+ paragraph.getPositionForOffset(const Offset(0, 5)),
+ const TextPosition(offset: 0, affinity: TextAffinity.downstream),
);
// Above the first line.
expect(
- paragraph.getPositionForOffset(Offset(0, -15)),
- TextPosition(offset: 0, affinity: TextAffinity.downstream),
+ paragraph.getPositionForOffset(const Offset(0, -15)),
+ const TextPosition(offset: 0, affinity: TextAffinity.downstream),
);
// At the end of the first line.
expect(
- paragraph.getPositionForOffset(Offset(50, 5)),
- TextPosition(offset: 4, affinity: TextAffinity.upstream),
+ paragraph.getPositionForOffset(const Offset(50, 5)),
+ const TextPosition(offset: 4, affinity: TextAffinity.upstream),
);
// On the left side of "b" in the first line.
expect(
- paragraph.getPositionForOffset(Offset(14, 5)),
- TextPosition(offset: 1, affinity: TextAffinity.downstream),
+ paragraph.getPositionForOffset(const Offset(14, 5)),
+ const TextPosition(offset: 1, affinity: TextAffinity.downstream),
);
// On the right side of "b" in the first line.
expect(
- paragraph.getPositionForOffset(Offset(16, 5)),
- TextPosition(offset: 2, affinity: TextAffinity.upstream),
+ paragraph.getPositionForOffset(const Offset(16, 5)),
+ const TextPosition(offset: 2, affinity: TextAffinity.upstream),
);
// Second line: "abcdefg\n"
// At the beginning of the second line.
expect(
- paragraph.getPositionForOffset(Offset(0, 15)),
- TextPosition(offset: 5, affinity: TextAffinity.downstream),
+ paragraph.getPositionForOffset(const Offset(0, 15)),
+ const TextPosition(offset: 5, affinity: TextAffinity.downstream),
);
// At the end of the second line.
expect(
- paragraph.getPositionForOffset(Offset(100, 15)),
- TextPosition(offset: 12, affinity: TextAffinity.upstream),
+ paragraph.getPositionForOffset(const Offset(100, 15)),
+ const TextPosition(offset: 12, affinity: TextAffinity.upstream),
);
// On the left side of "e" in the second line.
expect(
- paragraph.getPositionForOffset(Offset(44, 15)),
- TextPosition(offset: 9, affinity: TextAffinity.downstream),
+ paragraph.getPositionForOffset(const Offset(44, 15)),
+ const TextPosition(offset: 9, affinity: TextAffinity.downstream),
);
// On the right side of "e" in the second line.
expect(
- paragraph.getPositionForOffset(Offset(46, 15)),
- TextPosition(offset: 10, affinity: TextAffinity.upstream),
+ paragraph.getPositionForOffset(const Offset(46, 15)),
+ const TextPosition(offset: 10, affinity: TextAffinity.upstream),
);
// Last (third) line: "ab"
// At the beginning of the last line.
expect(
- paragraph.getPositionForOffset(Offset(0, 25)),
- TextPosition(offset: 13, affinity: TextAffinity.downstream),
+ paragraph.getPositionForOffset(const Offset(0, 25)),
+ const TextPosition(offset: 13, affinity: TextAffinity.downstream),
);
// At the end of the last line.
expect(
- paragraph.getPositionForOffset(Offset(100, 25)),
- TextPosition(offset: 15, affinity: TextAffinity.upstream),
+ paragraph.getPositionForOffset(const Offset(100, 25)),
+ const TextPosition(offset: 15, affinity: TextAffinity.upstream),
);
// Below the last line.
expect(
- paragraph.getPositionForOffset(Offset(0, 32)),
- TextPosition(offset: 15, affinity: TextAffinity.upstream),
+ paragraph.getPositionForOffset(const Offset(0, 32)),
+ const TextPosition(offset: 15, affinity: TextAffinity.upstream),
);
// On the left side of "b" in the last line.
expect(
- paragraph.getPositionForOffset(Offset(12, 25)),
- TextPosition(offset: 14, affinity: TextAffinity.downstream),
+ paragraph.getPositionForOffset(const Offset(12, 25)),
+ const TextPosition(offset: 14, affinity: TextAffinity.downstream),
);
// On the right side of "a" in the last line.
expect(
- paragraph.getPositionForOffset(Offset(9, 25)),
- TextPosition(offset: 14, affinity: TextAffinity.upstream),
+ paragraph.getPositionForOffset(const Offset(9, 25)),
+ const TextPosition(offset: 14, affinity: TextAffinity.upstream),
);
TextMeasurementService.clearCache();
@@ -318,85 +318,85 @@
// At the beginning of the first line.
expect(
- paragraph.getPositionForOffset(Offset(0, 5)),
- TextPosition(offset: 0, affinity: TextAffinity.downstream),
+ paragraph.getPositionForOffset(const Offset(0, 5)),
+ const TextPosition(offset: 0, affinity: TextAffinity.downstream),
);
// Above the first line.
expect(
- paragraph.getPositionForOffset(Offset(0, -15)),
- TextPosition(offset: 0, affinity: TextAffinity.downstream),
+ paragraph.getPositionForOffset(const Offset(0, -15)),
+ const TextPosition(offset: 0, affinity: TextAffinity.downstream),
);
// At the end of the first line.
expect(
- paragraph.getPositionForOffset(Offset(100, 5)),
- TextPosition(offset: 4, affinity: TextAffinity.upstream),
+ paragraph.getPositionForOffset(const Offset(100, 5)),
+ const TextPosition(offset: 4, affinity: TextAffinity.upstream),
);
// On the left side of "b" in the first line.
expect(
// The line is centered so it's shifted to the right by "30.0px".
- paragraph.getPositionForOffset(Offset(30.0 + 14, 5)),
- TextPosition(offset: 1, affinity: TextAffinity.downstream),
+ paragraph.getPositionForOffset(const Offset(30.0 + 14, 5)),
+ const TextPosition(offset: 1, affinity: TextAffinity.downstream),
);
// On the right side of "b" in the first line.
expect(
// The line is centered so it's shifted to the right by "30.0px".
- paragraph.getPositionForOffset(Offset(30.0 + 16, 5)),
- TextPosition(offset: 2, affinity: TextAffinity.upstream),
+ paragraph.getPositionForOffset(const Offset(30.0 + 16, 5)),
+ const TextPosition(offset: 2, affinity: TextAffinity.upstream),
);
// Second line: "abcdefg\n"
// At the beginning of the second line.
expect(
- paragraph.getPositionForOffset(Offset(0, 15)),
- TextPosition(offset: 5, affinity: TextAffinity.downstream),
+ paragraph.getPositionForOffset(const Offset(0, 15)),
+ const TextPosition(offset: 5, affinity: TextAffinity.downstream),
);
// At the end of the second line.
expect(
- paragraph.getPositionForOffset(Offset(100, 15)),
- TextPosition(offset: 12, affinity: TextAffinity.upstream),
+ paragraph.getPositionForOffset(const Offset(100, 15)),
+ const TextPosition(offset: 12, affinity: TextAffinity.upstream),
);
// On the left side of "e" in the second line.
expect(
// The line is centered so it's shifted to the right by "15.0px".
- paragraph.getPositionForOffset(Offset(15.0 + 44, 15)),
- TextPosition(offset: 9, affinity: TextAffinity.downstream),
+ paragraph.getPositionForOffset(const Offset(15.0 + 44, 15)),
+ const TextPosition(offset: 9, affinity: TextAffinity.downstream),
);
// On the right side of "e" in the second line.
expect(
// The line is centered so it's shifted to the right by "15.0px".
- paragraph.getPositionForOffset(Offset(15.0 + 46, 15)),
- TextPosition(offset: 10, affinity: TextAffinity.upstream),
+ paragraph.getPositionForOffset(const Offset(15.0 + 46, 15)),
+ const TextPosition(offset: 10, affinity: TextAffinity.upstream),
);
// Last (third) line: "ab"
// At the beginning of the last line.
expect(
- paragraph.getPositionForOffset(Offset(0, 25)),
- TextPosition(offset: 13, affinity: TextAffinity.downstream),
+ paragraph.getPositionForOffset(const Offset(0, 25)),
+ const TextPosition(offset: 13, affinity: TextAffinity.downstream),
);
// At the end of the last line.
expect(
- paragraph.getPositionForOffset(Offset(100, 25)),
- TextPosition(offset: 15, affinity: TextAffinity.upstream),
+ paragraph.getPositionForOffset(const Offset(100, 25)),
+ const TextPosition(offset: 15, affinity: TextAffinity.upstream),
);
// Below the last line.
expect(
- paragraph.getPositionForOffset(Offset(0, 32)),
- TextPosition(offset: 15, affinity: TextAffinity.upstream),
+ paragraph.getPositionForOffset(const Offset(0, 32)),
+ const TextPosition(offset: 15, affinity: TextAffinity.upstream),
);
// On the left side of "b" in the last line.
expect(
// The line is centered so it's shifted to the right by "40.0px".
- paragraph.getPositionForOffset(Offset(40.0 + 12, 25)),
- TextPosition(offset: 14, affinity: TextAffinity.downstream),
+ paragraph.getPositionForOffset(const Offset(40.0 + 12, 25)),
+ const TextPosition(offset: 14, affinity: TextAffinity.downstream),
);
// On the right side of "a" in the last line.
expect(
// The line is centered so it's shifted to the right by "40.0px".
- paragraph.getPositionForOffset(Offset(40.0 + 9, 25)),
- TextPosition(offset: 14, affinity: TextAffinity.upstream),
+ paragraph.getPositionForOffset(const Offset(40.0 + 9, 25)),
+ const TextPosition(offset: 14, affinity: TextAffinity.upstream),
);
TextMeasurementService.clearCache();
@@ -410,34 +410,34 @@
final Paragraph paragraph = builder.build();
const TextRange loremRange = TextRange(start: 0, end: 5);
- expect(paragraph.getWordBoundary(TextPosition(offset: 0)), loremRange);
- expect(paragraph.getWordBoundary(TextPosition(offset: 1)), loremRange);
- expect(paragraph.getWordBoundary(TextPosition(offset: 2)), loremRange);
- expect(paragraph.getWordBoundary(TextPosition(offset: 3)), loremRange);
- expect(paragraph.getWordBoundary(TextPosition(offset: 4)), loremRange);
+ expect(paragraph.getWordBoundary(const TextPosition(offset: 0)), loremRange);
+ expect(paragraph.getWordBoundary(const TextPosition(offset: 1)), loremRange);
+ expect(paragraph.getWordBoundary(const TextPosition(offset: 2)), loremRange);
+ expect(paragraph.getWordBoundary(const TextPosition(offset: 3)), loremRange);
+ expect(paragraph.getWordBoundary(const TextPosition(offset: 4)), loremRange);
const TextRange firstSpace = TextRange(start: 5, end: 6);
- expect(paragraph.getWordBoundary(TextPosition(offset: 5)), firstSpace);
+ expect(paragraph.getWordBoundary(const TextPosition(offset: 5)), firstSpace);
const TextRange ipsumRange = TextRange(start: 6, end: 11);
- expect(paragraph.getWordBoundary(TextPosition(offset: 6)), ipsumRange);
- expect(paragraph.getWordBoundary(TextPosition(offset: 7)), ipsumRange);
- expect(paragraph.getWordBoundary(TextPosition(offset: 8)), ipsumRange);
- expect(paragraph.getWordBoundary(TextPosition(offset: 9)), ipsumRange);
- expect(paragraph.getWordBoundary(TextPosition(offset: 10)), ipsumRange);
+ expect(paragraph.getWordBoundary(const TextPosition(offset: 6)), ipsumRange);
+ expect(paragraph.getWordBoundary(const TextPosition(offset: 7)), ipsumRange);
+ expect(paragraph.getWordBoundary(const TextPosition(offset: 8)), ipsumRange);
+ expect(paragraph.getWordBoundary(const TextPosition(offset: 9)), ipsumRange);
+ expect(paragraph.getWordBoundary(const TextPosition(offset: 10)), ipsumRange);
const TextRange secondSpace = TextRange(start: 11, end: 12);
- expect(paragraph.getWordBoundary(TextPosition(offset: 11)), secondSpace);
+ expect(paragraph.getWordBoundary(const TextPosition(offset: 11)), secondSpace);
const TextRange dolorRange = TextRange(start: 12, end: 17);
- expect(paragraph.getWordBoundary(TextPosition(offset: 12)), dolorRange);
- expect(paragraph.getWordBoundary(TextPosition(offset: 13)), dolorRange);
- expect(paragraph.getWordBoundary(TextPosition(offset: 14)), dolorRange);
- expect(paragraph.getWordBoundary(TextPosition(offset: 15)), dolorRange);
- expect(paragraph.getWordBoundary(TextPosition(offset: 16)), dolorRange);
+ expect(paragraph.getWordBoundary(const TextPosition(offset: 12)), dolorRange);
+ expect(paragraph.getWordBoundary(const TextPosition(offset: 13)), dolorRange);
+ expect(paragraph.getWordBoundary(const TextPosition(offset: 14)), dolorRange);
+ expect(paragraph.getWordBoundary(const TextPosition(offset: 15)), dolorRange);
+ expect(paragraph.getWordBoundary(const TextPosition(offset: 16)), dolorRange);
const TextRange endRange = TextRange(start: 17, end: 17);
- expect(paragraph.getWordBoundary(TextPosition(offset: 17)), endRange);
+ expect(paragraph.getWordBoundary(const TextPosition(offset: 17)), endRange);
});
testEachMeasurement('getBoxesForRange returns a box', () {
@@ -530,35 +530,35 @@
// The range "ab" in the first line.
expect(
paragraph.getBoxesForRange(0, 2),
- <TextBox>[
+ const <TextBox>[
TextBox.fromLTRBD(0.0, 0.0, 20.0, 10.0, TextDirection.ltr),
],
);
// The range "bc" in the first line.
expect(
paragraph.getBoxesForRange(1, 3),
- <TextBox>[
+ const <TextBox>[
TextBox.fromLTRBD(10.0, 0.0, 30.0, 10.0, TextDirection.ltr),
],
);
// The range "d" in the first line.
expect(
paragraph.getBoxesForRange(3, 4),
- <TextBox>[
+ const <TextBox>[
TextBox.fromLTRBD(30.0, 0.0, 40.0, 10.0, TextDirection.ltr),
],
);
// The range "\n" in the first line.
expect(
paragraph.getBoxesForRange(4, 5),
- <TextBox>[
+ const <TextBox>[
TextBox.fromLTRBD(40.0, 0.0, 40.0, 10.0, TextDirection.ltr),
],
);
// The range "cd\n" in the first line.
expect(
paragraph.getBoxesForRange(2, 5),
- <TextBox>[
+ const <TextBox>[
TextBox.fromLTRBD(20.0, 0.0, 40.0, 10.0, TextDirection.ltr),
],
);
@@ -578,21 +578,21 @@
// The range "efg" in the second line.
expect(
paragraph.getBoxesForRange(9, 12),
- <TextBox>[
+ const <TextBox>[
TextBox.fromLTRBD(40.0, 10.0, 70.0, 20.0, TextDirection.ltr),
],
);
// The range "bcde" in the second line.
expect(
paragraph.getBoxesForRange(6, 10),
- <TextBox>[
+ const <TextBox>[
TextBox.fromLTRBD(10.0, 10.0, 50.0, 20.0, TextDirection.ltr),
],
);
// The range "fg\n" in the second line.
expect(
paragraph.getBoxesForRange(10, 13),
- <TextBox>[
+ const <TextBox>[
TextBox.fromLTRBD(50.0, 10.0, 70.0, 20.0, TextDirection.ltr),
],
);
@@ -612,14 +612,14 @@
// The range "a" in the last line.
expect(
paragraph.getBoxesForRange(14, 15),
- <TextBox>[
+ const <TextBox>[
TextBox.fromLTRBD(10.0, 20.0, 20.0, 30.0, TextDirection.ltr),
],
);
// The range "ab" in the last line.
expect(
paragraph.getBoxesForRange(13, 15),
- <TextBox>[
+ const <TextBox>[
TextBox.fromLTRBD(0.0, 20.0, 20.0, 30.0, TextDirection.ltr),
],
);
@@ -630,7 +630,7 @@
// The range "cd\nabc".
expect(
paragraph.getBoxesForRange(2, 8),
- <TextBox>[
+ const <TextBox>[
TextBox.fromLTRBD(20.0, 0.0, 40.0, 10.0, TextDirection.ltr),
TextBox.fromLTRBD(0.0, 10.0, 30.0, 20.0, TextDirection.ltr),
],
@@ -639,7 +639,7 @@
// The range "\nabcd".
expect(
paragraph.getBoxesForRange(4, 9),
- <TextBox>[
+ const <TextBox>[
TextBox.fromLTRBD(40.0, 0.0, 40.0, 10.0, TextDirection.ltr),
TextBox.fromLTRBD(0.0, 10.0, 40.0, 20.0, TextDirection.ltr),
],
@@ -648,7 +648,7 @@
// The range "d\nabcdefg\na".
expect(
paragraph.getBoxesForRange(3, 14),
- <TextBox>[
+ const <TextBox>[
TextBox.fromLTRBD(30.0, 0.0, 40.0, 10.0, TextDirection.ltr),
TextBox.fromLTRBD(0.0, 10.0, 70.0, 20.0, TextDirection.ltr),
TextBox.fromLTRBD(0.0, 20.0, 10.0, 30.0, TextDirection.ltr),
@@ -658,7 +658,7 @@
// The range "abcd\nabcdefg\n".
expect(
paragraph.getBoxesForRange(0, 13),
- <TextBox>[
+ const <TextBox>[
TextBox.fromLTRBD(0.0, 0.0, 40.0, 10.0, TextDirection.ltr),
TextBox.fromLTRBD(0.0, 10.0, 70.0, 20.0, TextDirection.ltr),
],
@@ -667,7 +667,7 @@
// The range "abcd\nabcdefg\nab".
expect(
paragraph.getBoxesForRange(0, 15),
- <TextBox>[
+ const <TextBox>[
TextBox.fromLTRBD(0.0, 0.0, 40.0, 10.0, TextDirection.ltr),
TextBox.fromLTRBD(0.0, 10.0, 70.0, 20.0, TextDirection.ltr),
TextBox.fromLTRBD(0.0, 20.0, 20.0, 30.0, TextDirection.ltr),
@@ -710,35 +710,35 @@
// The range "ab" in the first line.
expect(
paragraph.getBoxesForRange(0, 2),
- <TextBox>[
+ const <TextBox>[
TextBox.fromLTRBD(0.0, 0.0, 20.0, 10.0, TextDirection.ltr),
],
);
// The range "bc" in the first line.
expect(
paragraph.getBoxesForRange(1, 3),
- <TextBox>[
+ const <TextBox>[
TextBox.fromLTRBD(10.0, 0.0, 30.0, 10.0, TextDirection.ltr),
],
);
// The range "d" in the first line.
expect(
paragraph.getBoxesForRange(3, 4),
- <TextBox>[
+ const <TextBox>[
TextBox.fromLTRBD(30.0, 0.0, 40.0, 10.0, TextDirection.ltr),
],
);
// The range "\n" in the first line.
expect(
paragraph.getBoxesForRange(4, 5),
- <TextBox>[
+ const <TextBox>[
TextBox.fromLTRBD(40.0, 0.0, 40.0, 10.0, TextDirection.ltr),
],
);
// The range "cd\n" in the first line.
expect(
paragraph.getBoxesForRange(2, 5),
- <TextBox>[
+ const <TextBox>[
TextBox.fromLTRBD(20.0, 0.0, 40.0, 10.0, TextDirection.ltr),
],
);
@@ -758,21 +758,21 @@
// The range "efg" in the second line.
expect(
paragraph.getBoxesForRange(9, 12),
- <TextBox>[
+ const <TextBox>[
TextBox.fromLTRBD(40.0, 10.0, 70.0, 20.0, TextDirection.ltr),
],
);
// The range "bcde" in the second line.
expect(
paragraph.getBoxesForRange(6, 10),
- <TextBox>[
+ const <TextBox>[
TextBox.fromLTRBD(10.0, 10.0, 50.0, 20.0, TextDirection.ltr),
],
);
// The range "fg\n" in the second line.
expect(
paragraph.getBoxesForRange(10, 13),
- <TextBox>[
+ const <TextBox>[
TextBox.fromLTRBD(50.0, 10.0, 70.0, 20.0, TextDirection.ltr),
],
);
@@ -806,7 +806,7 @@
// The range "cd\nabc".
expect(
paragraph.getBoxesForRange(2, 8),
- <TextBox>[
+ const <TextBox>[
TextBox.fromLTRBD(20.0, 0.0, 40.0, 10.0, TextDirection.ltr),
TextBox.fromLTRBD(0.0, 10.0, 30.0, 20.0, TextDirection.ltr),
],
@@ -815,7 +815,7 @@
// The range "\nabcd".
expect(
paragraph.getBoxesForRange(4, 9),
- <TextBox>[
+ const <TextBox>[
TextBox.fromLTRBD(40.0, 0.0, 40.0, 10.0, TextDirection.ltr),
TextBox.fromLTRBD(0.0, 10.0, 40.0, 20.0, TextDirection.ltr),
],
@@ -824,7 +824,7 @@
// The range "d\nabcdefg\na".
expect(
paragraph.getBoxesForRange(3, 14),
- <TextBox>[
+ const <TextBox>[
TextBox.fromLTRBD(30.0, 0.0, 40.0, 10.0, TextDirection.ltr),
TextBox.fromLTRBD(0.0, 10.0, 70.0, 20.0, TextDirection.ltr),
],
@@ -833,7 +833,7 @@
// The range "abcd\nabcdefg\n".
expect(
paragraph.getBoxesForRange(0, 13),
- <TextBox>[
+ const <TextBox>[
TextBox.fromLTRBD(0.0, 0.0, 40.0, 10.0, TextDirection.ltr),
TextBox.fromLTRBD(0.0, 10.0, 70.0, 20.0, TextDirection.ltr),
],
@@ -842,7 +842,7 @@
// The range "abcd\nabcdefg\nab".
expect(
paragraph.getBoxesForRange(0, 15),
- <TextBox>[
+ const <TextBox>[
TextBox.fromLTRBD(0.0, 0.0, 40.0, 10.0, TextDirection.ltr),
TextBox.fromLTRBD(0.0, 10.0, 70.0, 20.0, TextDirection.ltr),
],
@@ -862,7 +862,7 @@
paragraph.layout(const ParagraphConstraints(width: double.infinity));
expect(
paragraph.getBoxesForRange(0, text.length),
- <TextBox>[
+ const <TextBox>[
TextBox.fromLTRBD(0.0, 0.0, 120.0, 10.0, TextDirection.ltr),
],
);
@@ -881,7 +881,7 @@
paragraph.layout(const ParagraphConstraints(width: double.infinity));
expect(
paragraph.getBoxesForRange(0, text.length),
- <TextBox>[
+ const <TextBox>[
TextBox.fromLTRBD(0.0, 0.0, 40.0, 10.0, TextDirection.ltr),
TextBox.fromLTRBD(0.0, 10.0, 70.0, 20.0, TextDirection.ltr),
TextBox.fromLTRBD(0.0, 20.0, 30.0, 30.0, TextDirection.ltr),
@@ -926,7 +926,7 @@
for (int i = 0; i < 15; i++) {
expect(
paragraph.getLineBoundary(TextPosition(offset: i)),
- TextRange(start: 0, end: 15),
+ const TextRange(start: 0, end: 15),
reason: 'failed at offset $i',
);
}
@@ -955,7 +955,7 @@
for (int i = 0; i < 11; i++) {
expect(
paragraph.getLineBoundary(TextPosition(offset: i)),
- TextRange(start: 0, end: 11),
+ const TextRange(start: 0, end: 11),
reason: 'failed at offset $i',
);
}
@@ -964,7 +964,7 @@
for (int i = 11; i < 23; i++) {
expect(
paragraph.getLineBoundary(TextPosition(offset: i)),
- TextRange(start: 11, end: 23),
+ const TextRange(start: 11, end: 23),
reason: 'failed at offset $i',
);
}
@@ -973,7 +973,7 @@
for (int i = 23; i < 33; i++) {
expect(
paragraph.getLineBoundary(TextPosition(offset: i)),
- TextRange(start: 23, end: 33),
+ const TextRange(start: 23, end: 33),
reason: 'failed at offset $i',
);
}
diff --git a/lib/web_ui/test/path_test.dart b/lib/web_ui/test/path_test.dart
index d720256..f35b87a 100644
--- a/lib/web_ui/test/path_test.dart
+++ b/lib/web_ui/test/path_test.dart
@@ -94,7 +94,7 @@
path.moveTo(10, 20);
path.lineTo(200, 20);
final Rect r = path.toStraightLine()!;
- expect(r, equals(Rect.fromLTRB(10, 20, 200, 20)));
+ expect(r, equals(const Rect.fromLTRB(10, 20, 200, 20)));
});
test('Should detect vertical line path', () {
@@ -102,7 +102,7 @@
path.moveTo(10, 20);
path.lineTo(10, 200);
final Rect r = path.toStraightLine()!;
- expect(r, equals(Rect.fromLTRB(10, 20, 10, 200)));
+ expect(r, equals(const Rect.fromLTRB(10, 20, 10, 200)));
});
test('Should detect non rectangular path if empty', () {
@@ -165,64 +165,64 @@
expect(emptyPath.getBounds(), Rect.zero);
final SurfacePath path = SurfacePath();
- path.addRect(Rect.fromLTWH(0, 0, 270, 45));
- path.addRect(Rect.fromLTWH(134.5, 0, 1, 45));
+ path.addRect(const Rect.fromLTWH(0, 0, 270, 45));
+ path.addRect(const Rect.fromLTWH(134.5, 0, 1, 45));
expect(path.getBounds(), const Rect.fromLTRB(0, 0, 270, 45));
});
test('Should compute bounds for addRRect', () {
SurfacePath path = SurfacePath();
- final Rect bounds = Rect.fromLTRB(30, 40, 400, 300);
+ const Rect bounds = Rect.fromLTRB(30, 40, 400, 300);
RRect rrect = RRect.fromRectAndCorners(bounds,
- topLeft: Radius.elliptical(1, 2),
- topRight: Radius.elliptical(3, 4),
- bottomLeft: Radius.elliptical(5, 6),
- bottomRight: Radius.elliptical(7, 8));
+ topLeft: const Radius.elliptical(1, 2),
+ topRight: const Radius.elliptical(3, 4),
+ bottomLeft: const Radius.elliptical(5, 6),
+ bottomRight: const Radius.elliptical(7, 8));
path.addRRect(rrect);
expect(path.getBounds(), bounds);
expect(path.toRoundedRect(), rrect);
path = SurfacePath();
rrect = RRect.fromRectAndCorners(bounds,
- topLeft: Radius.elliptical(0, 2),
- topRight: Radius.elliptical(3, 4),
- bottomLeft: Radius.elliptical(5, 6),
- bottomRight: Radius.elliptical(7, 8));
+ topLeft: const Radius.elliptical(0, 2),
+ topRight: const Radius.elliptical(3, 4),
+ bottomLeft: const Radius.elliptical(5, 6),
+ bottomRight: const Radius.elliptical(7, 8));
path.addRRect(rrect);
expect(path.getBounds(), bounds);
expect(path.toRoundedRect(), rrect);
path = SurfacePath();
rrect = RRect.fromRectAndCorners(bounds,
- topLeft: Radius.elliptical(0, 0),
- topRight: Radius.elliptical(3, 4),
- bottomLeft: Radius.elliptical(5, 6),
- bottomRight: Radius.elliptical(7, 8));
+ topLeft: const Radius.elliptical(0, 0),
+ topRight: const Radius.elliptical(3, 4),
+ bottomLeft: const Radius.elliptical(5, 6),
+ bottomRight: const Radius.elliptical(7, 8));
path.addRRect(rrect);
expect(path.getBounds(), bounds);
expect(path.toRoundedRect(), rrect);
path = SurfacePath();
rrect = RRect.fromRectAndCorners(bounds,
- topLeft: Radius.elliptical(1, 2),
- topRight: Radius.elliptical(0, 0),
- bottomLeft: Radius.elliptical(5, 6),
- bottomRight: Radius.elliptical(7, 8));
+ topLeft: const Radius.elliptical(1, 2),
+ topRight: const Radius.elliptical(0, 0),
+ bottomLeft: const Radius.elliptical(5, 6),
+ bottomRight: const Radius.elliptical(7, 8));
path.addRRect(rrect);
expect(path.getBounds(), bounds);
expect(path.toRoundedRect(), rrect);
path = SurfacePath();
rrect = RRect.fromRectAndCorners(bounds,
- topLeft: Radius.elliptical(1, 2),
- topRight: Radius.elliptical(3, 4),
- bottomLeft: Radius.elliptical(0, 0),
- bottomRight: Radius.elliptical(7, 8));
+ topLeft: const Radius.elliptical(1, 2),
+ topRight: const Radius.elliptical(3, 4),
+ bottomLeft: const Radius.elliptical(0, 0),
+ bottomRight: const Radius.elliptical(7, 8));
path.addRRect(rrect);
expect(path.getBounds(), bounds);
expect(path.toRoundedRect(), rrect);
path = SurfacePath();
rrect = RRect.fromRectAndCorners(bounds,
- topLeft: Radius.elliptical(1, 2),
- topRight: Radius.elliptical(3, 4),
- bottomLeft: Radius.elliptical(5, 6),
- bottomRight: Radius.elliptical(0, 0));
+ topLeft: const Radius.elliptical(1, 2),
+ topRight: const Radius.elliptical(3, 4),
+ bottomLeft: const Radius.elliptical(5, 6),
+ bottomRight: const Radius.elliptical(0, 0));
path.addRRect(rrect);
expect(path.getBounds(), bounds);
expect(path.toRoundedRect(), rrect);
@@ -242,7 +242,7 @@
test('Should compute bounds for polygon', () {
final SurfacePath path = SurfacePath();
- path.addPolygon(<Offset>[
+ path.addPolygon(const <Offset>[
Offset(50, 100),
Offset(250, 100),
Offset(152, 180),
@@ -375,10 +375,10 @@
path.lineTo(110, 190);
path.lineTo(50, 190);
path.close();
- expect(path.contains(Offset(80, 190)), isTrue);
- expect(path.contains(Offset(110, 80)), isTrue);
- expect(path.contains(Offset(110, 190)), isTrue);
- expect(path.contains(Offset(110, 191)), isFalse);
+ expect(path.contains(const Offset(80, 190)), isTrue);
+ expect(path.contains(const Offset(110, 80)), isTrue);
+ expect(path.contains(const Offset(110, 190)), isTrue);
+ expect(path.contains(const Offset(110, 191)), isFalse);
});
test('Should not contain top-left of beveled border', () {
@@ -392,7 +392,7 @@
path.lineTo(15, 40);
path.lineTo(10, 35);
path.close();
- expect(path.contains(Offset(10, 20)), isFalse);
+ expect(path.contains(const Offset(10, 20)), isFalse);
});
test('Computes contains for cubic curves', () {
@@ -406,8 +406,8 @@
path.lineTo(15, 40);
path.cubicTo(10, 40, 10, 40, 10, 35);
path.close();
- expect(path.contains(Offset(10, 20)), isFalse);
- expect(path.contains(Offset(30, 40)), isFalse);
+ expect(path.contains(const Offset(10, 20)), isFalse);
+ expect(path.contains(const Offset(30, 40)), isFalse);
});
// Regression test for https://github.com/flutter/flutter/issues/44470
@@ -420,7 +420,7 @@
..lineTo(0, 100)
..lineTo(50, 0)
..close();
- expect(path.contains(Offset(50, 50)), isTrue);
+ expect(path.contains(const Offset(50, 50)), isTrue);
js_util.setProperty(html.window, 'devicePixelRatio', 1.0);
window.debugOverrideDevicePixelRatio(1.0);
// TODO: Investigate failure on CI. Locally this passes.
@@ -436,22 +436,22 @@
test('Should hit test correctly for malformed rrect', () {
// Correctly formed rrect.
final Path path1 = Path()
- ..addRRect(RRect.fromLTRBR(50, 50, 100, 100, Radius.circular(20)));
- expect(path1.contains(Offset(75, 75)), isTrue);
- expect(path1.contains(Offset(52, 75)), isTrue);
- expect(path1.contains(Offset(50, 50)), isFalse);
- expect(path1.contains(Offset(100, 50)), isFalse);
- expect(path1.contains(Offset(100, 100)), isFalse);
- expect(path1.contains(Offset(50, 100)), isFalse);
+ ..addRRect(RRect.fromLTRBR(50, 50, 100, 100, const Radius.circular(20)));
+ expect(path1.contains(const Offset(75, 75)), isTrue);
+ expect(path1.contains(const Offset(52, 75)), isTrue);
+ expect(path1.contains(const Offset(50, 50)), isFalse);
+ expect(path1.contains(const Offset(100, 50)), isFalse);
+ expect(path1.contains(const Offset(100, 100)), isFalse);
+ expect(path1.contains(const Offset(50, 100)), isFalse);
final Path path2 = Path()
- ..addRRect(RRect.fromLTRBR(50, 50, 100, 100, Radius.circular(100)));
- expect(path2.contains(Offset(75, 75)), isTrue);
- expect(path2.contains(Offset(52, 75)), isTrue);
- expect(path2.contains(Offset(50, 50)), isFalse);
- expect(path2.contains(Offset(100, 50)), isFalse);
- expect(path2.contains(Offset(100, 100)), isFalse);
- expect(path2.contains(Offset(50, 100)), isFalse);
+ ..addRRect(RRect.fromLTRBR(50, 50, 100, 100, const Radius.circular(100)));
+ expect(path2.contains(const Offset(75, 75)), isTrue);
+ expect(path2.contains(const Offset(52, 75)), isTrue);
+ expect(path2.contains(const Offset(50, 50)), isFalse);
+ expect(path2.contains(const Offset(100, 50)), isFalse);
+ expect(path2.contains(const Offset(100, 100)), isFalse);
+ expect(path2.contains(const Offset(50, 100)), isFalse);
});
test('Should set segment masks', () {
diff --git a/lib/web_ui/test/text/canvas_paragraph_builder_test.dart b/lib/web_ui/test/text/canvas_paragraph_builder_test.dart
index 9ad02f3..a9e5122 100644
--- a/lib/web_ui/test/text/canvas_paragraph_builder_test.dart
+++ b/lib/web_ui/test/text/canvas_paragraph_builder_test.dart
@@ -50,7 +50,7 @@
expect(paragraph.toPlainText(), 'Hello');
expect(paragraph.spans, hasLength(1));
- paragraph.layout(ParagraphConstraints(width: double.infinity));
+ paragraph.layout(const ParagraphConstraints(width: double.infinity));
expect(
paragraph.toDomElement().outerHtml,
'<p style="font-size: 13px; $defaultFontFamily $paragraphStyle">'
@@ -61,7 +61,7 @@
);
// Should break "Hello" into "Hel" and "lo".
- paragraph.layout(ParagraphConstraints(width: 39.0));
+ paragraph.layout(const ParagraphConstraints(width: 39.0));
expect(
paragraph.toDomElement().outerHtml,
'<p style="font-size: 13px; $defaultFontFamily $paragraphStyle">'
@@ -89,7 +89,7 @@
expect(paragraph.toPlainText(), 'Hello');
expect(paragraph.spans, hasLength(1));
- paragraph.layout(ParagraphConstraints(width: double.infinity));
+ paragraph.layout(const ParagraphConstraints(width: double.infinity));
expect(
paragraph.toDomElement().outerHtml,
'<p style="$defaultFontSize $defaultFontFamily $paragraphStyle">'
@@ -118,7 +118,7 @@
// On iOS Safari, the height measurement is one extra pixel.
expectedHeight++;
}
- paragraph.layout(ParagraphConstraints(width: double.infinity));
+ paragraph.layout(const ParagraphConstraints(width: double.infinity));
expect(
paragraph.toDomElement().outerHtml,
'<p style="$defaultFontSize $defaultFontFamily $paragraphStyle overflow-y: hidden; height: ${expectedHeight}px;">'
@@ -144,7 +144,7 @@
// On iOS Safari, the height measurement is one extra pixel.
expectedHeight++;
}
- paragraph.layout(ParagraphConstraints(width: 100.0));
+ paragraph.layout(const ParagraphConstraints(width: 100.0));
expect(
paragraph.toDomElement().outerHtml,
'<p style="$defaultFontSize $defaultFontFamily $paragraphStyle width: 100px; overflow-y: hidden; height: ${expectedHeight}px;">'
@@ -172,7 +172,7 @@
expect(paragraph.toPlainText(), 'Hello');
expect(paragraph.spans, hasLength(1));
- paragraph.layout(ParagraphConstraints(width: double.infinity));
+ paragraph.layout(const ParagraphConstraints(width: double.infinity));
expect(
paragraph.toDomElement().outerHtml,
'<p style="line-height: 1.5; font-size: 9px; $defaultFontFamily $paragraphStyle">'
@@ -210,7 +210,7 @@
expect(paragraph.toPlainText(), 'Hello world');
expect(paragraph.spans, hasLength(2));
- paragraph.layout(ParagraphConstraints(width: double.infinity));
+ paragraph.layout(const ParagraphConstraints(width: double.infinity));
expect(
paragraph.toDomElement().outerHtml,
'<p style="font-size: 13px; $defaultFontFamily $paragraphStyle">'
@@ -224,7 +224,7 @@
);
// Should break "Hello world" into "Hello" and " world".
- paragraph.layout(ParagraphConstraints(width: 75.0));
+ paragraph.layout(const ParagraphConstraints(width: 75.0));
expect(
paragraph.toDomElement().outerHtml,
'<p style="font-size: 13px; $defaultFontFamily $paragraphStyle width: 75px;">'
@@ -275,7 +275,7 @@
expect(paragraph.toPlainText(), 'Hello world!');
expect(paragraph.spans, hasLength(3));
- paragraph.layout(ParagraphConstraints(width: double.infinity));
+ paragraph.layout(const ParagraphConstraints(width: double.infinity));
expect(
paragraph.toDomElement().outerHtml,
'<p style="font-size: 13px; $defaultFontFamily $paragraphStyle">'
@@ -339,7 +339,7 @@
// There's a new line between "First" and "Second", but "Second" and
// "ThirdLongLine" remain together since constraints are infinite.
- paragraph.layout(ParagraphConstraints(width: double.infinity));
+ paragraph.layout(const ParagraphConstraints(width: double.infinity));
expect(
paragraph.toDomElement().outerHtml,
'<p style="font-size: 13px; $defaultFontFamily $paragraphStyle">'
@@ -353,7 +353,7 @@
);
// Should break the paragraph into "First", "Second" and "ThirdLongLine".
- paragraph.layout(ParagraphConstraints(width: 180.0));
+ paragraph.layout(const ParagraphConstraints(width: 180.0));
expect(
paragraph.toDomElement().outerHtml,
'<p style="font-size: 13px; $defaultFontFamily $paragraphStyle width: 180px;">'
@@ -387,7 +387,7 @@
// The paragraph should take the font size and family from the span with the
// greatest font size.
- paragraph.layout(ParagraphConstraints(width: double.infinity));
+ paragraph.layout(const ParagraphConstraints(width: double.infinity));
expect(
paragraph.toDomElement().outerHtml,
'<p style="font-size: 18px; ${fontFamilyToAttribute('second')} $paragraphStyle">'
diff --git a/lib/web_ui/test/text/canvas_paragraph_test.dart b/lib/web_ui/test/text/canvas_paragraph_test.dart
index 8177145..d838635 100644
--- a/lib/web_ui/test/text/canvas_paragraph_test.dart
+++ b/lib/web_ui/test/text/canvas_paragraph_test.dart
@@ -392,57 +392,57 @@
// Above the line, at the beginning.
expect(
- paragraph.getPositionForOffset(ui.Offset(0, -5)),
+ paragraph.getPositionForOffset(const ui.Offset(0, -5)),
pos(0, ui.TextAffinity.downstream),
);
// At the top left corner of the line.
expect(
- paragraph.getPositionForOffset(ui.Offset(0, 0)),
+ paragraph.getPositionForOffset(const ui.Offset(0, 0)),
pos(0, ui.TextAffinity.downstream),
);
// At the beginning of the line.
expect(
- paragraph.getPositionForOffset(ui.Offset(0, 5)),
+ paragraph.getPositionForOffset(const ui.Offset(0, 5)),
pos(0, ui.TextAffinity.downstream),
);
// Below the line, at the end.
expect(
- paragraph.getPositionForOffset(ui.Offset(130, 12)),
+ paragraph.getPositionForOffset(const ui.Offset(130, 12)),
pos(13, ui.TextAffinity.upstream),
);
// At the end of the line.
expect(
- paragraph.getPositionForOffset(ui.Offset(130, 5)),
+ paragraph.getPositionForOffset(const ui.Offset(130, 5)),
pos(13, ui.TextAffinity.upstream),
);
// On the left half of "p" in "ipsum".
expect(
- paragraph.getPositionForOffset(ui.Offset(74, 5)),
+ paragraph.getPositionForOffset(const ui.Offset(74, 5)),
pos(7, ui.TextAffinity.downstream),
);
// On the left half of "p" in "ipsum" (above the line).
expect(
- paragraph.getPositionForOffset(ui.Offset(74, -5)),
+ paragraph.getPositionForOffset(const ui.Offset(74, -5)),
pos(7, ui.TextAffinity.downstream),
);
// On the left half of "p" in "ipsum" (below the line).
expect(
- paragraph.getPositionForOffset(ui.Offset(74, 15)),
+ paragraph.getPositionForOffset(const ui.Offset(74, 15)),
pos(7, ui.TextAffinity.downstream),
);
// On the right half of "p" in "ipsum".
expect(
- paragraph.getPositionForOffset(ui.Offset(76, 5)),
+ paragraph.getPositionForOffset(const ui.Offset(76, 5)),
pos(8, ui.TextAffinity.upstream),
);
// At the top of the line, on the left half of "p" in "ipsum".
expect(
- paragraph.getPositionForOffset(ui.Offset(74, 0)),
+ paragraph.getPositionForOffset(const ui.Offset(74, 0)),
pos(7, ui.TextAffinity.downstream),
);
// At the top of the line, on the right half of "p" in "ipsum".
expect(
- paragraph.getPositionForOffset(ui.Offset(76, 0)),
+ paragraph.getPositionForOffset(const ui.Offset(76, 0)),
pos(8, ui.TextAffinity.upstream),
);
});
@@ -460,84 +460,84 @@
// Above the first line, at the beginning.
expect(
- paragraph.getPositionForOffset(ui.Offset(0, -5)),
+ paragraph.getPositionForOffset(const ui.Offset(0, -5)),
pos(0, ui.TextAffinity.downstream),
);
// At the top left corner of the line.
expect(
- paragraph.getPositionForOffset(ui.Offset(0, 0)),
+ paragraph.getPositionForOffset(const ui.Offset(0, 0)),
pos(0, ui.TextAffinity.downstream),
);
// At the beginning of the first line.
expect(
- paragraph.getPositionForOffset(ui.Offset(0, 5)),
+ paragraph.getPositionForOffset(const ui.Offset(0, 5)),
pos(0, ui.TextAffinity.downstream),
);
// At the end of the first line.
expect(
- paragraph.getPositionForOffset(ui.Offset(60, 5)),
+ paragraph.getPositionForOffset(const ui.Offset(60, 5)),
pos(6, ui.TextAffinity.upstream),
);
// At the end of the first line (above the line).
expect(
- paragraph.getPositionForOffset(ui.Offset(60, -5)),
+ paragraph.getPositionForOffset(const ui.Offset(60, -5)),
pos(6, ui.TextAffinity.upstream),
);
// After the end of the first line to the right.
expect(
- paragraph.getPositionForOffset(ui.Offset(70, 5)),
+ paragraph.getPositionForOffset(const ui.Offset(70, 5)),
pos(6, ui.TextAffinity.upstream),
);
// On the left half of " " in "Lorem ".
expect(
- paragraph.getPositionForOffset(ui.Offset(54, 5)),
+ paragraph.getPositionForOffset(const ui.Offset(54, 5)),
pos(5, ui.TextAffinity.downstream),
);
// On the right half of " " in "Lorem ".
expect(
- paragraph.getPositionForOffset(ui.Offset(56, 5)),
+ paragraph.getPositionForOffset(const ui.Offset(56, 5)),
pos(6, ui.TextAffinity.upstream),
);
// At the beginning of the second line "ipsum ".
expect(
- paragraph.getPositionForOffset(ui.Offset(0, 15)),
+ paragraph.getPositionForOffset(const ui.Offset(0, 15)),
pos(6, ui.TextAffinity.downstream),
);
// At the end of the second line.
expect(
- paragraph.getPositionForOffset(ui.Offset(60, 15)),
+ paragraph.getPositionForOffset(const ui.Offset(60, 15)),
pos(12, ui.TextAffinity.upstream),
);
// After the end of the second line to the right.
expect(
- paragraph.getPositionForOffset(ui.Offset(70, 15)),
+ paragraph.getPositionForOffset(const ui.Offset(70, 15)),
pos(12, ui.TextAffinity.upstream),
);
// Below the third line "dolor sit", at the end.
expect(
- paragraph.getPositionForOffset(ui.Offset(90, 40)),
+ paragraph.getPositionForOffset(const ui.Offset(90, 40)),
pos(21, ui.TextAffinity.upstream),
);
// At the end of the third line.
expect(
- paragraph.getPositionForOffset(ui.Offset(90, 25)),
+ paragraph.getPositionForOffset(const ui.Offset(90, 25)),
pos(21, ui.TextAffinity.upstream),
);
// After the end of the third line to the right.
expect(
- paragraph.getPositionForOffset(ui.Offset(100, 25)),
+ paragraph.getPositionForOffset(const ui.Offset(100, 25)),
pos(21, ui.TextAffinity.upstream),
);
// On the left half of " " in "dolor sit".
expect(
- paragraph.getPositionForOffset(ui.Offset(54, 25)),
+ paragraph.getPositionForOffset(const ui.Offset(54, 25)),
pos(17, ui.TextAffinity.downstream),
);
// On the right half of " " in "dolor sit".
expect(
- paragraph.getPositionForOffset(ui.Offset(56, 25)),
+ paragraph.getPositionForOffset(const ui.Offset(56, 25)),
pos(18, ui.TextAffinity.upstream),
);
});
@@ -560,74 +560,74 @@
// Above the first line, at the beginning.
expect(
- paragraph.getPositionForOffset(ui.Offset(0, -5)),
+ paragraph.getPositionForOffset(const ui.Offset(0, -5)),
pos(0, ui.TextAffinity.downstream),
);
// At the beginning of the first line.
expect(
- paragraph.getPositionForOffset(ui.Offset(0, 5)),
+ paragraph.getPositionForOffset(const ui.Offset(0, 5)),
pos(0, ui.TextAffinity.downstream),
);
// At the end of the first line.
expect(
- paragraph.getPositionForOffset(ui.Offset(60, 5)),
+ paragraph.getPositionForOffset(const ui.Offset(60, 5)),
pos(6, ui.TextAffinity.upstream),
);
// After the end of the first line to the right.
expect(
- paragraph.getPositionForOffset(ui.Offset(70, 5)),
+ paragraph.getPositionForOffset(const ui.Offset(70, 5)),
pos(6, ui.TextAffinity.upstream),
);
// On the left half of " " in "Lorem ".
expect(
- paragraph.getPositionForOffset(ui.Offset(54, 5)),
+ paragraph.getPositionForOffset(const ui.Offset(54, 5)),
pos(5, ui.TextAffinity.downstream),
);
// On the right half of " " in "Lorem ".
expect(
- paragraph.getPositionForOffset(ui.Offset(56, 5)),
+ paragraph.getPositionForOffset(const ui.Offset(56, 5)),
pos(6, ui.TextAffinity.upstream),
);
// At the beginning of the second line "ipsum ".
expect(
- paragraph.getPositionForOffset(ui.Offset(0, 15)),
+ paragraph.getPositionForOffset(const ui.Offset(0, 15)),
pos(6, ui.TextAffinity.downstream),
);
// At the end of the second line.
expect(
- paragraph.getPositionForOffset(ui.Offset(60, 15)),
+ paragraph.getPositionForOffset(const ui.Offset(60, 15)),
pos(12, ui.TextAffinity.upstream),
);
// After the end of the second line to the right.
expect(
- paragraph.getPositionForOffset(ui.Offset(70, 15)),
+ paragraph.getPositionForOffset(const ui.Offset(70, 15)),
pos(12, ui.TextAffinity.upstream),
);
// Below the third line "dolor sit", at the end.
expect(
- paragraph.getPositionForOffset(ui.Offset(90, 40)),
+ paragraph.getPositionForOffset(const ui.Offset(90, 40)),
pos(21, ui.TextAffinity.upstream),
);
// At the end of the third line.
expect(
- paragraph.getPositionForOffset(ui.Offset(90, 25)),
+ paragraph.getPositionForOffset(const ui.Offset(90, 25)),
pos(21, ui.TextAffinity.upstream),
);
// After the end of the third line to the right.
expect(
- paragraph.getPositionForOffset(ui.Offset(100, 25)),
+ paragraph.getPositionForOffset(const ui.Offset(100, 25)),
pos(21, ui.TextAffinity.upstream),
);
// On the left half of " " in "dolor sit".
expect(
- paragraph.getPositionForOffset(ui.Offset(54, 25)),
+ paragraph.getPositionForOffset(const ui.Offset(54, 25)),
pos(17, ui.TextAffinity.downstream),
);
// On the right half of " " in "dolor sit".
expect(
- paragraph.getPositionForOffset(ui.Offset(56, 25)),
+ paragraph.getPositionForOffset(const ui.Offset(56, 25)),
pos(18, ui.TextAffinity.upstream),
);
});
@@ -644,7 +644,7 @@
for (int i = 0; i < 15; i++) {
expect(
paragraph.getLineBoundary(ui.TextPosition(offset: i)),
- ui.TextRange(start: 0, end: 15),
+ const ui.TextRange(start: 0, end: 15),
reason: 'failed at offset $i',
);
}
@@ -662,7 +662,7 @@
for (int i = 0; i < 11; i++) {
expect(
paragraph.getLineBoundary(ui.TextPosition(offset: i)),
- ui.TextRange(start: 0, end: 11),
+ const ui.TextRange(start: 0, end: 11),
reason: 'failed at offset $i',
);
}
@@ -671,7 +671,7 @@
for (int i = 11; i < 23; i++) {
expect(
paragraph.getLineBoundary(ui.TextPosition(offset: i)),
- ui.TextRange(start: 11, end: 23),
+ const ui.TextRange(start: 11, end: 23),
reason: 'failed at offset $i',
);
}
@@ -680,7 +680,7 @@
for (int i = 23; i < 33; i++) {
expect(
paragraph.getLineBoundary(ui.TextPosition(offset: i)),
- ui.TextRange(start: 23, end: 33),
+ const ui.TextRange(start: 23, end: 33),
reason: 'failed at offset $i',
);
}
diff --git a/lib/web_ui/test/text/font_loading_test.dart b/lib/web_ui/test/text/font_loading_test.dart
index 66c4478..5b57919 100644
--- a/lib/web_ui/test/text/font_loading_test.dart
+++ b/lib/web_ui/test/text/font_loading_test.dart
@@ -28,7 +28,7 @@
test('surfaces error from invalid font buffer', () async {
await expectLater(
ui.loadFontFromList(Uint8List(0), fontFamily: 'test-font'),
- throwsA(TypeMatcher<Exception>()));
+ throwsA(const TypeMatcher<Exception>()));
},
// TODO(nurhan): https://github.com/flutter/flutter/issues/56702
// TODO(nurhan): https://github.com/flutter/flutter/issues/50770
@@ -53,7 +53,7 @@
test('loading font should clear measurement caches', () async {
final EngineParagraphStyle style = EngineParagraphStyle();
- final ui.ParagraphConstraints constraints =
+ const ui.ParagraphConstraints constraints =
ui.ParagraphConstraints(width: 30.0);
final DomParagraphBuilder domBuilder = DomParagraphBuilder(style);
diff --git a/lib/web_ui/test/text/line_breaker_test.dart b/lib/web_ui/test/text/line_breaker_test.dart
index 6c36931..8545b8c 100644
--- a/lib/web_ui/test/text/line_breaker_test.dart
+++ b/lib/web_ui/test/text/line_breaker_test.dart
@@ -170,7 +170,7 @@
test('trailing spaces and new lines', () {
expect(
findBreaks('foo bar '),
- <LineBreakResult>[
+ const <LineBreakResult>[
LineBreakResult(4, 4, 3, LineBreakType.opportunity),
LineBreakResult(9, 9, 7, LineBreakType.endOfText),
],
@@ -178,7 +178,7 @@
expect(
findBreaks('foo \nbar\nbaz \n'),
- <LineBreakResult>[
+ const <LineBreakResult>[
LineBreakResult(6, 5, 3, LineBreakType.mandatory),
LineBreakResult(10, 9, 9, LineBreakType.mandatory),
LineBreakResult(17, 16, 13, LineBreakType.mandatory),
@@ -190,7 +190,7 @@
test('leading spaces', () {
expect(
findBreaks(' foo'),
- <LineBreakResult>[
+ const <LineBreakResult>[
LineBreakResult(1, 1, 0, LineBreakType.opportunity),
LineBreakResult(4, 4, 4, LineBreakType.endOfText),
],
@@ -198,7 +198,7 @@
expect(
findBreaks(' foo'),
- <LineBreakResult>[
+ const <LineBreakResult>[
LineBreakResult(3, 3, 0, LineBreakType.opportunity),
LineBreakResult(6, 6, 6, LineBreakType.endOfText),
],
@@ -206,7 +206,7 @@
expect(
findBreaks(' foo bar'),
- <LineBreakResult>[
+ const <LineBreakResult>[
LineBreakResult(2, 2, 0, LineBreakType.opportunity),
LineBreakResult(8, 8, 5, LineBreakType.opportunity),
LineBreakResult(11, 11, 11, LineBreakType.endOfText),
@@ -215,7 +215,7 @@
expect(
findBreaks(' \n foo'),
- <LineBreakResult>[
+ const <LineBreakResult>[
LineBreakResult(3, 2, 0, LineBreakType.mandatory),
LineBreakResult(6, 6, 3, LineBreakType.opportunity),
LineBreakResult(9, 9, 9, LineBreakType.endOfText),
diff --git a/lib/web_ui/test/text_editing_test.dart b/lib/web_ui/test/text_editing_test.dart
index 2ebc757..bba4de6 100644
--- a/lib/web_ui/test/text_editing_test.dart
+++ b/lib/web_ui/test/text_editing_test.dart
@@ -445,7 +445,7 @@
});
test('TextInput.requestAutofill', () async {
- final MethodCall requestAutofill = MethodCall('TextInput.requestAutofill');
+ const MethodCall requestAutofill = MethodCall('TextInput.requestAutofill');
sendFrameworkMessage(codec.encodeMethodCall(requestAutofill));
//No-op and without crashing.
diff --git a/lib/web_ui/test/text_test.dart b/lib/web_ui/test/text_test.dart
index 8abf5fa..68d3396 100644
--- a/lib/web_ui/test/text_test.dart
+++ b/lib/web_ui/test/text_test.dart
@@ -326,7 +326,7 @@
*/
final DomParagraph paragraph = builder.build() as DomParagraph;
- paragraph.layout(ParagraphConstraints(width: 800));
+ paragraph.layout(const ParagraphConstraints(width: 800));
// Reference the offsets with the output of `Display arrangement`.
const int offset010 = text00.length;
@@ -334,22 +334,22 @@
const int offset04 = offset030 + text030.length;
const int offset050 = offset04 + text04.length;
// Tap text010.
- expect(paragraph.getPositionForOffset(Offset(700, 10)).offset, offset010);
+ expect(paragraph.getPositionForOffset(const Offset(700, 10)).offset, offset010);
// Tap text030
- expect(paragraph.getPositionForOffset(Offset(600, 30)).offset, offset030);
+ expect(paragraph.getPositionForOffset(const Offset(600, 30)).offset, offset030);
// Tap text050
- expect(paragraph.getPositionForOffset(Offset(220, 70)).offset, offset050);
+ expect(paragraph.getPositionForOffset(const Offset(220, 70)).offset, offset050);
// Tap the left neighbor of text050
- expect(paragraph.getPositionForOffset(Offset(199, 70)).offset, offset04);
+ expect(paragraph.getPositionForOffset(const Offset(199, 70)).offset, offset04);
// Tap the right neighbor of text050. No matter who the right neighbor of
// text0505 is, it must not be text050 itself.
- expect(paragraph.getPositionForOffset(Offset(360, 70)).offset,
+ expect(paragraph.getPositionForOffset(const Offset(360, 70)).offset,
isNot(offset050));
// Tap the neighbor above text050
- expect(paragraph.getPositionForOffset(Offset(220, 59)).offset, offset04);
+ expect(paragraph.getPositionForOffset(const Offset(220, 59)).offset, offset04);
// Tap the neighbor below text050. No matter who the neighbor above text050,
// it must not be text050 itself.
- expect(paragraph.getPositionForOffset(Offset(220, 80)).offset,
+ expect(paragraph.getPositionForOffset(const Offset(220, 80)).offset,
isNot(offset050));
});
diff --git a/lib/web_ui/test/window_test.dart b/lib/web_ui/test/window_test.dart
index 45a0d3a..2180f44 100644
--- a/lib/web_ui/test/window_test.dart
+++ b/lib/web_ui/test/window_test.dart
@@ -41,7 +41,7 @@
test('window.defaultRouteName should not change', () async {
final TestUrlStrategy strategy = TestUrlStrategy.fromEntry(
- TestHistoryEntry('initial state', null, '/initial'),
+ const TestHistoryEntry('initial state', null, '/initial'),
);
await window.debugInitializeHistory(strategy, useSingle: true);
expect(window.defaultRouteName, '/initial');
@@ -59,7 +59,7 @@
await window.debugInitializeHistory(TestUrlStrategy.fromEntry(
// The URL here does not set the PlatformDispatcher's defaultRouteName,
// since it got cached as soon as we read it above.
- TestHistoryEntry('initial state', null, '/not-really-inital/THIS_IS_IGNORED'),
+ const TestHistoryEntry('initial state', null, '/not-really-inital/THIS_IS_IGNORED'),
), useSingle: true);
// Reading it multiple times should return the same value.
expect(window.defaultRouteName, '/initial');
@@ -68,9 +68,9 @@
final Completer<void> callback = Completer<void>();
window.sendPlatformMessage(
'flutter/navigation',
- JSONMethodCodec().encodeMethodCall(MethodCall(
+ const JSONMethodCodec().encodeMethodCall(const MethodCall(
'routeUpdated',
- const <String, dynamic>{'routeName': '/bar'},
+ <String, dynamic>{'routeName': '/bar'},
)),
(_) { callback.complete(); },
);
@@ -85,7 +85,7 @@
test('can switch history mode', () async {
Completer<void> callback;
await window.debugInitializeHistory(TestUrlStrategy.fromEntry(
- TestHistoryEntry('initial state', null, '/initial'),
+ const TestHistoryEntry('initial state', null, '/initial'),
), useSingle: false);
expect(window.browserHistory, isA<MultiEntriesBrowserHistory>());
@@ -93,7 +93,7 @@
callback = Completer<void>();
window.sendPlatformMessage(
'flutter/navigation',
- JSONMethodCodec().encodeMethodCall(MethodCall(method, arguments)),
+ const JSONMethodCodec().encodeMethodCall(MethodCall(method, arguments)),
(_) { callback.complete(); },
);
await callback.future;
@@ -116,7 +116,7 @@
() async {
expect(() async {
await window.handleNavigationMessage(
- JSONMethodCodec().encodeMethodCall(MethodCall(
+ const JSONMethodCodec().encodeMethodCall(const MethodCall(
'routeUpdated',
null, // boom
))
@@ -125,7 +125,7 @@
expect(() async {
await window.handleNavigationMessage(
- JSONMethodCodec().encodeMethodCall(MethodCall(
+ const JSONMethodCodec().encodeMethodCall(const MethodCall(
'routeInformationUpdated',
null, // boom
))
@@ -136,12 +136,12 @@
test('handleNavigationMessage execute request in order.', () async {
// Start with multi entries.
await window.debugInitializeHistory(TestUrlStrategy.fromEntry(
- TestHistoryEntry('initial state', null, '/initial'),
+ const TestHistoryEntry('initial state', null, '/initial'),
), useSingle: false);
expect(window.browserHistory, isA<MultiEntriesBrowserHistory>());
final List<String> executionOrder = <String>[];
window.handleNavigationMessage(
- JSONMethodCodec().encodeMethodCall(MethodCall(
+ const JSONMethodCodec().encodeMethodCall(const MethodCall(
'selectSingleEntryHistory',
null,
))
@@ -149,7 +149,7 @@
executionOrder.add('1');
});
window.handleNavigationMessage(
- JSONMethodCodec().encodeMethodCall(MethodCall(
+ const JSONMethodCodec().encodeMethodCall(const MethodCall(
'selectMultiEntryHistory',
null,
))
@@ -157,7 +157,7 @@
executionOrder.add('2');
});
window.handleNavigationMessage(
- JSONMethodCodec().encodeMethodCall(MethodCall(
+ const JSONMethodCodec().encodeMethodCall(const MethodCall(
'selectSingleEntryHistory',
null,
))
@@ -165,7 +165,7 @@
executionOrder.add('3');
});
await window.handleNavigationMessage(
- JSONMethodCodec().encodeMethodCall(MethodCall(
+ const JSONMethodCodec().encodeMethodCall(const MethodCall(
'routeInformationUpdated',
// ignore: prefer_const_literals_to_create_immutables
<String, dynamic>{
@@ -188,7 +188,7 @@
test('should not throw when using nav1 and nav2 together',
() async {
await window.debugInitializeHistory(TestUrlStrategy.fromEntry(
- TestHistoryEntry('initial state', null, '/initial'),
+ const TestHistoryEntry('initial state', null, '/initial'),
), useSingle: false);
expect(window.browserHistory, isA<MultiEntriesBrowserHistory>());
@@ -196,7 +196,7 @@
Completer<void> callback = Completer<void>();
window.sendPlatformMessage(
'flutter/navigation',
- JSONMethodCodec().encodeMethodCall(MethodCall(
+ const JSONMethodCodec().encodeMethodCall(const MethodCall(
'routeUpdated',
// ignore: prefer_const_literals_to_create_immutables
<String, dynamic>{'routeName': '/bar'},
@@ -211,7 +211,7 @@
callback = Completer<void>();
window.sendPlatformMessage(
'flutter/navigation',
- JSONMethodCodec().encodeMethodCall(MethodCall(
+ const JSONMethodCodec().encodeMethodCall(const MethodCall(
'routeInformationUpdated',
// ignore: prefer_const_literals_to_create_immutables
<String, dynamic>{
@@ -227,7 +227,7 @@
// they can be interleaved safely
await window.handleNavigationMessage(
- JSONMethodCodec().encodeMethodCall(MethodCall(
+ const JSONMethodCodec().encodeMethodCall(const MethodCall(
'routeUpdated',
// ignore: prefer_const_literals_to_create_immutables
<String, dynamic>{'routeName': '/foo'},
@@ -240,14 +240,14 @@
test('can replace in MultiEntriesBrowserHistory',
() async {
await window.debugInitializeHistory(TestUrlStrategy.fromEntry(
- TestHistoryEntry('initial state', null, '/initial'),
+ const TestHistoryEntry('initial state', null, '/initial'),
), useSingle: false);
expect(window.browserHistory, isA<MultiEntriesBrowserHistory>());
Completer<void> callback = Completer<void>();
window.sendPlatformMessage(
'flutter/navigation',
- JSONMethodCodec().encodeMethodCall(MethodCall(
+ const JSONMethodCodec().encodeMethodCall(const MethodCall(
'routeInformationUpdated',
// ignore: prefer_const_literals_to_create_immutables
<String, dynamic>{
@@ -264,7 +264,7 @@
callback = Completer<void>();
window.sendPlatformMessage(
'flutter/navigation',
- JSONMethodCodec().encodeMethodCall(MethodCall(
+ const JSONMethodCodec().encodeMethodCall(const MethodCall(
'routeInformationUpdated',
// ignore: prefer_const_literals_to_create_immutables
<String, dynamic>{
@@ -282,7 +282,7 @@
callback = Completer<void>();
window.sendPlatformMessage(
'flutter/navigation',
- JSONMethodCodec().encodeMethodCall(MethodCall(
+ const JSONMethodCodec().encodeMethodCall(const MethodCall(
'routeInformationUpdated',
// ignore: prefer_const_literals_to_create_immutables
<String, dynamic>{
@@ -312,7 +312,7 @@
final Completer<void> callback = Completer<void>();
window.sendPlatformMessage(
'flutter/navigation',
- JSONMethodCodec().encodeMethodCall(MethodCall(
+ const JSONMethodCodec().encodeMethodCall(const MethodCall(
'routeUpdated',
// ignore: prefer_const_literals_to_create_immutables
<String, dynamic>{'routeName': '/bar'},
@@ -338,7 +338,7 @@
final Completer<void> callback = Completer<void>();
window.sendPlatformMessage(
'flutter/navigation',
- JSONMethodCodec().encodeMethodCall(MethodCall(
+ const JSONMethodCodec().encodeMethodCall(const MethodCall(
'routeInformationUpdated',
// ignore: prefer_const_literals_to_create_immutables
<String, dynamic>{
@@ -380,7 +380,7 @@
test('cannot set url strategy after it is initialized', () async {
final TestUrlStrategy testStrategy = TestUrlStrategy.fromEntry(
- TestHistoryEntry('initial state', null, '/'),
+ const TestHistoryEntry('initial state', null, '/'),
);
await window.debugInitializeHistory(testStrategy, useSingle: true);