This commit is contained in:
Ferhat
2021-07-27 13:50:26 -07:00
committed by GitHub
parent fc9f1feaf8
commit ca82f36e70
54 changed files with 153 additions and 163 deletions

View File

@@ -26,8 +26,6 @@ linter:
prefer_conditional_assignment: false
prefer_const_constructors: false
prefer_const_constructors_in_immutables: false
prefer_const_declarations: false
prefer_const_literals_to_create_immutables: false
prefer_foreach: false
prefer_generic_function_type_aliases: false
prefer_initializing_formals: false
@@ -37,14 +35,6 @@ linter:
recursive_getters: false
slash_for_doc_comments: false
sort_unnamed_constructors_first: false
test_types_in_equals: false
throw_in_finally: false
type_init_formals: false
unnecessary_getters_setters: false
use_rethrow_when_possible: false
valid_regexps: false
use_function_type_syntax_for_parameters: false
avoid_single_cascade_in_expression_statements: false
flutter_style_todos: false
# We have some legitimate use-cases for this (preserve tear-off identity)

View File

@@ -97,7 +97,7 @@ abstract class Browser {
/// which asynchronously returns the browser process. Any errors in
/// [startBrowser] (even those raised asynchronously after it returns) are
/// piped to [onExit] and will cause the browser to be killed.
Browser(Future<Process> startBrowser()) {
Browser(Future<Process> Function() startBrowser) {
// Don't return a Future here because there's no need for the caller to wait
// for the process to actually start. They should just wait for the HTTP
// request instead.

View File

@@ -15,8 +15,7 @@ import 'watcher.dart';
class BuildCommand extends Command<bool> with ArgUtils<bool> {
BuildCommand() {
argParser
..addFlag(
argParser.addFlag(
'watch',
defaultsTo: false,
abbr: 'w',

View File

@@ -112,7 +112,7 @@ class Chrome extends Browser {
}, remoteDebuggerCompleter.future);
}
Chrome._(Future<Process> startBrowser(), this.remoteDebuggerUrl)
Chrome._(Future<Process> Function() startBrowser, this.remoteDebuggerUrl)
: super(startBrowser);
}
@@ -157,8 +157,9 @@ Future<Process> _spawnChromiumProcess(String executable, List<String> args, { St
})
.firstWhere((String line) => line.startsWith('DevTools listening'), orElse: () {
if (hitGlibcBug) {
final String message = 'Encountered glibc bug https://sourceware.org/bugzilla/show_bug.cgi?id=19329. '
'Will try launching browser again.';
const String message = 'Encountered glibc bug '
'https://sourceware.org/bugzilla/show_bug.cgi?id=19329. '
'Will try launching browser again.';
print(message);
return message;
}

View File

@@ -34,8 +34,7 @@ class ChromeArgParser extends BrowserArgParser {
_pinnedChromeBuildNumber =
PlatformBinding.instance.getChromeBuild(browserLock);
argParser
..addOption(
argParser.addOption(
'chrome-version',
defaultsTo: pinnedChromeBuildNumber,
help: 'The Chrome version to use while running tests. If the requested '
@@ -234,8 +233,8 @@ class ChromeInstaller {
..createSync(recursive: true)
..writeAsBytesSync(data);
} else {
io.Directory(path.join(versionDir.path, filename))
..create(recursive: true);
io.Directory(path.join(versionDir.path, filename)).create(
recursive: true);
}
}

View File

@@ -14,7 +14,7 @@ class CreateSimulatorCommand extends Command<bool> with ArgUtils<bool> {
CreateSimulatorCommand() {
IosSafariArgParser.instance.populateOptions(argParser);
argParser
..addOption(
.addOption(
'type',
defaultsTo: _defaultType,
help: 'Type of the mobile simulator. Currently the only iOS '
@@ -24,7 +24,7 @@ class CreateSimulatorCommand extends Command<bool> with ArgUtils<bool> {
}
/// Currently the only iOS Simulators are supported.
static final String _defaultType = 'iOS';
static const String _defaultType = 'iOS';
@override
String get name => 'create_simulator';

View File

@@ -72,5 +72,5 @@ class Edge extends Browser {
});
}
Edge._(Future<Process> startBrowser()) : super(startBrowser);
Edge._(Future<Process> Function() startBrowser) : super(startBrowser);
}

View File

@@ -24,8 +24,7 @@ class EdgeArgParser extends BrowserArgParser {
@override
void populateOptions(ArgParser argParser) {
argParser
..addOption(
argParser.addOption(
'edge-version',
defaultsTo: 'system',
help: 'The Edge version to use while running tests. The Edge '

View File

@@ -63,7 +63,7 @@ class Firefox extends Browser {
);
// Using a profile on opening will prevent popups related to profiles.
final String _profile = '''
const String _profile = '''
user_pref("browser.shell.checkDefaultBrowser", false);
user_pref("dom.disable_open_during_load", false);
user_pref("dom.max_script_run_time", 0);
@@ -111,6 +111,6 @@ user_pref("dom.max_script_run_time", 0);
}, remoteDebuggerCompleter.future);
}
Firefox._(Future<Process> startBrowser(), this.remoteDebuggerUrl)
Firefox._(Future<Process> Function() startBrowser, this.remoteDebuggerUrl)
: super(startBrowser);
}

View File

@@ -28,8 +28,7 @@ class FirefoxArgParser extends BrowserArgParser {
final YamlMap browserLock = BrowserLock.instance.configuration;
final String firefoxVersion = browserLock['firefox']['version'] as String;
argParser
..addOption(
argParser.addOption(
'firefox-version',
defaultsTo: firefoxVersion,
help: 'The Firefox version to use while running tests. If the requested '

View File

@@ -22,8 +22,7 @@ class SafariArgParser extends BrowserArgParser {
@override
void populateOptions(ArgParser argParser) {
argParser
..addOption(
argParser.addOption(
'safari-version',
defaultsTo: 'system',
help: 'The Safari version to use while running tests. The Safari '

View File

@@ -72,7 +72,7 @@ class SafariIos extends Browser {
});
}
SafariIos._(Future<io.Process> startBrowser()) : super(startBrowser);
SafariIos._(Future<io.Process> Function() startBrowser) : super(startBrowser);
}
/// [ScreenshotManager] implementation for Safari.

View File

@@ -89,5 +89,5 @@ class SafariMacOs extends Browser {
});
}
SafariMacOs._(Future<Process> startBrowser()) : super(startBrowser);
SafariMacOs._(Future<Process> Function() startBrowser) : super(startBrowser);
}

View File

@@ -337,8 +337,7 @@ class GeneralTestsArgumentParser {
bool verbose = false;
void populateOptions(ArgParser argParser) {
argParser
..addFlag(
argParser.addFlag(
'verbose',
defaultsTo: false,
help: 'Flag to indicate extra logs should also be printed.',

View File

@@ -88,9 +88,9 @@ const String canvasKitBaseUrl = String.fromEnvironment(
'FLUTTER_WEB_CANVASKIT_URL',
defaultValue: 'https://unpkg.com/canvaskit-wasm@0.28.1/bin/',
);
final String canvasKitBuildUrl =
const String canvasKitBuildUrl =
canvasKitBaseUrl + (kProfileMode ? 'profiling/' : '');
final String canvasKitJavaScriptBindingsUrl =
const String canvasKitJavaScriptBindingsUrl =
canvasKitBuildUrl + 'canvaskit.js';
String canvasKitWasmModuleUrl(String file) => _currentCanvasKitBase! + file;

View File

@@ -219,7 +219,7 @@ class Surface {
final int surfaceHeight = _currentSurfaceSize!.height.ceil();
final double offset =
(_pixelHeight - surfaceHeight) / window.devicePixelRatio;
htmlCanvas!.style..transform = 'translate(0, -${offset}px)';
htmlCanvas!.style.transform = 'translate(0, -${offset}px)';
}
void _contextRestoredListener(html.Event event) {

View File

@@ -67,7 +67,7 @@ class CrossFrameCache<T> {
void _addToCache(String key, _CrossFrameCacheItem<T> item) {
_cache ??= <String, List<_CrossFrameCacheItem<T>>>{};
(_cache![key] ??= <_CrossFrameCacheItem<T>>[])..add(item);
(_cache![key] ??= <_CrossFrameCacheItem<T>>[]).add(item);
}
/// Given a key, consumes an item that has been cached in a prior frame.

View File

@@ -216,13 +216,13 @@ class Conic {
// Map conic to 3D.
final double tx0 = p0x;
final double ty0 = p0y;
final double tz0 = 1;
const double tz0 = 1;
final double tx1 = p1x * fW;
final double ty1 = p1y * fW;
final double tz1 = fW;
final double tx2 = p2x;
final double ty2 = p2y;
final double tz2 = 1;
const double tz2 = 1;
// Now interpolate each dimension.
final double dx0 = tx0 + (tx1 - tx0) * t;
final double dx2 = tx1 + (tx2 - tx1) * t;
@@ -335,7 +335,7 @@ class Conic {
static double evalDenominator(double w, double t) {
final double B = 2 * (w - 1);
final double C = 1;
const double C = 1;
final double A = -B;
return polyEval(A, B, C, t);
}

View File

@@ -163,7 +163,7 @@ double? chopMonoAtY(Float32List _buffer, int bufferStartPos, double y) {
}
// Bisection / linear convergance.
final double tolerance = 1.0 / 65536;
const double tolerance = 1.0 / 65536;
do {
final double tMid = (tPos + tNeg) / 2.0;
final double y01 = ycrv0 + (ycrv1 - ycrv0) * tMid;

View File

@@ -902,7 +902,7 @@ class SurfacePath implements ui.Path {
assert(direction != SPathDirection.kUnknown);
final bool isOval = _hasOnlyMoveTos();
final double weight = SPath.scalarRoot2Over2;
const double weight = SPath.scalarRoot2Over2;
final double left = oval.left;
final double right = oval.right;
final double centerX = (left + right) / 2.0;
@@ -1018,7 +1018,7 @@ class SurfacePath implements ui.Path {
// degenerate(oval) => line points are collapsing.
_addOval(bounds, direction, startIndex ~/ 2);
} else {
final double weight = SPath.scalarRoot2Over2;
const double weight = SPath.scalarRoot2Over2;
final double left = bounds.left;
final double right = bounds.right;
final double top = bounds.top;

View File

@@ -309,7 +309,7 @@ class PathRef {
if (other.runtimeType != runtimeType) {
return false;
}
return equals(other as PathRef);
return other is PathRef && equals(other);
}
@override
@@ -876,7 +876,7 @@ class PathRef {
for (int i = 0; i < len; i += 2) {
final double pointX = fPoints[i];
final double pointY = fPoints[i + 1];
final double tolerance = 0.0001;
const double tolerance = 0.0001;
final bool pointIsFinite = pointX.isFinite && pointY.isFinite;
if (pointIsFinite &&
(pointX + tolerance < boundsLeft ||

View File

@@ -314,7 +314,7 @@ class Convexicator {
math.max(curVecX, math.max(curVecY, math.max(lastX, lastY))),
-smallest);
if (SPath.nearlyEqual(largest, largest + cross)) {
final double nearlyZeroSquared =
const double nearlyZeroSquared =
SPath.scalarNearlyZero * SPath.scalarNearlyZero;
if (SPath.nearlyEqual(lengthSquared(lastX, lastY), nearlyZeroSquared) ||
SPath.nearlyEqual(lengthSquared(curVecX, curVecY), nearlyZeroSquared)) {

View File

@@ -76,7 +76,7 @@ class PersistedShaderMask extends PersistedContainerSurface
html.Element createElement() {
final html.Element element = defaultCreateElement('flt-shader-mask');
final html.Element container = html.Element.tag('flt-mask-interior');
container.style..position = 'absolute';
container.style.position = 'absolute';
_childContainer = container;
element.append(_childContainer!);
return element;

View File

@@ -524,11 +524,7 @@ abstract class PersistedSurface implements ui.EngineLayer {
/// transforms as well as this layer's transform (if any).
///
/// The value is update by [recomputeTransformAndClip].
Matrix4? get transform => _transform;
set transform(Matrix4? value) {
_transform = value;
}
Matrix4? _transform;
Matrix4? transform;
/// The intersection at this surface level.
///
@@ -555,7 +551,7 @@ abstract class PersistedSurface implements ui.EngineLayer {
///
/// This method is called by the [preroll] method.
void recomputeTransformAndClip() {
_transform = parent!._transform;
transform = parent!.transform;
localClipBounds = null;
projectedClip = null;
}
@@ -661,7 +657,7 @@ abstract class PersistedContainerSurface extends PersistedSurface {
@override
void recomputeTransformAndClip() {
_transform = parent!._transform;
transform = parent!.transform;
localClipBounds = null;
projectedClip = null;
}

View File

@@ -1012,7 +1012,7 @@ bool _handleWebTestEnd2EndMessage(MethodCodec codec, ByteData? data) {
}
/// Invokes [callback] inside the given [zone].
void invoke(void callback()?, Zone? zone) {
void invoke(void Function()? callback, Zone? zone) {
if (callback == null) {
return;
}
@@ -1027,7 +1027,7 @@ void invoke(void callback()?, Zone? zone) {
}
/// Invokes [callback] inside the given [zone] passing it [arg].
void invoke1<A>(void callback(A a)?, Zone? zone, A arg) {
void invoke1<A>(void Function(A a)? callback, Zone? zone, A arg) {
if (callback == null) {
return;
}

View File

@@ -646,7 +646,7 @@ class CanvasTextMeasurementService extends TextMeasurementService {
maxIntrinsicWidth: maxIntrinsicCalculator.value,
width: constraints.width,
lines: linesCalculator.lines,
placeholderBoxes: <ui.TextBox>[],
placeholderBoxes: const <ui.TextBox>[],
textAlign: paragraph.textAlign,
textDirection: paragraph.textDirection,
);

View File

@@ -38,7 +38,7 @@ void testMain() {
}
testCanvas('draws laid out paragraph', (EngineCanvas canvas) {
final ui.Rect screenRect = const ui.Rect.fromLTWH(0, 0, 100, 100);
const ui.Rect screenRect = ui.Rect.fromLTWH(0, 0, 100, 100);
final RecordingCanvas recordingCanvas = RecordingCanvas(screenRect);
final ui.ParagraphBuilder builder =
ui.ParagraphBuilder(ui.ParagraphStyle());
@@ -63,7 +63,7 @@ void testMain() {
testCanvas('ignores paragraphs that were not laid out',
(EngineCanvas canvas) {
final ui.Rect screenRect = const ui.Rect.fromLTWH(0, 0, 100, 100);
const ui.Rect screenRect = ui.Rect.fromLTWH(0, 0, 100, 100);
final RecordingCanvas recordingCanvas = RecordingCanvas(screenRect);
final ui.ParagraphBuilder builder =
ui.ParagraphBuilder(ui.ParagraphStyle());

View File

@@ -117,15 +117,15 @@ void testMain() {
const double cy = 100;
const double startAngle = 0.0;
const double endAngle = 90.0;
final double startRad = startAngle * math.pi / 180.0;
final double endRad = endAngle * math.pi / 180.0;
const double startRad = startAngle * math.pi / 180.0;
const double endRad = endAngle * math.pi / 180.0;
final double startX = cx + (rx * math.cos(startRad));
final double startY = cy + (ry * math.sin(startRad));
final double endX = cx + (rx * math.cos(endRad));
final double endY = cy + (ry * math.sin(endRad));
final bool clockwise = endAngle > startAngle;
const bool clockwise = endAngle > startAngle;
final bool largeArc = (endAngle - startAngle).abs() > 180.0;
final Path path = Path()
..moveTo(startX, startY)
@@ -146,15 +146,15 @@ void testMain() {
const double cy = 100;
const double startAngle = 0.0;
const double endAngle = 180.0;
final double startRad = startAngle * math.pi / 180.0;
final double endRad = endAngle * math.pi / 180.0;
const double startRad = startAngle * math.pi / 180.0;
const double endRad = endAngle * math.pi / 180.0;
final double startX = cx + (rx * math.cos(startRad));
final double startY = cy + (ry * math.sin(startRad));
final double endX = cx + (rx * math.cos(endRad));
final double endY = cy + (ry * math.sin(endRad));
final bool clockwise = endAngle > startAngle;
const bool clockwise = endAngle > startAngle;
final bool largeArc = (endAngle - startAngle).abs() > 180.0;
final Path path = Path()
..moveTo(startX, startY)
@@ -175,15 +175,15 @@ void testMain() {
const double cy = 100;
const double startAngle = 0.0;
const double endAngle = 270.0;
final double startRad = startAngle * math.pi / 180.0;
final double endRad = endAngle * math.pi / 180.0;
const double startRad = startAngle * math.pi / 180.0;
const double endRad = endAngle * math.pi / 180.0;
final double startX = cx + (rx * math.cos(startRad));
final double startY = cy + (ry * math.sin(startRad));
final double endX = cx + (rx * math.cos(endRad));
final double endY = cy + (ry * math.sin(endRad));
final bool clockwise = endAngle > startAngle;
const bool clockwise = endAngle > startAngle;
final bool largeArc = (endAngle - startAngle).abs() > 180.0;
final Path path = Path()
..moveTo(startX, startY)
@@ -204,15 +204,15 @@ void testMain() {
const double cy = 100;
const double startAngle = 0.0;
const double endAngle = 270.0;
final double startRad = startAngle * math.pi / 180.0;
final double endRad = endAngle * math.pi / 180.0;
const double startRad = startAngle * math.pi / 180.0;
const double endRad = endAngle * math.pi / 180.0;
final double startX = cx + (rx * math.cos(startRad));
final double startY = cy + (ry * math.sin(startRad));
final double endX = cx + (rx * math.cos(endRad));
final double endY = cy + (ry * math.sin(endRad));
final bool clockwise = endAngle > startAngle;
const bool clockwise = endAngle > startAngle;
final bool largeArc = (endAngle - startAngle).abs() > 180.0;
final Path path = Path()
..moveTo(startX, startY)

View File

@@ -16,8 +16,8 @@ void main() {
void testMain() {
group('PlatformViewManager', () {
final String viewType = 'forTest';
final int viewId = 6;
const String viewType = 'forTest';
const int viewId = 6;
late PlatformViewManager contentManager;
@@ -78,8 +78,8 @@ void testMain() {
});
group('renderContent', () {
final String unregisteredViewType = 'unregisteredForTest';
final String anotherViewType = 'anotherViewType';
const String unregisteredViewType = 'unregisteredForTest';
const String anotherViewType = 'anotherViewType';
setUp(() {
contentManager.registerFactory(viewType, (int id) {

View File

@@ -19,8 +19,8 @@ final MethodCodec codec = StandardMethodCodec();
void testMain() {
group('PlatformViewMessageHandler', () {
group('handlePlatformViewCall', () {
final String viewType = 'forTest';
final int viewId = 6;
const String viewType = 'forTest';
const int viewId = 6;
late PlatformViewManager contentManager;
late Completer<ByteData?> completer;
late Completer<html.Element> contentCompleter;

View File

@@ -14,7 +14,7 @@ void main() {
void testMain() {
group('PlatformViewManager', () {
final int viewId = 6;
const int viewId = 6;
group('createPlatformViewSlot', () {
test(

View File

@@ -16,7 +16,7 @@ void main() {
void testMain() {
late RecordingCanvas underTest;
late MockEngineCanvas mockCanvas;
final Rect screenRect = Rect.largest;
const Rect screenRect = Rect.largest;
setUp(() {
underTest = RecordingCanvas(screenRect);

View File

@@ -760,7 +760,7 @@ class MockPersistedPicture extends PersistedPicture {
final EnginePictureRecorder recorder = EnginePictureRecorder();
// Use the largest cull rect so that layer clips are effective. The tests
// rely on this.
recorder.beginRecording(ui.Rect.largest)..drawPaint(SurfacePaint());
recorder.beginRecording(ui.Rect.largest).drawPaint(SurfacePaint());
return MockPersistedPicture._(recorder.endRecording());
}

View File

@@ -12,12 +12,12 @@ void main() {
}
void testMain() {
final String mat2Sample = 'mat2(1.1, 2.1, 1.2, 2.2)';
final String mat3Sample = 'mat3(1.1, 2.1, 3.1, // first column (not row!)\n'
const String mat2Sample = 'mat2(1.1, 2.1, 1.2, 2.2)';
const String mat3Sample = 'mat3(1.1, 2.1, 3.1, // first column (not row!)\n'
'1.2, 2.2, 3.2, // second column\n'
'1.3, 2.3, 3.3 // third column\n'
')';
final String mat4Sample = 'mat3(1.1, 2.1, 3.1, 4.1,\n'
const String mat4Sample = 'mat3(1.1, 2.1, 3.1, 4.1,\n'
'1.2, 2.2, 3.2, 4.2,\n'
'1.3, 2.3, 3.3, 4.3,\n'
'1.4, 2.4, 3.4, 4.4,\n'

View File

@@ -54,7 +54,7 @@ void testMain() {
test('Should compare equality based on ulps', () {
// If number of floats between a=1.1 and b are below 16, equals should
// return true.
final double a = 1.1;
const double a = 1.1;
final int aBits = floatAs2sCompliment(a);
double b = twosComplimentAsFloat(aBits + 1);
expect(almostEqualUlps(a, b), isTrue);

View File

@@ -306,7 +306,7 @@ void testMain() {
final Completer<bool> completer = Completer<bool>();
final ByteData inputData = JSONMethodCodec().encodeMethodCall(MethodCall(
'SystemChrome.setPreferredOrientations',
<dynamic>[]))!;
const <dynamic>[]))!;
window.sendPlatformMessage(
'flutter/platform',

View File

@@ -52,8 +52,8 @@ Future<void> testMain() async {
final engine.RecordingCanvas rc =
engine.RecordingCanvas(const Rect.fromLTRB(0, 0, 500, 500));
rc.save();
final double testWidth = 200;
final double testHeight = 150;
const double testWidth = 200;
const double testHeight = 150;
final Path path = Path();
path.addOval(Rect.fromLTWH(100, 30, testWidth, testHeight));
rc.clipPath(path);
@@ -77,8 +77,8 @@ Future<void> testMain() async {
final engine.RecordingCanvas rc =
engine.RecordingCanvas(const Rect.fromLTRB(0, 0, 500, 500));
rc.save();
final double testWidth = 200;
final double testHeight = 150;
const double testWidth = 200;
const double testHeight = 150;
final Path paintPath = Path();
paintPath.addRect(Rect.fromLTWH(-50, 0, testWidth, testHeight));
@@ -105,8 +105,8 @@ Future<void> testMain() async {
final engine.RecordingCanvas rc =
engine.RecordingCanvas(const Rect.fromLTRB(0, 0, 500, 500));
rc.save();
final double testWidth = 200;
final double testHeight = 150;
const double testWidth = 200;
const double testHeight = 150;
final Path paintPath = Path();
paintPath.addRect(Rect.fromLTWH(-50, 0, testWidth, testHeight));

View File

@@ -19,7 +19,7 @@ Future<void> testMain() async {
/// Regression test for https://github.com/flutter/flutter/issues/64734.
test('Clips using difference', () async {
final Rect region = const Rect.fromLTRB(0, 0, 400, 300);
const Rect region = Rect.fromLTRB(0, 0, 400, 300);
final RecordingCanvas canvas = RecordingCanvas(region);
final Rect titleRect = Rect.fromLTWH(20, 0, 50, 20);
final SurfacePaint paint = SurfacePaint()
@@ -34,7 +34,7 @@ Future<void> testMain() async {
} finally {
canvas.restore();
}
canvas..drawRect(titleRect, paint);
canvas.drawRect(titleRect, paint);
await canvasScreenshot(canvas, 'clip_op_difference',
region: const Rect.fromLTRB(0, 0, 420, 360));
});

View File

@@ -666,7 +666,7 @@ void _testCullRectComputation() {
test('pushClipPath', () async {
final SurfaceSceneBuilder builder = SurfaceSceneBuilder();
final ui.Path path = ui.Path();
path..addRect(const ui.Rect.fromLTRB(10, 10, 60, 60));
path.addRect(const ui.Rect.fromLTRB(10, 10, 60, 60));
builder.pushClipPath(
path,
);

View File

@@ -349,7 +349,7 @@ Future<void> testMain() async {
// Creates a picture
test('Paints nine slice image', () async {
final Rect region = const Rect.fromLTWH(0, 0, 500, 500);
const Rect region = Rect.fromLTWH(0, 0, 500, 500);
final EnginePictureRecorder recorder = EnginePictureRecorder();
final Canvas canvas = Canvas(recorder, region);
final Image testImage = createNineSliceImage();
@@ -379,7 +379,7 @@ Future<void> testMain() async {
// Tests for correct behavior when using drawImageNine with a destination
// size that is too small to render the center portion of the original image.
test('Paints nine slice image', () async {
final Rect region = const Rect.fromLTWH(0, 0, 100, 100);
const Rect region = Rect.fromLTWH(0, 0, 100, 100);
final EnginePictureRecorder recorder = EnginePictureRecorder();
final Canvas canvas = Canvas(recorder, region);
final Image testImage = createNineSliceImage();
@@ -414,7 +414,7 @@ Future<void> testMain() async {
// the image we did not apply `transform-origin: 0 0 0` to the clipping
// element which resulted in an undesirable offset.
test('Paints clipped and transformed image', () async {
final Rect region = const Rect.fromLTRB(0, 0, 60, 70);
const Rect region = Rect.fromLTRB(0, 0, 60, 70);
final RecordingCanvas canvas = RecordingCanvas(region);
canvas.translate(10, 10);
canvas.transform(Matrix4.rotationZ(0.4).storage);
@@ -431,7 +431,7 @@ Future<void> testMain() async {
/// Regression test for https://github.com/flutter/flutter/issues/61245
test('Should render image with perspective', () async {
final Rect region = const Rect.fromLTRB(0, 0, 200, 200);
const Rect region = Rect.fromLTRB(0, 0, 200, 200);
final RecordingCanvas canvas = RecordingCanvas(region);
canvas.translate(10, 10);
canvas.drawImage(createTestImage(), Offset(0, 0), SurfacePaint());
@@ -448,7 +448,7 @@ Future<void> testMain() async {
/// Regression test for https://github.com/flutter/flutter/issues/61245
test('Should render image with perspective inside clip area', () async {
final Rect region = const Rect.fromLTRB(0, 0, 200, 200);
const Rect region = Rect.fromLTRB(0, 0, 200, 200);
final RecordingCanvas canvas = RecordingCanvas(region);
canvas.drawRect(region, SurfacePaint()..color = Color(0xFFE0E0E0));
canvas.translate(10, 10);
@@ -468,7 +468,7 @@ Future<void> testMain() async {
});
test('Should render rect with perspective transform', () async {
final Rect region = const Rect.fromLTRB(0, 0, 400, 400);
const Rect region = Rect.fromLTRB(0, 0, 400, 400);
final RecordingCanvas canvas = RecordingCanvas(region);
canvas.drawRect(region, SurfacePaint()..color = Color(0xFFE0E0E0));
canvas.translate(20, 20);
@@ -492,7 +492,7 @@ Future<void> testMain() async {
});
test('Should render color and ovals with perspective transform', () async {
final Rect region = const Rect.fromLTRB(0, 0, 400, 400);
const Rect region = Rect.fromLTRB(0, 0, 400, 400);
final RecordingCanvas canvas = RecordingCanvas(region);
canvas.drawRect(region, SurfacePaint()..color = Color(0xFFFF0000));
canvas.drawColor(Color(0xFFE0E0E0), BlendMode.src);
@@ -517,7 +517,7 @@ Future<void> testMain() async {
});
test('Should render path with perspective transform', () async {
final Rect region = const Rect.fromLTRB(0, 0, 400, 400);
const Rect region = Rect.fromLTRB(0, 0, 400, 400);
final RecordingCanvas canvas = RecordingCanvas(region);
canvas.drawRect(region, SurfacePaint()..color = Color(0xFFFF0000));
canvas.drawColor(Color(0xFFE0E0E0), BlendMode.src);
@@ -549,7 +549,7 @@ Future<void> testMain() async {
});
test('Should render path with perspective transform', () async {
final Rect region = const Rect.fromLTRB(0, 0, 400, 400);
const Rect region = Rect.fromLTRB(0, 0, 400, 400);
final RecordingCanvas canvas = RecordingCanvas(region);
canvas.drawRect(region, SurfacePaint()..color = Color(0xFFFF0000));
canvas.drawColor(Color(0xFFE0E0E0), BlendMode.src);

View File

@@ -270,7 +270,7 @@ Future<void> testMain() async {
// Draw a rect in the placeholder.
// Leave some padding around the placeholder to make the black paragraph
// background visible.
final double padding = 5;
const double padding = 5;
final TextBox placeholderBox = paragraph2.getBoxesForPlaceholders().single;
canvas.drawRect(
placeholderBox.toRect().shift(offset).deflate(padding),
@@ -371,11 +371,11 @@ Future<void> testMain() async {
});
void testFontFeatures(EngineCanvas canvas) {
final String text = 'Aa Bb Dd Ee Ff Difficult';
const String text = 'Aa Bb Dd Ee Ff Difficult';
final FontFeature enableSmallCaps = FontFeature('smcp');
final FontFeature disableSmallCaps = FontFeature('smcp', 0);
final String numeric = '123.4560';
const String numeric = '123.4560';
final FontFeature enableOnum = FontFeature('onum');
final FontFeature disableLigatures = FontFeature('liga', 0);

View File

@@ -25,9 +25,9 @@ Future<void> testMain() async {
Offset offset = Offset.zero;
CanvasParagraph paragraph;
final double fontSize = 22.0;
final double width = 126.0;
final double padding = 20.0;
const double fontSize = 22.0;
const double width = 126.0;
const double padding = 20.0;
paragraph = rich(
EngineParagraphStyle(fontFamily: 'Roboto', fontSize: fontSize, ellipsis: '...'),

View File

@@ -25,7 +25,7 @@ Future<void> testMain() async {
setUpStableTestFonts();
void paintTest(EngineCanvas canvas, PaintTest painter) {
final Rect screenRect = const Rect.fromLTWH(0, 0, 600, 600);
const Rect screenRect = Rect.fromLTWH(0, 0, 600, 600);
final RecordingCanvas recordingCanvas = RecordingCanvas(screenRect);
painter(recordingCanvas);
recordingCanvas.endRecording();

View File

@@ -28,7 +28,7 @@ Future<void> testMain() async {
setUpStableTestFonts();
testEachCanvas('draws paragraphs with placeholders', (EngineCanvas canvas) {
final Rect screenRect = const Rect.fromLTWH(0, 0, 600, 600);
const Rect screenRect = Rect.fromLTWH(0, 0, 600, 600);
final RecordingCanvas recordingCanvas = RecordingCanvas(screenRect);
Offset offset = Offset.zero;
@@ -51,7 +51,7 @@ Future<void> testMain() async {
});
testEachCanvas('text alignment and placeholders', (EngineCanvas canvas) {
final Rect screenRect = const Rect.fromLTWH(0, 0, 600, 600);
const Rect screenRect = Rect.fromLTWH(0, 0, 600, 600);
final RecordingCanvas recordingCanvas = RecordingCanvas(screenRect);
Offset offset = Offset.zero;

View File

@@ -67,10 +67,10 @@ Future<void> testMain() async {
test('Should calculate tangent on cubic curve', () async {
final Path path = Path();
final double p1x = 240;
final double p1y = 120;
final double p2x = 320;
final double p2y = 25;
const double p1x = 240;
const double p1y = 120;
const double p2x = 320;
const double p2y = 25;
path.moveTo(150, 20);
path.quadraticBezierTo(p1x, p1y, p2x, p2y);
final PathMetric metric = path.computeMetrics().first;
@@ -83,10 +83,10 @@ Future<void> testMain() async {
test('Should calculate tangent on quadratic curve', () async {
final Path path = Path();
final double p0x = 150;
final double p0y = 20;
final double p1x = 320;
final double p1y = 25;
const double p0x = 150;
const double p0y = 20;
const double p1x = 320;
const double p1y = 25;
path.moveTo(150, 20);
path.quadraticBezierTo(p0x, p0y, p1x, p1y);
final PathMetric metric = path.computeMetrics().first;
@@ -114,16 +114,16 @@ Future<void> testMain() async {
final SurfacePath path = SurfacePath();
path.moveTo(50, 130);
path.lineTo(150, 20);
final double p1x = 240;
final double p1y = 120;
final double p2x = 320;
final double p2y = 25;
const double p1x = 240;
const double p1y = 120;
const double p2x = 320;
const double p2y = 25;
path.quadraticBezierTo(p1x, p1y, p2x, p2y);
rc.drawPath(path, paint);
final double t0 = 0.2;
final double t1 = 0.7;
const double t0 = 0.2;
const double t1 = 0.7;
final List<PathMetric> metrics = path.computeMetrics().toList();
double totalLength = 0;
@@ -135,7 +135,7 @@ Future<void> testMain() async {
double distance = totalLength * t0;
bool draw = true;
while (distance < measurePath.length * t1) {
final double length = kDashLength;
const double length = kDashLength;
if (draw) {
dashedPath.addPath(
measurePath.extractPath(distance, distance + length),
@@ -166,18 +166,18 @@ Future<void> testMain() async {
final Path path = Path();
path.moveTo(50, 130);
path.lineTo(150, 20);
final double p1x = 40;
final double p1y = 120;
final double p2x = 300;
final double p2y = 130;
final double p3x = 320;
final double p3y = 25;
const double p1x = 40;
const double p1y = 120;
const double p2x = 300;
const double p2y = 130;
const double p3x = 320;
const double p3y = 25;
path.cubicTo(p1x, p1y, p2x, p2y, p3x, p3y);
rc.drawPath(path, paint);
final double t0 = 0.2;
final double t1 = 0.7;
const double t0 = 0.2;
const double t1 = 0.7;
final List<PathMetric> metrics = path.computeMetrics().toList();
double totalLength = 0;
@@ -189,7 +189,7 @@ Future<void> testMain() async {
double distance = totalLength * t0;
bool draw = true;
while (distance < measurePath.length * t1) {
final double length = kDashLength;
const double length = kDashLength;
if (draw) {
dashedPath.addPath(
measurePath.extractPath(distance, distance + length),

View File

@@ -68,7 +68,7 @@ Future<void> testMain() async {
final RecordingCanvas rc =
RecordingCanvas(const Rect.fromLTRB(0, 0, screenWidth, screenHeight));
//Rect shaderRect = const Rect.fromLTRB(20, 20, 100, 100);
final Rect shaderRect = const Rect.fromLTRB(0, 0, 100, 100);
const Rect shaderRect = Rect.fromLTRB(0, 0, 100, 100);
final SurfacePaint paint = Paint() as SurfacePaint;
paint.shader =
ImageShader(testImage, tmx, tmy, Matrix4.identity().toFloat64()

View File

@@ -29,7 +29,7 @@ Future<void> testMain() async {
test('Should draw linear gradient using rectangle.', () async {
final RecordingCanvas rc =
RecordingCanvas(const Rect.fromLTRB(0, 0, 500, 500));
final Rect shaderRect = const Rect.fromLTRB(50, 50, 300, 300);
const Rect shaderRect = Rect.fromLTRB(50, 50, 300, 300);
final SurfacePaint paint = SurfacePaint()..shader = Gradient.linear(
Offset(shaderRect.left, shaderRect.top),
Offset(shaderRect.right, shaderRect.bottom),
@@ -78,7 +78,7 @@ Future<void> testMain() async {
test('Should draw linear gradient using rounded rect.', () async {
final RecordingCanvas rc =
RecordingCanvas(const Rect.fromLTRB(0, 0, 500, 500));
final Rect shaderRect = const Rect.fromLTRB(50, 50, 300, 300);
const Rect shaderRect = Rect.fromLTRB(50, 50, 300, 300);
final SurfacePaint paint = SurfacePaint()..shader = Gradient.linear(
Offset(shaderRect.left, shaderRect.top),
Offset(shaderRect.right, shaderRect.bottom),

View File

@@ -37,7 +37,7 @@ Future<void> testMain() async {
}
test('Should draw centered radial gradient.', () async {
final Rect shaderRect = const Rect.fromLTRB(50, 50, 300, 300);
const Rect shaderRect = Rect.fromLTRB(50, 50, 300, 300);
await _testGradient(
'radial_gradient_centered',
Gradient.radial(
@@ -53,7 +53,7 @@ Future<void> testMain() async {
});
test('Should draw right bottom centered radial gradient.', () async {
final Rect shaderRect = const Rect.fromLTRB(50, 50, 300, 300);
const Rect shaderRect = Rect.fromLTRB(50, 50, 300, 300);
await _testGradient(
'radial_gradient_right_bottom',
Gradient.radial(
@@ -70,7 +70,7 @@ Future<void> testMain() async {
});
test('Should draw with radial gradient with TileMode.clamp.', () async {
final Rect shaderRect = const Rect.fromLTRB(50, 50, 100, 100);
const Rect shaderRect = Rect.fromLTRB(50, 50, 100, 100);
await _testGradient(
'radial_gradient_tilemode_clamp',
Gradient.radial(
@@ -99,7 +99,7 @@ Future<void> testMain() async {
const List<double> colorStops = <double>[0.0, 0.05, 0.4, 0.6, 0.9, 1.0];
test('Should draw with radial gradient with TileMode.repeated.', () async {
final Rect shaderRect = const Rect.fromLTRB(50, 50, 100, 100);
const Rect shaderRect = Rect.fromLTRB(50, 50, 100, 100);
await _testGradient(
'radial_gradient_tilemode_repeated',
Gradient.radial(
@@ -114,7 +114,7 @@ Future<void> testMain() async {
});
test('Should draw with radial gradient with TileMode.mirrored.', () async {
final Rect shaderRect = const Rect.fromLTRB(50, 50, 100, 100);
const Rect shaderRect = Rect.fromLTRB(50, 50, 100, 100);
await _testGradient(
'radial_gradient_tilemode_mirror',
Gradient.radial(

View File

@@ -178,7 +178,7 @@ Picture _drawTestPictureWithText(
builder.addText(text);
final CanvasParagraph paragraph = builder.build();
final double maxWidth = 200 - 10;
const double maxWidth = 200 - 10;
paragraph.layout(ParagraphConstraints(width: maxWidth));
canvas.drawParagraph(paragraph, Offset(offsetX, offsetY));
return recorder.endRecording();

View File

@@ -25,14 +25,14 @@ final int kPhysicalTab = kWebToPhysicalKey['Tab']!;
final int kPhysicalCapsLock = kWebToPhysicalKey['CapsLock']!;
final int kPhysicalScrollLock = kWebToPhysicalKey['ScrollLock']!;
final int kLogicalKeyA = 0x00000000061;
final int kLogicalKeyU = 0x00000000075;
final int kLogicalDigit1 = 0x00000000031;
const int kLogicalKeyA = 0x00000000061;
const int kLogicalKeyU = 0x00000000075;
const int kLogicalDigit1 = 0x00000000031;
final int kLogicalNumpad1 = kWebLogicalLocationMap['1']![kLocationNumpad]!;
final int kLogicalShiftLeft = kWebLogicalLocationMap['Shift']![kLocationLeft]!;
final int kLogicalShiftRight = kWebLogicalLocationMap['Shift']![kLocationRight]!;
final int kLogicalMetaLeft = kWebLogicalLocationMap['Meta']![kLocationLeft]!;
final int kLogicalTab = 0x0000000009;
const int kLogicalTab = 0x0000000009;
final int kLogicalCapsLock = kWebToLogicalKey['CapsLock']!;
final int kLogicalScrollLock = kWebToLogicalKey['ScrollLock']!;

View File

@@ -25,7 +25,7 @@ String fontFamilyToAttribute(String fontFamily) {
final String defaultFontFamily = fontFamilyToAttribute('Ahem');
const String defaultColor = 'color: rgb(255, 0, 0);';
const String defaultFontSize = 'font-size: 14px;';
final String paragraphStyle =
const String paragraphStyle =
'position: absolute; white-space: pre;';
void main() {

View File

@@ -28,7 +28,7 @@ void testMain() {
group('regular special characters', () {
test('Register Asset with no special characters', () async {
final String _testFontFamily = "Ahem";
const String _testFontFamily = "Ahem";
final List<String> fontFamilyList = <String>[];
fontManager.registerAsset(
@@ -46,7 +46,7 @@ void testMain() {
skip: browserEngine == BrowserEngine.edge);
test('Register Asset with white space in the family name', () async {
final String _testFontFamily = "Ahem ahem ahem";
const String _testFontFamily = "Ahem ahem ahem";
final List<String> fontFamilyList = <String>[];
fontManager.registerAsset(
@@ -66,7 +66,7 @@ void testMain() {
browserEngine == BrowserEngine.webkit);
test('Register Asset with capital case letters', () async {
final String _testFontFamily = "AhEm";
const String _testFontFamily = "AhEm";
final List<String> fontFamilyList = <String>[];
fontManager.registerAsset(
@@ -86,7 +86,7 @@ void testMain() {
group('fonts with special characters', () {
test('Register Asset twice with special character slash', () async {
final String _testFontFamily = '/Ahem';
const String _testFontFamily = '/Ahem';
final List<String> fontFamilyList = <String>[];
fontManager.registerAsset(
@@ -112,7 +112,7 @@ void testMain() {
browserEngine == BrowserEngine.webkit);
test('Register Asset twice with exclamation mark', () async {
final String _testFontFamily = 'Ahem!!ahem';
const String _testFontFamily = 'Ahem!!ahem';
final List<String> fontFamilyList = <String>[];
fontManager.registerAsset(
@@ -138,7 +138,7 @@ void testMain() {
browserEngine == BrowserEngine.webkit);
test('Register Asset twice with comma', () async {
final String _testFontFamily = 'Ahem ,ahem';
const String _testFontFamily = 'Ahem ,ahem';
final List<String> fontFamilyList = <String>[];
fontManager.registerAsset(
@@ -165,7 +165,7 @@ void testMain() {
test('Register Asset twice with a digit at the start of a token',
() async {
final String testFontFamily = 'Ahem 1998';
const String testFontFamily = 'Ahem 1998';
final List<String> fontFamilyList = <String>[];
fontManager.registerAsset(

View File

@@ -1396,7 +1396,7 @@ void testMain() {
test('multiTextField Autofill sync updates back to Flutter', () {
// Create a configuration with an AutofillGroup of four text fields.
final String hintForFirstElement = 'familyName';
const String hintForFirstElement = 'familyName';
final Map<String, dynamic> flutterMultiAutofillElementConfig =
createFlutterConfig('text',
autofillHint: 'email',
@@ -2064,10 +2064,10 @@ void checkInputEditingState(
void clearBackUpDomElementIfExists() {
final List<Node> domElementsToRemove = <Node>[];
if (defaultTextEditingRoot.querySelectorAll('input').isNotEmpty) {
domElementsToRemove..addAll(defaultTextEditingRoot.querySelectorAll('input'));
domElementsToRemove.addAll(defaultTextEditingRoot.querySelectorAll('input'));
}
if (defaultTextEditingRoot.querySelectorAll('textarea').isNotEmpty) {
domElementsToRemove..addAll(defaultTextEditingRoot.querySelectorAll('textarea'));
domElementsToRemove.addAll(defaultTextEditingRoot.querySelectorAll('textarea'));
}
domElementsToRemove.forEach(_removeNode);
}

View File

@@ -70,7 +70,7 @@ void testMain() {
'flutter/navigation',
JSONMethodCodec().encodeMethodCall(MethodCall(
'routeUpdated',
<String, dynamic>{'routeName': '/bar'},
const <String, dynamic>{'routeName': '/bar'},
)),
(_) { callback.complete(); },
);
@@ -167,6 +167,7 @@ void testMain() {
await window.handleNavigationMessage(
JSONMethodCodec().encodeMethodCall(MethodCall(
'routeInformationUpdated',
// ignore: prefer_const_literals_to_create_immutables
<String, dynamic>{
'location': '/baz',
'state': null,
@@ -197,6 +198,7 @@ void testMain() {
'flutter/navigation',
JSONMethodCodec().encodeMethodCall(MethodCall(
'routeUpdated',
// ignore: prefer_const_literals_to_create_immutables
<String, dynamic>{'routeName': '/bar'},
)),
(_) { callback.complete(); },
@@ -211,6 +213,7 @@ void testMain() {
'flutter/navigation',
JSONMethodCodec().encodeMethodCall(MethodCall(
'routeInformationUpdated',
// ignore: prefer_const_literals_to_create_immutables
<String, dynamic>{
'location': '/baz',
'state': null,
@@ -226,6 +229,7 @@ void testMain() {
await window.handleNavigationMessage(
JSONMethodCodec().encodeMethodCall(MethodCall(
'routeUpdated',
// ignore: prefer_const_literals_to_create_immutables
<String, dynamic>{'routeName': '/foo'},
))
);
@@ -245,6 +249,7 @@ void testMain() {
'flutter/navigation',
JSONMethodCodec().encodeMethodCall(MethodCall(
'routeInformationUpdated',
// ignore: prefer_const_literals_to_create_immutables
<String, dynamic>{
'location': '/baz',
'state': '/state',
@@ -261,6 +266,7 @@ void testMain() {
'flutter/navigation',
JSONMethodCodec().encodeMethodCall(MethodCall(
'routeInformationUpdated',
// ignore: prefer_const_literals_to_create_immutables
<String, dynamic>{
'location': '/baz',
'state': '/state1',
@@ -278,6 +284,7 @@ void testMain() {
'flutter/navigation',
JSONMethodCodec().encodeMethodCall(MethodCall(
'routeInformationUpdated',
// ignore: prefer_const_literals_to_create_immutables
<String, dynamic>{
'location': '/foo',
'state': '/foostate1',
@@ -307,6 +314,7 @@ void testMain() {
'flutter/navigation',
JSONMethodCodec().encodeMethodCall(MethodCall(
'routeUpdated',
// ignore: prefer_const_literals_to_create_immutables
<String, dynamic>{'routeName': '/bar'},
)),
(_) { callback.complete(); },
@@ -332,6 +340,7 @@ void testMain() {
'flutter/navigation',
JSONMethodCodec().encodeMethodCall(MethodCall(
'routeInformationUpdated',
// ignore: prefer_const_literals_to_create_immutables
<String, dynamic>{
'location': '/baz',
'state': null,