未验证 提交 b0eb010e 编写于 作者: Y Yegor 提交者: GitHub

[web] last batch of test null safety (#26719)

上级 b807dfde
......@@ -23,7 +23,7 @@ class EnginePictureRecorder implements ui.PictureRecorder {
bool get isRecording => _isRecording;
@override
ui.Picture endRecording() {
EnginePicture endRecording() {
if (!_isRecording) {
// The mobile version returns an empty picture in this case. To match the
// behavior we produce a blank picture too.
......
......@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.6
import 'dart:html' as html;
import 'dart:typed_data';
......@@ -47,7 +46,7 @@ void testMain() {
browserSupportsFinalizationRegistry = false;
Future<void> expectFrameData(ui.FrameInfo frame, List<int> data) async {
final ByteData frameData = await frame.image.toByteData();
final ByteData frameData = (await frame.image.toByteData())!;
expect(frameData.buffer.asUint8List(), Uint8List.fromList(data));
}
......@@ -73,7 +72,7 @@ void testMain() {
test('CkImage toString', () {
final SkImage skImage =
canvasKit.MakeAnimatedImageFromEncoded(kTransparentImage)
canvasKit.MakeAnimatedImageFromEncoded(kTransparentImage)!
.makeImageAtCurrentFrame();
final CkImage image = CkImage(skImage);
expect(image.toString(), '[1×1]');
......@@ -83,7 +82,7 @@ void testMain() {
test('CkImage can be explicitly disposed of', () {
final SkImage skImage =
canvasKit.MakeAnimatedImageFromEncoded(kTransparentImage)
canvasKit.MakeAnimatedImageFromEncoded(kTransparentImage)!
.makeImageAtCurrentFrame();
final CkImage image = CkImage(skImage);
expect(image.debugDisposed, isFalse);
......@@ -99,7 +98,7 @@ void testMain() {
test('CkImage can be explicitly disposed of when cloned', () async {
final SkImage skImage =
canvasKit.MakeAnimatedImageFromEncoded(kTransparentImage)
canvasKit.MakeAnimatedImageFromEncoded(kTransparentImage)!
.makeImageAtCurrentFrame();
final CkImage image = CkImage(skImage);
final SkiaObjectBox<CkImage, SkImage> box = image.box;
......@@ -133,7 +132,7 @@ void testMain() {
test('CkImage toByteData', () async {
final SkImage skImage =
canvasKit.MakeAnimatedImageFromEncoded(kTransparentImage)
canvasKit.MakeAnimatedImageFromEncoded(kTransparentImage)!
.makeImageAtCurrentFrame();
final CkImage image = CkImage(skImage);
expect((await image.toByteData()).lengthInBytes, greaterThan(0));
......@@ -145,7 +144,7 @@ void testMain() {
test('CkImage can be resurrected', () {
browserSupportsFinalizationRegistry = false;
final SkImage skImage =
canvasKit.MakeAnimatedImageFromEncoded(kTransparentImage)
canvasKit.MakeAnimatedImageFromEncoded(kTransparentImage)!
.makeImageAtCurrentFrame();
final CkImage image = CkImage(skImage);
expect(image.box.rawSkiaObject, isNotNull);
......@@ -259,13 +258,13 @@ void testMain() {
class TestHttpRequest implements html.HttpRequest {
@override
String responseType;
String responseType = 'invalid';
@override
int timeout = 10;
int? timeout = 10;
@override
bool withCredentials = false;
bool? withCredentials = false;
@override
void abort() {
......@@ -273,7 +272,7 @@ class TestHttpRequest implements html.HttpRequest {
}
@override
void addEventListener(String type, listener, [bool useCapture]) {
void addEventListener(String type, listener, [bool? useCapture]) {
throw UnimplementedError();
}
......@@ -320,7 +319,7 @@ class TestHttpRequest implements html.HttpRequest {
Stream<html.ProgressEvent> get onTimeout => throw UnimplementedError();
@override
void open(String method, String url, {bool async, String user, String password}) {}
void open(String method, String url, {bool? async, String? user, String? password}) {}
@override
void overrideMimeType(String mime) {
......@@ -331,7 +330,7 @@ class TestHttpRequest implements html.HttpRequest {
int get readyState => throw UnimplementedError();
@override
void removeEventListener(String type, listener, [bool useCapture]) {
void removeEventListener(String type, listener, [bool? useCapture]) {
throw UnimplementedError();
}
......
......@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.6
import 'dart:typed_data';
import 'package:ui/ui.dart';
......@@ -23,21 +22,21 @@ void testMain() async {
});
test('Picture.toImage().toByteData()', () async {
final EnginePictureRecorder recorder = PictureRecorder();
final EnginePictureRecorder recorder = EnginePictureRecorder();
final RecordingCanvas canvas =
recorder.beginRecording(Rect.fromLTRB(0, 0, 2, 2));
canvas.drawColor(Color(0xFFCCDD00), BlendMode.srcOver);
final Picture testPicture = recorder.endRecording();
final Image testImage = await testPicture.toImage(2, 2);
final ByteData bytes =
await testImage.toByteData(format: ImageByteFormat.rawRgba);
(await testImage.toByteData(format: ImageByteFormat.rawRgba))!;
expect(
bytes.buffer.asUint32List(),
<int>[0xFF00DDCC, 0xFF00DDCC, 0xFF00DDCC, 0xFF00DDCC],
);
final ByteData pngBytes =
await testImage.toByteData(format: ImageByteFormat.png);
(await testImage.toByteData(format: ImageByteFormat.png))!;
// PNG-encoding is browser-specific, but the header is standard. We only
// test the header.
......
......@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.6
import 'package:test/bootstrap/browser.dart';
import 'package:test/test.dart';
import 'package:ui/ui.dart';
......@@ -15,8 +14,8 @@ void main() {
}
void testMain() {
RecordingCanvas underTest;
MockEngineCanvas mockCanvas;
late RecordingCanvas underTest;
late MockEngineCanvas mockCanvas;
final Rect screenRect = Rect.largest;
setUp(() {
......@@ -113,62 +112,62 @@ void testMain() {
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), Paint());
underTest.drawRect(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), Paint());
underTest.drawRect(Rect.fromLTWH(20.0, 0.0, 10.0, 10.0), SurfacePaint());
// Visible
underTest.drawRect(Rect.fromLTWH(20.0, 20.0, 10.0, 10.0), Paint());
underTest.drawRect(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), Paint());
underTest.drawRect(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), Paint());
underTest.drawRect(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), Paint());
underTest.drawRect(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), Paint());
underTest.drawRect(Rect.fromLTWH(20.0, 40.0, 10.0, 10.0), SurfacePaint());
underTest.endRecording();
expect(underTest.debugPaintCommands, hasLength(10));
final PaintDrawRect outsideLeft = underTest.debugPaintCommands[0];
final PaintDrawRect outsideLeft = underTest.debugPaintCommands[0] as PaintDrawRect;
expect(outsideLeft.isClippedOut, isFalse);
expect(outsideLeft.leftBound, 0);
expect(outsideLeft.topBound, 20);
expect(outsideLeft.rightBound, 10);
expect(outsideLeft.bottomBound, 30);
final PaintDrawRect outsideAbove = underTest.debugPaintCommands[1];
final PaintDrawRect outsideAbove = underTest.debugPaintCommands[1] as PaintDrawRect;
expect(outsideAbove.isClippedOut, isFalse);
final PaintDrawRect visible = underTest.debugPaintCommands[2];
final PaintDrawRect visible = underTest.debugPaintCommands[2] as PaintDrawRect;
expect(visible.isClippedOut, isFalse);
final PaintDrawRect zeroSize = underTest.debugPaintCommands[3];
final PaintDrawRect zeroSize = underTest.debugPaintCommands[3] as PaintDrawRect;
expect(zeroSize.isClippedOut, isTrue);
expect(underTest.debugPaintCommands[4], isA<PaintSave>());
final PaintClipRect clip = underTest.debugPaintCommands[5];
final PaintClipRect clip = underTest.debugPaintCommands[5] as PaintClipRect;
expect(clip.isClippedOut, isFalse);
final PaintDrawRect clippedOut = underTest.debugPaintCommands[6];
final PaintDrawRect clippedOut = underTest.debugPaintCommands[6] as PaintDrawRect;
expect(clippedOut.isClippedOut, isTrue);
expect(underTest.debugPaintCommands[7], isA<PaintRestore>());
final PaintDrawRect outsideRight = underTest.debugPaintCommands[8];
final PaintDrawRect outsideRight = underTest.debugPaintCommands[8] as PaintDrawRect;
expect(outsideRight.isClippedOut, isFalse);
final PaintDrawRect outsideBelow = underTest.debugPaintCommands[9];
final PaintDrawRect outsideBelow = underTest.debugPaintCommands[9] as PaintDrawRect;
expect(outsideBelow.isClippedOut, isFalse);
// Give it the entire screen so everything paints.
......
......@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.6
import 'dart:html' as html;
import 'package:ui/src/engine.dart';
......@@ -23,7 +22,7 @@ void testMain() {
test('debugAssertSurfaceState produces a human-readable message', () {
final SceneBuilder builder = SceneBuilder();
final PersistedOpacity opacityLayer = builder.pushOpacity(100);
final PersistedOpacity opacityLayer = builder.pushOpacity(100) as PersistedOpacity;
try {
debugAssertSurfaceState(opacityLayer, PersistedSurfaceState.active, PersistedSurfaceState.pendingRetention);
fail('Expected $PersistedSurfaceException');
......@@ -39,7 +38,7 @@ void testMain() {
test('is created', () {
final SceneBuilder builder = SceneBuilder();
final PersistedOpacity opacityLayer = builder.pushOpacity(100);
final PersistedOpacity opacityLayer = builder.pushOpacity(100) as PersistedOpacity;
builder.pop();
expect(opacityLayer, isNotNull);
......@@ -48,13 +47,13 @@ void testMain() {
builder.build();
expect(opacityLayer.rootElement.tagName.toLowerCase(), 'flt-opacity');
expect(opacityLayer.rootElement!.tagName.toLowerCase(), 'flt-opacity');
expect(opacityLayer.isActive, isTrue);
});
test('is released', () {
final SceneBuilder builder1 = SceneBuilder();
final PersistedOpacity opacityLayer = builder1.pushOpacity(100);
final PersistedOpacity opacityLayer = builder1.pushOpacity(100) as PersistedOpacity;
builder1.pop();
builder1.build();
expect(opacityLayer.isActive, isTrue);
......@@ -66,9 +65,9 @@ void testMain() {
test('discarding is recursive', () {
final SceneBuilder builder1 = SceneBuilder();
final PersistedOpacity opacityLayer = builder1.pushOpacity(100);
final PersistedOpacity opacityLayer = builder1.pushOpacity(100) as PersistedOpacity;
final PersistedTransform transformLayer =
builder1.pushTransform(Matrix4.identity().toFloat64());
builder1.pushTransform(Matrix4.identity().toFloat64()) as PersistedTransform;
builder1.pop();
builder1.pop();
builder1.build();
......@@ -84,15 +83,15 @@ void testMain() {
test('is updated', () {
final SceneBuilder builder1 = SceneBuilder();
final PersistedOpacity opacityLayer1 = builder1.pushOpacity(100);
final PersistedOpacity opacityLayer1 = builder1.pushOpacity(100) as PersistedOpacity;
builder1.pop();
builder1.build();
expect(opacityLayer1.isActive, isTrue);
final html.Element element = opacityLayer1.rootElement;
final html.Element element = opacityLayer1.rootElement!;
final SceneBuilder builder2 = SceneBuilder();
final PersistedOpacity opacityLayer2 =
builder2.pushOpacity(200, oldLayer: opacityLayer1);
builder2.pushOpacity(200, oldLayer: opacityLayer1) as PersistedOpacity;
expect(opacityLayer1.isPendingUpdate, isTrue);
expect(opacityLayer2.isCreated, isTrue);
expect(opacityLayer2.oldLayer, same(opacityLayer1));
......@@ -110,11 +109,11 @@ void testMain() {
test('ignores released surface when updated', () {
// Build a surface
final SceneBuilder builder1 = SceneBuilder();
final PersistedOpacity opacityLayer1 = builder1.pushOpacity(100);
final PersistedOpacity opacityLayer1 = builder1.pushOpacity(100) as PersistedOpacity;
builder1.pop();
builder1.build();
expect(opacityLayer1.isActive, isTrue);
final html.Element element = opacityLayer1.rootElement;
final html.Element element = opacityLayer1.rootElement!;
// Release it
SceneBuilder().build();
......@@ -124,7 +123,7 @@ void testMain() {
// Attempt to update it
final SceneBuilder builder2 = SceneBuilder();
final PersistedOpacity opacityLayer2 =
builder2.pushOpacity(200, oldLayer: opacityLayer1);
builder2.pushOpacity(200, oldLayer: opacityLayer1) as PersistedOpacity;
builder2.pop();
expect(opacityLayer1.isReleased, isTrue);
expect(opacityLayer2.isCreated, isTrue);
......@@ -160,10 +159,10 @@ void testMain() {
final SurfaceSceneBuilder builder1 = SurfaceSceneBuilder();
final PersistedTransform a1 =
builder1.pushTransform(
(Matrix4.identity()..scale(html.window.devicePixelRatio)).toFloat64());
final PersistedOpacity b1 = builder1.pushOpacity(100);
(Matrix4.identity()..scale(html.window.devicePixelRatio as double)).toFloat64()) as PersistedTransform;
final PersistedOpacity b1 = builder1.pushOpacity(100) as PersistedOpacity;
final PersistedTransform c1 =
builder1.pushTransform(Matrix4.identity().toFloat64());
builder1.pushTransform(Matrix4.identity().toFloat64()) as PersistedTransform;
builder1.debugAddSurface(logger);
builder1.pop();
builder1.pop();
......@@ -171,9 +170,9 @@ void testMain() {
builder1.build();
expect(logger.log, <String>['build', 'createElement', 'apply']);
final html.Element elementA = a1.rootElement;
final html.Element elementB = b1.rootElement;
final html.Element elementC = c1.rootElement;
final html.Element elementA = a1.rootElement!;
final html.Element elementB = b1.rootElement!;
final html.Element elementC = c1.rootElement!;
expect(elementC.parent, elementB);
expect(elementB.parent, elementA);
......@@ -181,10 +180,10 @@ void testMain() {
final SurfaceSceneBuilder builder2 = SurfaceSceneBuilder();
final PersistedTransform a2 =
builder2.pushTransform(
(Matrix4.identity()..scale(html.window.devicePixelRatio)).toFloat64(),
oldLayer: a1);
(Matrix4.identity()..scale(html.window.devicePixelRatio as double)).toFloat64(),
oldLayer: a1) as PersistedTransform;
final PersistedTransform c2 =
builder2.pushTransform(Matrix4.identity().toFloat64(), oldLayer: c1);
builder2.pushTransform(Matrix4.identity().toFloat64(), oldLayer: c1) as PersistedTransform;
builder2.addRetained(logger);
builder2.pop();
builder2.pop();
......@@ -210,11 +209,11 @@ void testMain() {
test('is retained', () {
final SceneBuilder builder1 = SceneBuilder();
final PersistedOpacity opacityLayer = builder1.pushOpacity(100);
final PersistedOpacity opacityLayer = builder1.pushOpacity(100) as PersistedOpacity;
builder1.pop();
builder1.build();
expect(opacityLayer.isActive, isTrue);
final html.Element element = opacityLayer.rootElement;
final html.Element element = opacityLayer.rootElement!;
final SceneBuilder builder2 = SceneBuilder();
......@@ -229,14 +228,14 @@ void testMain() {
test('revives released surface when retained', () {
final SurfaceSceneBuilder builder1 = SurfaceSceneBuilder();
final PersistedOpacity opacityLayer = builder1.pushOpacity(100);
final PersistedOpacity opacityLayer = builder1.pushOpacity(100) as PersistedOpacity;
final _LoggingTestSurface logger = _LoggingTestSurface();
builder1.debugAddSurface(logger);
builder1.pop();
builder1.build();
expect(opacityLayer.isActive, isTrue);
expect(logger.log, <String>['build', 'createElement', 'apply']);
final html.Element element = opacityLayer.rootElement;
final html.Element element = opacityLayer.rootElement!;
SceneBuilder().build();
expect(opacityLayer.isReleased, isTrue);
......@@ -255,16 +254,16 @@ void testMain() {
test('reviving is recursive', () {
final SceneBuilder builder1 = SceneBuilder();
final PersistedOpacity opacityLayer = builder1.pushOpacity(100);
final PersistedOpacity opacityLayer = builder1.pushOpacity(100) as PersistedOpacity;
final PersistedTransform transformLayer =
builder1.pushTransform(Matrix4.identity().toFloat64());
builder1.pushTransform(Matrix4.identity().toFloat64()) as PersistedTransform;
builder1.pop();
builder1.pop();
builder1.build();
expect(opacityLayer.isActive, isTrue);
expect(transformLayer.isActive, isTrue);
final html.Element opacityElement = opacityLayer.rootElement;
final html.Element transformElement = transformLayer.rootElement;
final html.Element opacityElement = opacityLayer.rootElement!;
final html.Element transformElement = transformLayer.rootElement!;
SceneBuilder().build();
......@@ -299,28 +298,28 @@ void testMain() {
// D
test('reparents DOM elements when retained', () {
final SceneBuilder builder1 = SceneBuilder();
final PersistedOpacity a1 = builder1.pushOpacity(10);
final PersistedOpacity b1 = builder1.pushOpacity(20);
final PersistedOpacity a1 = builder1.pushOpacity(10) as PersistedOpacity;
final PersistedOpacity b1 = builder1.pushOpacity(20) as PersistedOpacity;
builder1.pop();
final PersistedOpacity c1 = builder1.pushOpacity(30);
final PersistedOpacity d1 = builder1.pushOpacity(40);
final PersistedOpacity c1 = builder1.pushOpacity(30) as PersistedOpacity;
final PersistedOpacity d1 = builder1.pushOpacity(40) as PersistedOpacity;
builder1.pop();
builder1.pop();
builder1.pop();
builder1.build();
final html.Element elementA = a1.rootElement;
final html.Element elementB = b1.rootElement;
final html.Element elementC = c1.rootElement;
final html.Element elementD = d1.rootElement;
final html.Element elementA = a1.rootElement!;
final html.Element elementB = b1.rootElement!;
final html.Element elementC = c1.rootElement!;
final html.Element elementD = d1.rootElement!;
expect(elementB.parent, elementA);
expect(elementC.parent, elementA);
expect(elementD.parent, elementC);
final SceneBuilder builder2 = SceneBuilder();
final PersistedOpacity a2 = builder2.pushOpacity(10, oldLayer: a1);
final PersistedOpacity b2 = builder2.pushOpacity(20, oldLayer: b1);
final PersistedOpacity a2 = builder2.pushOpacity(10, oldLayer: a1) as PersistedOpacity;
final PersistedOpacity b2 = builder2.pushOpacity(20, oldLayer: b1) as PersistedOpacity;
builder2.addRetained(c1);
builder2.pop();
builder2.pop();
......@@ -333,9 +332,9 @@ void testMain() {
expect(
<html.Element>[
elementD.parent,
elementC.parent,
elementB.parent,
elementD.parent!,
elementC.parent!,
elementB.parent!,
],
<html.Element>[elementC, elementB, elementA],
);
......@@ -343,14 +342,14 @@ void testMain() {
test('is updated by matching', () {
final SceneBuilder builder1 = SceneBuilder();
final PersistedOpacity opacityLayer1 = builder1.pushOpacity(100);
final PersistedOpacity opacityLayer1 = builder1.pushOpacity(100) as PersistedOpacity;
builder1.pop();
builder1.build();
expect(opacityLayer1.isActive, isTrue);
final html.Element element = opacityLayer1.rootElement;
final html.Element element = opacityLayer1.rootElement!;
final SceneBuilder builder2 = SceneBuilder();
final PersistedOpacity opacityLayer2 = builder2.pushOpacity(200);
final PersistedOpacity opacityLayer2 = builder2.pushOpacity(200) as PersistedOpacity;
expect(opacityLayer1.isActive, isTrue);
expect(opacityLayer2.isCreated, isTrue);
builder2.pop();
......@@ -374,7 +373,7 @@ void testMain() {
final Path path = Path();
path.addPolygon([Offset(50, 0), Offset(100, 80), Offset(20, 40)], true);
PersistedPhysicalShape shape = builder1.pushPhysicalShape(path: path,
color: Color(0xFF00FF00), elevation: 1);
color: Color(0xFF00FF00), elevation: 1) as PersistedPhysicalShape;
builder1.build();
expect(() => shape.apply(), returnsNormally);
});
......@@ -430,7 +429,7 @@ class _LoggingTestSurface extends PersistedContainerSurface {
}
@override
double matchForUpdate(PersistedSurface existingSurface) {
double matchForUpdate(PersistedSurface? existingSurface) {
return 1.0;
}
}
......@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.6
import 'dart:async';
import 'dart:js_util' as js_util;
import 'dart:html' as html;
......@@ -98,7 +97,7 @@ void testMain() {
expect(window.onBeginFrame, same(callback));
});
EnginePlatformDispatcher.instance.invokeOnBeginFrame(null);
EnginePlatformDispatcher.instance.invokeOnBeginFrame(Duration.zero);
});
test('onReportTimings preserves the zone', () {
......@@ -114,7 +113,7 @@ void testMain() {
expect(window.onReportTimings, same(callback));
});
EnginePlatformDispatcher.instance.invokeOnReportTimings(null);
EnginePlatformDispatcher.instance.invokeOnReportTimings(<ui.FrameTiming>[]);
});
test('onDrawFrame preserves the zone', () {
......@@ -146,7 +145,7 @@ void testMain() {
expect(window.onPointerDataPacket, same(callback));
});
EnginePlatformDispatcher.instance.invokeOnPointerDataPacket(null);
EnginePlatformDispatcher.instance.invokeOnPointerDataPacket(ui.PointerDataPacket());
});
test('invokeOnKeyData returns normally when onKeyData is null', () {
......@@ -224,7 +223,7 @@ void testMain() {
expect(window.onSemanticsAction, same(callback));
});
EnginePlatformDispatcher.instance.invokeOnSemanticsAction(null, null, null);
EnginePlatformDispatcher.instance.invokeOnSemanticsAction(0, ui.SemanticsAction.tap, null);
});
test('onAccessibilityFeaturesChanged preserves the zone', () {
......@@ -256,7 +255,9 @@ void testMain() {
expect(window.onPlatformMessage, same(callback));
});
EnginePlatformDispatcher.instance.invokeOnPlatformMessage(null, null, null);
EnginePlatformDispatcher.instance.invokeOnPlatformMessage('foo', null, (ByteData? data) {
// Not testing anything here.
});
});
test('sendPlatformMessage preserves the zone', () async {
......@@ -299,13 +300,13 @@ void testMain() {
/// Regression test for https://github.com/flutter/flutter/issues/66128.
test('setPreferredOrientation responds even if browser doesn\'t support api', () async {
final html.Screen screen = html.window.screen;
final html.Screen screen = html.window.screen!;
js_util.setProperty(screen, 'orientation', null);
final Completer<bool> completer = Completer<bool>();
final ByteData inputData = JSONMethodCodec().encodeMethodCall(MethodCall(
'SystemChrome.setPreferredOrientations',
<dynamic>[]));
<dynamic>[]))!;
window.sendPlatformMessage(
'flutter/platform',
......
......@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.6
import 'dart:async';
import 'dart:html' as html;
import 'dart:math' as math;
......@@ -33,7 +32,7 @@ void testMain() async {
CanvasParagraph paragraph;
// Single-line multi-span.
paragraph = rich(ParagraphStyle(fontFamily: 'Roboto'), (builder) {
paragraph = rich(EngineParagraphStyle(fontFamily: 'Roboto'), (builder) {
builder.pushStyle(EngineTextStyle.only(color: blue));
builder.addText('Lorem ');
builder.pushStyle(EngineTextStyle.only(
......@@ -49,7 +48,7 @@ void testMain() async {
offset = offset.translate(0, paragraph.height + 10);
// Multi-line single-span.
paragraph = rich(ParagraphStyle(fontFamily: 'Roboto'), (builder) {
paragraph = rich(EngineParagraphStyle(fontFamily: 'Roboto'), (builder) {
builder.addText('Lorem ipsum dolor sit');
})
..layout(constrain(90.0));
......@@ -57,7 +56,7 @@ void testMain() async {
offset = offset.translate(0, paragraph.height + 10);
// Multi-line multi-span.
paragraph = rich(ParagraphStyle(fontFamily: 'Roboto'), (builder) {
paragraph = rich(EngineParagraphStyle(fontFamily: 'Roboto'), (builder) {
builder.pushStyle(EngineTextStyle.only(color: blue));
builder.addText('Lorem ipsum ');
builder.pushStyle(EngineTextStyle.only(background: Paint()..color = red));
......@@ -91,21 +90,21 @@ void testMain() async {
}
paragraph = rich(
ParagraphStyle(fontFamily: 'Roboto', textAlign: TextAlign.left),
EngineParagraphStyle(fontFamily: 'Roboto', textAlign: TextAlign.left),
build,
)..layout(constrain(100.0));
canvas.drawParagraph(paragraph, offset);
offset = offset.translate(0, paragraph.height + 10);
paragraph = rich(
ParagraphStyle(fontFamily: 'Roboto', textAlign: TextAlign.center),
EngineParagraphStyle(fontFamily: 'Roboto', textAlign: TextAlign.center),
build,
)..layout(constrain(100.0));
canvas.drawParagraph(paragraph, offset);
offset = offset.translate(0, paragraph.height + 10);
paragraph = rich(
ParagraphStyle(fontFamily: 'Roboto', textAlign: TextAlign.right),
EngineParagraphStyle(fontFamily: 'Roboto', textAlign: TextAlign.right),
build,
)..layout(constrain(100.0));
canvas.drawParagraph(paragraph, offset);
......@@ -132,21 +131,21 @@ void testMain() async {
}
paragraph = rich(
ParagraphStyle(fontFamily: 'Roboto', textAlign: TextAlign.left),
EngineParagraphStyle(fontFamily: 'Roboto', textAlign: TextAlign.left),
build,
)..layout(constrain(100.0));
canvas.drawParagraph(paragraph, offset);
offset = offset.translate(0, paragraph.height + 10);
paragraph = rich(
ParagraphStyle(fontFamily: 'Roboto', textAlign: TextAlign.center),
EngineParagraphStyle(fontFamily: 'Roboto', textAlign: TextAlign.center),
build,
)..layout(constrain(100.0));
canvas.drawParagraph(paragraph, offset);
offset = offset.translate(0, paragraph.height + 10);
paragraph = rich(
ParagraphStyle(fontFamily: 'Roboto', textAlign: TextAlign.right),
EngineParagraphStyle(fontFamily: 'Roboto', textAlign: TextAlign.right),
build,
)..layout(constrain(100.0));
canvas.drawParagraph(paragraph, offset);
......@@ -169,7 +168,7 @@ void testMain() async {
void drawParagraphAt(Offset offset, TextAlign align) {
paragraph = rich(
ParagraphStyle(fontFamily: 'Roboto', fontSize: 20.0, textAlign: align),
EngineParagraphStyle(fontFamily: 'Roboto', fontSize: 20.0, textAlign: align),
build,
)..layout(constrain(150.0));
canvas.save();
......@@ -200,7 +199,7 @@ void testMain() async {
void testGiantParagraphStyles(EngineCanvas canvas) {
final CanvasParagraph paragraph = rich(
ParagraphStyle(fontFamily: 'Roboto', fontSize: 80.0),
EngineParagraphStyle(fontFamily: 'Roboto', fontSize: 80.0),
(CanvasParagraphBuilder builder) {
builder.pushStyle(EngineTextStyle.only(color: yellow, fontSize: 24.0));
builder.addText('Lorem ');
......@@ -231,14 +230,14 @@ void testMain() async {
const Rect bounds = Rect.fromLTWH(0, 0, 600, 200);
// Store the old font size value on the body, and set a gaint font size.
final String oldBodyFontSize = html.document.body.style.fontSize;
html.document.body.style.fontSize = '100px';
final String oldBodyFontSize = html.document.body!.style.fontSize;
html.document.body!.style.fontSize = '100px';
final canvas = DomCanvas(domRenderer.createElement('flt-picture'));
Offset offset = Offset(10.0, 10.0);
final CanvasParagraph paragraph = rich(
ParagraphStyle(fontFamily: 'Roboto'),
EngineParagraphStyle(fontFamily: 'Roboto'),
(CanvasParagraphBuilder builder) {
builder.pushStyle(EngineTextStyle.only(color: yellow, fontSize: 24.0));
builder.addText('Lorem ');
......@@ -260,7 +259,7 @@ void testMain() async {
final double placeholderWidth = paragraph.height * 2;
final CanvasParagraph paragraph2 = rich(
ParagraphStyle(),
EngineParagraphStyle(),
(CanvasParagraphBuilder builder) {
builder.addPlaceholder(placeholderWidth, placeholderHeight, PlaceholderAlignment.baseline, baseline: TextBaseline.alphabetic);
},
......@@ -281,14 +280,14 @@ void testMain() async {
await takeScreenshot(canvas, bounds, 'canvas_paragraph_giant_body_font_size_dom');
// Restore the old font size value.
html.document.body.style.fontSize = oldBodyFontSize;
html.document.body!.style.fontSize = oldBodyFontSize;
});
test('paints spans with varying heights/baselines', () {
final canvas = BitmapCanvas(bounds, RenderStrategy());
final CanvasParagraph paragraph = rich(
ParagraphStyle(fontFamily: 'Roboto'),
EngineParagraphStyle(fontFamily: 'Roboto'),
(builder) {
builder.pushStyle(EngineTextStyle.only(fontSize: 20.0));
builder.addText('Lorem ');
......@@ -323,7 +322,7 @@ void testMain() async {
final canvas = BitmapCanvas(bounds, RenderStrategy());
final CanvasParagraph paragraph = rich(
ParagraphStyle(fontFamily: 'Roboto'),
EngineParagraphStyle(fontFamily: 'Roboto'),
(builder) {
builder.pushStyle(EngineTextStyle.only(color: blue));
builder.addText('Lorem ');
......@@ -349,7 +348,7 @@ void testMain() async {
];
final CanvasParagraph paragraph = rich(
ParagraphStyle(fontFamily: 'Roboto'),
EngineParagraphStyle(fontFamily: 'Roboto'),
(builder) {
for (TextDecorationStyle decorationStyle in decorationStyles) {
builder.pushStyle(EngineTextStyle.only(
......@@ -382,7 +381,7 @@ void testMain() async {
final FontFeature disableLigatures = FontFeature('liga', 0);
final CanvasParagraph paragraph = rich(
ParagraphStyle(fontFamily: 'Roboto'),
EngineParagraphStyle(fontFamily: 'Roboto'),
(CanvasParagraphBuilder builder) {
// Small Caps
builder.pushStyle(EngineTextStyle.only(
......
......@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.6
import 'dart:html' as html;
import 'dart:math' as math;
import 'dart:typed_data';
......@@ -39,7 +38,7 @@ void testMain() async {
final html.Element sceneElement = html.Element.tag('flt-scene');
try {
sceneElement.append(engineCanvas.rootElement);
html.document.body.append(sceneElement);
html.document.body!.append(sceneElement);
await matchGoldenFile('$fileName.png',
region: region, maxDiffRatePercent: maxDiffRatePercent, write: write);
} finally {
......@@ -60,7 +59,7 @@ void testMain() async {
RecordingCanvas(const Rect.fromLTRB(0, 0, 400, 300));
canvas.save();
final Paint borderPaint = Paint()
final SurfacePaint borderPaint = SurfacePaint()
..style = PaintingStyle.stroke
..strokeWidth = 1
..color = Color(0xFF000000);
......@@ -74,12 +73,12 @@ void testMain() async {
Color(0xFF656D78),];
List<double> stops = <double>[0.0, 0.05, 0.4, 0.6, 0.9, 1.0];
EngineGradient sweepGradient = GradientSweep(Offset(0.5, 0.5),
GradientSweep sweepGradient = GradientSweep(Offset(0.5, 0.5),
colors, stops, TileMode.clamp,
0, 360.0 / 180.0 * math.pi,
Matrix4.rotationZ(math.pi / 6.0).storage);
EngineGradient sweepGradientRotated = GradientSweep(Offset(0.5, 0.5),
GradientSweep sweepGradientRotated = GradientSweep(Offset(0.5, 0.5),
colors, stops, TileMode.clamp,
0, 360.0 / 180.0 * math.pi,
Matrix4.rotationZ(math.pi / 6.0).storage);
......@@ -89,13 +88,13 @@ void testMain() async {
// Gradient with default center.
Rect rectBounds = Rect.fromLTWH(10, 20, kBoxWidth, kBoxHeight);
canvas.drawRect(rectBounds,
Paint()..shader = engineGradientToShader(sweepGradient, rectBounds));
SurfacePaint()..shader = engineGradientToShader(sweepGradient, rectBounds));
canvas.drawRect(rectBounds, borderPaint);
// Gradient with shifted center and rotation.
rectBounds = rectBounds.translate(kBoxWidth + 10, 0);
canvas.drawRect(rectBounds,
Paint()..shader = engineGradientToShader(sweepGradientRotated, Rect.fromLTWH(rectBounds.center.dx, rectBounds.top, rectBounds.width / 2, rectBounds.height)));
SurfacePaint()..shader = engineGradientToShader(sweepGradientRotated, Rect.fromLTWH(rectBounds.center.dx, rectBounds.top, rectBounds.width / 2, rectBounds.height)));
canvas.drawRect(rectBounds, borderPaint);
// Gradient with start/endangle.
......@@ -106,7 +105,7 @@ void testMain() async {
rectBounds = rectBounds.translate(kBoxWidth + 10, 0);
canvas.drawRect(rectBounds,
new Paint()..shader = engineGradientToShader(sweepGradient, rectBounds));
SurfacePaint()..shader = engineGradientToShader(sweepGradient, rectBounds));
canvas.drawRect(rectBounds, borderPaint);
// Tile mode repeat
......@@ -117,7 +116,7 @@ void testMain() async {
Matrix4.rotationZ(math.pi / 6.0).storage);
canvas.drawRect(rectBounds,
new Paint()..shader = engineGradientToShader(sweepGradient, rectBounds));
SurfacePaint()..shader = engineGradientToShader(sweepGradient, rectBounds));
canvas.drawRect(rectBounds, borderPaint);
// Tile mode mirror
......@@ -127,7 +126,7 @@ void testMain() async {
math.pi / 6, 3 * math.pi / 4,
Matrix4.rotationZ(math.pi / 6.0).storage);
canvas.drawRect(rectBounds,
new Paint()..shader = engineGradientToShader(sweepGradient, rectBounds));
SurfacePaint()..shader = engineGradientToShader(sweepGradient, rectBounds));
canvas.drawRect(rectBounds, borderPaint);
canvas.restore();
......@@ -139,7 +138,7 @@ void testMain() async {
RecordingCanvas(const Rect.fromLTRB(0, 0, 400, 300));
canvas.save();
final Paint borderPaint = Paint()
final SurfacePaint borderPaint = SurfacePaint()
..style = PaintingStyle.stroke
..strokeWidth = 1
..color = Color(0xFF000000);
......@@ -153,12 +152,12 @@ void testMain() async {
Color(0xFF656D78),];
List<double> stops = <double>[0.0, 0.05, 0.4, 0.6, 0.9, 1.0];
EngineGradient sweepGradient = GradientSweep(Offset(0.5, 0.5),
GradientSweep sweepGradient = GradientSweep(Offset(0.5, 0.5),
colors, stops, TileMode.clamp,
0, 360.0 / 180.0 * math.pi,
Matrix4.rotationZ(math.pi / 6.0).storage);
EngineGradient sweepGradientRotated = GradientSweep(Offset(0.5, 0.5),
GradientSweep sweepGradientRotated = GradientSweep(Offset(0.5, 0.5),
colors, stops, TileMode.clamp,
0, 360.0 / 180.0 * math.pi,
Matrix4.rotationZ(math.pi / 6.0).storage);
......@@ -168,13 +167,13 @@ void testMain() async {
// Gradient with default center.
Rect rectBounds = Rect.fromLTWH(10, 20, kBoxWidth, kBoxHeight);
canvas.drawOval(rectBounds,
Paint()..shader = engineGradientToShader(sweepGradient, rectBounds));
SurfacePaint()..shader = engineGradientToShader(sweepGradient, rectBounds));
canvas.drawRect(rectBounds, borderPaint);
// Gradient with shifted center and rotation.
rectBounds = rectBounds.translate(kBoxWidth + 10, 0);
canvas.drawOval(rectBounds,
Paint()..shader = engineGradientToShader(sweepGradientRotated, Rect.fromLTWH(rectBounds.center.dx, rectBounds.top, rectBounds.width / 2, rectBounds.height)));
SurfacePaint()..shader = engineGradientToShader(sweepGradientRotated, Rect.fromLTWH(rectBounds.center.dx, rectBounds.top, rectBounds.width / 2, rectBounds.height)));
canvas.drawRect(rectBounds, borderPaint);
// Gradient with start/endangle.
......@@ -185,7 +184,7 @@ void testMain() async {
rectBounds = rectBounds.translate(kBoxWidth + 10, 0);
canvas.drawOval(rectBounds,
new Paint()..shader = engineGradientToShader(sweepGradient, rectBounds));
SurfacePaint()..shader = engineGradientToShader(sweepGradient, rectBounds));
canvas.drawRect(rectBounds, borderPaint);
// Tile mode repeat
......@@ -196,7 +195,7 @@ void testMain() async {
Matrix4.rotationZ(math.pi / 6.0).storage);
canvas.drawOval(rectBounds,
new Paint()..shader = engineGradientToShader(sweepGradient, rectBounds));
SurfacePaint()..shader = engineGradientToShader(sweepGradient, rectBounds));
canvas.drawRect(rectBounds, borderPaint);
// Tile mode mirror
......@@ -206,7 +205,7 @@ void testMain() async {
math.pi / 6, 3 * math.pi / 4,
Matrix4.rotationZ(math.pi / 6.0).storage);
canvas.drawOval(rectBounds,
new Paint()..shader = engineGradientToShader(sweepGradient, rectBounds));
SurfacePaint()..shader = engineGradientToShader(sweepGradient, rectBounds));
canvas.drawRect(rectBounds, borderPaint);
canvas.restore();
......@@ -218,7 +217,7 @@ void testMain() async {
RecordingCanvas(const Rect.fromLTRB(0, 0, 400, 300));
canvas.save();
final Paint borderPaint = Paint()
final SurfacePaint borderPaint = SurfacePaint()
..style = PaintingStyle.stroke
..strokeWidth = 1
..color = Color(0xFF000000);
......@@ -232,12 +231,12 @@ void testMain() async {
Color(0xFF656D78),];
List<double> stops = <double>[0.0, 0.05, 0.4, 0.6, 0.9, 1.0];
EngineGradient sweepGradient = GradientSweep(Offset(0.5, 0.5),
GradientSweep sweepGradient = GradientSweep(Offset(0.5, 0.5),
colors, stops, TileMode.clamp,
0, 360.0 / 180.0 * math.pi,
Matrix4.rotationZ(math.pi / 6.0).storage);
EngineGradient sweepGradientRotated = GradientSweep(Offset(0.5, 0.5),
GradientSweep sweepGradientRotated = GradientSweep(Offset(0.5, 0.5),
colors, stops, TileMode.clamp,
0, 360.0 / 180.0 * math.pi,
Matrix4.rotationZ(math.pi / 6.0).storage);
......@@ -248,14 +247,14 @@ void testMain() async {
Rect rectBounds = Rect.fromLTWH(10, 20, kBoxWidth, kBoxHeight);
Path path = samplePathFromRect(rectBounds);
canvas.drawPath(path,
Paint()..shader = engineGradientToShader(sweepGradient, rectBounds));
SurfacePaint()..shader = engineGradientToShader(sweepGradient, rectBounds));
canvas.drawRect(rectBounds, borderPaint);
// Gradient with shifted center and rotation.
rectBounds = rectBounds.translate(kBoxWidth + 10, 0);
path = samplePathFromRect(rectBounds);
canvas.drawPath(path,
Paint()..shader = engineGradientToShader(sweepGradientRotated, Rect.fromLTWH(rectBounds.center.dx, rectBounds.top, rectBounds.width / 2, rectBounds.height)));
SurfacePaint()..shader = engineGradientToShader(sweepGradientRotated, Rect.fromLTWH(rectBounds.center.dx, rectBounds.top, rectBounds.width / 2, rectBounds.height)));
canvas.drawRect(rectBounds, borderPaint);
// Gradient with start/endangle.
......@@ -267,7 +266,7 @@ void testMain() async {
rectBounds = rectBounds.translate(kBoxWidth + 10, 0);
path = samplePathFromRect(rectBounds);
canvas.drawPath(path,
new Paint()..shader = engineGradientToShader(sweepGradient, rectBounds));
SurfacePaint()..shader = engineGradientToShader(sweepGradient, rectBounds));
canvas.drawRect(rectBounds, borderPaint);
// Tile mode repeat
......@@ -279,7 +278,7 @@ void testMain() async {
path = samplePathFromRect(rectBounds);
canvas.drawPath(path,
new Paint()..shader = engineGradientToShader(sweepGradient, rectBounds));
SurfacePaint()..shader = engineGradientToShader(sweepGradient, rectBounds));
canvas.drawRect(rectBounds, borderPaint);
// Tile mode mirror
......@@ -290,7 +289,7 @@ void testMain() async {
Matrix4.rotationZ(math.pi / 6.0).storage);
path = samplePathFromRect(rectBounds);
canvas.drawPath(path,
new Paint()..shader = engineGradientToShader(sweepGradient, rectBounds));
SurfacePaint()..shader = engineGradientToShader(sweepGradient, rectBounds));
canvas.drawRect(rectBounds, borderPaint);
canvas.restore();
......@@ -303,7 +302,7 @@ void testMain() async {
RecordingCanvas(const Rect.fromLTRB(0, 0, 400, 300));
canvas.save();
final Paint borderPaint = Paint()
final SurfacePaint borderPaint = SurfacePaint()
..style = PaintingStyle.stroke
..strokeWidth = 1
..color = Color(0xFF000000);
......@@ -317,7 +316,7 @@ void testMain() async {
Color(0xFF656D78),];
List<double> stops = <double>[0.0, 0.05, 0.4, 0.6, 0.9, 1.0];
EngineGradient linearGradient = GradientLinear(Offset(50, 50),
GradientLinear linearGradient = GradientLinear(Offset(50, 50),
Offset(200,130),
colors, stops, TileMode.clamp,
Matrix4.identity().storage);
......@@ -327,7 +326,7 @@ void testMain() async {
// Gradient with default center.
Rect rectBounds = Rect.fromLTWH(10, 20, kBoxWidth, kBoxHeight);
canvas.drawRect(rectBounds,
Paint()..shader = engineLinearGradientToShader(linearGradient, rectBounds));
SurfacePaint()..shader = engineLinearGradientToShader(linearGradient, rectBounds));
canvas.drawRect(rectBounds, borderPaint);
// Tile mode repeat
......@@ -338,7 +337,7 @@ void testMain() async {
Matrix4.identity().storage);
canvas.drawRect(rectBounds,
new Paint()..shader = engineLinearGradientToShader(linearGradient, rectBounds));
SurfacePaint()..shader = engineLinearGradientToShader(linearGradient, rectBounds));
canvas.drawRect(rectBounds, borderPaint);
canvas.restore();
......@@ -351,7 +350,7 @@ void testMain() async {
RecordingCanvas(const Rect.fromLTRB(0, 0, 400, 300));
canvas.save();
final Paint borderPaint = Paint()
final SurfacePaint borderPaint = SurfacePaint()
..style = PaintingStyle.stroke
..strokeWidth = 1
..color = Color(0xFF000000);
......@@ -361,7 +360,7 @@ void testMain() async {
Color(0xFFFF3C38)];
List<double> stops = <double>[0.0, 10.0];
EngineGradient linearGradient = GradientLinear(Offset(50, 50),
GradientLinear linearGradient = GradientLinear(Offset(50, 50),
Offset(200,130),
colors, stops, TileMode.clamp,
Matrix4.identity().storage);
......@@ -371,7 +370,7 @@ void testMain() async {
// Gradient with default center.
Rect rectBounds = Rect.fromLTWH(10, 20, kBoxWidth, kBoxHeight);
canvas.drawRect(rectBounds,
Paint()..shader = engineLinearGradientToShader(linearGradient, rectBounds));
SurfacePaint()..shader = engineLinearGradientToShader(linearGradient, rectBounds));
canvas.drawRect(rectBounds, borderPaint);
canvas.restore();
......@@ -386,7 +385,7 @@ void testMain() async {
RecordingCanvas(const Rect.fromLTRB(0, 0, 400, 300));
canvas.save();
final Paint borderPaint = Paint()
final SurfacePaint borderPaint = SurfacePaint()
..style = PaintingStyle.stroke
..strokeWidth = 1
..color = Color(0xFF000000);
......@@ -400,7 +399,7 @@ void testMain() async {
Color(0xFF656D78),];
List<double> stops = <double>[0.0, 0.05, 0.4, 0.6, 0.9, 1.0];
EngineGradient linearGradient = GradientLinear(Offset(50, 50),
GradientLinear linearGradient = GradientLinear(Offset(50, 50),
Offset(200,130),
colors, stops, TileMode.clamp,
Matrix4.identity().storage);
......@@ -410,7 +409,7 @@ void testMain() async {
// Gradient with default center.
Rect rectBounds = Rect.fromLTWH(10, 20, kBoxWidth, kBoxHeight);
canvas.drawRect(rectBounds,
Paint()..shader = engineLinearGradientToShader(linearGradient, rectBounds));
SurfacePaint()..shader = engineLinearGradientToShader(linearGradient, rectBounds));
canvas.drawRect(rectBounds, borderPaint);
// Tile mode repeat
......@@ -421,7 +420,7 @@ void testMain() async {
Matrix4.identity().storage);
canvas.drawRect(rectBounds,
new Paint()..shader = engineLinearGradientToShader(linearGradient, rectBounds));
SurfacePaint()..shader = engineLinearGradientToShader(linearGradient, rectBounds));
canvas.drawRect(rectBounds, borderPaint);
canvas.restore();
......@@ -437,7 +436,7 @@ Shader engineGradientToShader(GradientSweep gradient, Rect rect) {
gradient.startAngle,
gradient.endAngle,
gradient.matrix4 == null ? null :
Float64List.fromList(gradient.matrix4),
Float64List.fromList(gradient.matrix4!),
);
}
......@@ -445,7 +444,7 @@ Shader engineLinearGradientToShader(GradientLinear gradient, Rect rect) {
return Gradient.linear(gradient.from, gradient.to,
gradient.colors, gradient.colorStops, gradient.tileMode,
gradient.matrix4 == null ? null : Float64List.fromList(
gradient.matrix4.matrix),
gradient.matrix4!.matrix),
);
}
......
......@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.6
import 'dart:math' as math;
import 'package:test/bootstrap/browser.dart';
......@@ -107,12 +106,12 @@ const Rect testBounds = Rect.fromLTRB(50, 50, 230, 220);
void drawBackground(RecordingCanvas canvas) {
canvas.drawRect(
testBounds,
Paint()
SurfacePaint()
..style = PaintingStyle.fill
..color = const Color(0xFF9E9E9E));
canvas.drawRect(
testBounds.inflate(-40),
Paint()
SurfacePaint()
..strokeWidth = 1
..style = PaintingStyle.stroke
..color = const Color(0xFF009688));
......@@ -158,7 +157,7 @@ void paintTextWithClipRoundRect(RecordingCanvas canvas) {
drawBackground(canvas);
canvas.drawRRect(
roundRect,
Paint()
SurfacePaint()
..color = deepOrange
..style = PaintingStyle.fill);
canvas.clipRRect(roundRect);
......@@ -180,7 +179,7 @@ void paintTextWithClipPath(RecordingCanvas canvas) {
path.close();
canvas.drawPath(
path,
Paint()
SurfacePaint()
..color = deepOrange
..style = PaintingStyle.fill);
canvas.clipPath(path);
......@@ -196,7 +195,7 @@ void paintTextWithClipStack(RecordingCanvas canvas) {
canvas.clipRect(inflatedRect, ClipOp.intersect);
canvas.drawRect(
inflatedRect,
Paint()
SurfacePaint()
..color = deepOrange
..style = PaintingStyle.fill);
drawQuickBrownFox(canvas);
......
......@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.6
import 'dart:html' as html;
import 'package:test/bootstrap/browser.dart';
......@@ -28,8 +27,8 @@ void testMain() async {
Rect.fromLTWH(8, 8, 600, 400); // Compensate for old scuba tester padding
Future<void> testPath(Path path, String scubaFileName,
{Paint paint,
double maxDiffRatePercent = null,
{SurfacePaint? paint,
double? maxDiffRatePercent,
bool write = false,
PaintMode mode = PaintMode.kStrokeAndFill}) async {
const Rect canvasBounds = Rect.fromLTWH(0, 0, 600, 400);
......@@ -40,31 +39,31 @@ void testMain() async {
bool enableFill =
mode == PaintMode.kStrokeAndFill || mode == PaintMode.kFill;
if (enableFill) {
paint ??= Paint()
paint ??= SurfacePaint()
..color = const Color(0x807F7F7F)
..style = PaintingStyle.fill;
canvas.drawPath(path, paint);
}
if (mode == PaintMode.kStrokeAndFill || mode == PaintMode.kStroke) {
paint = Paint()
paint = SurfacePaint()
..strokeWidth = 2
..color = enableFill ? const Color(0xFFFF0000) : const Color(0xFF000000)
..style = PaintingStyle.stroke;
}
if (mode == PaintMode.kStrokeWidthOnly) {
paint = Paint()
paint = SurfacePaint()
..color = const Color(0xFF4060E0)
..strokeWidth = 10;
}
canvas.drawPath(path, paint);
canvas.drawPath(path, paint!);
final html.Element svgElement = pathToSvgElement(path, paint, enableFill);
html.document.body.append(bitmapCanvas.rootElement);
html.document.body.append(svgElement);
html.document.body!.append(bitmapCanvas.rootElement);
html.document.body!.append(svgElement);
canvas.endRecording();
canvas.apply(bitmapCanvas, canvasBounds);
......@@ -77,7 +76,7 @@ void testMain() async {
}
tearDown(() {
html.document.body.children.clear();
html.document.body!.children.clear();
});
test('render line strokes', () async {
......@@ -85,7 +84,7 @@ void testMain() async {
path.moveTo(50, 60);
path.lineTo(200, 300);
await testPath(path, 'svg_stroke_line',
paint: Paint()
paint: SurfacePaint()
..color = const Color(0xFFFF0000)
..strokeWidth = 2.0
..style = PaintingStyle.stroke);
......@@ -192,7 +191,7 @@ html.Element pathToSvgElement(Path path, Paint paint, bool enableFill) {
'width="${bounds.right}" height="${bounds.bottom}">');
sb.write('<path ');
if (paint.style == PaintingStyle.stroke ||
(paint.strokeWidth != null && paint.strokeWidth != 0.0)) {
paint.strokeWidth != 0.0) {
sb.write('stroke="${colorToCssString(paint.color)}" ');
sb.write('stroke-width="${paint.strokeWidth}" ');
if (!enableFill) {
......
......@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.6
import 'dart:html' as html;
import 'dart:math' as math;
import 'dart:typed_data';
......@@ -23,7 +22,7 @@ void testMain() async {
const double screenWidth = 600.0;
const double screenHeight = 800.0;
const Rect screenRect = Rect.fromLTWH(0, 0, screenWidth, screenHeight);
final Paint testPaint = Paint()..color = const Color(0xFFFF0000);
final SurfacePaint testPaint = SurfacePaint()..color = const Color(0xFFFF0000);
// Commit a recording canvas to a bitmap, and compare with the expected
Future<void> _checkScreenshot(RecordingCanvas rc, String fileName,
......@@ -37,7 +36,7 @@ void testMain() async {
engineCanvas
..save()
..drawRect(
rc.pictureBounds,
rc.pictureBounds!,
SurfacePaintData()
..color = const Color.fromRGBO(0, 0, 255, 1.0)
..style = PaintingStyle.stroke
......@@ -51,7 +50,7 @@ void testMain() async {
final html.Element sceneElement = html.Element.tag('flt-scene');
try {
sceneElement.append(engineCanvas.rootElement);
html.document.body.append(sceneElement);
html.document.body!.append(sceneElement);
await matchGoldenFile('paint_bounds_for_$fileName.png', region: region,
write: write);
} finally {
......@@ -219,7 +218,7 @@ void testMain() async {
test('drawColor should cover full size', () async {
final RecordingCanvas rc = RecordingCanvas(screenRect);
final Paint testPaint = Paint()..color = const Color(0xFF80FF00);
final SurfacePaint testPaint = SurfacePaint()..color = const Color(0xFF80FF00);
rc.drawRect(const Rect.fromLTRB(10, 20, 30, 40), testPaint);
rc.drawColor(const Color(0xFFFF0000), BlendMode.multiply);
rc.drawRect(const Rect.fromLTRB(10, 60, 30, 80), testPaint);
......@@ -287,7 +286,7 @@ void testMain() async {
test('Computes paint bounds for draw image', () {
final RecordingCanvas rc = RecordingCanvas(screenRect);
rc.drawImage(TestImage(), const Offset(50, 100), Paint());
rc.drawImage(TestImage(), const Offset(50, 100), SurfacePaint());
rc.endRecording();
expect(rc.pictureBounds, const Rect.fromLTRB(50.0, 100.0, 70.0, 110.0));
});
......@@ -295,7 +294,7 @@ void testMain() async {
test('Computes paint bounds for draw image rect', () {
final RecordingCanvas rc = RecordingCanvas(screenRect);
rc.drawImageRect(TestImage(), const Rect.fromLTRB(1, 1, 20, 10),
const Rect.fromLTRB(5, 6, 400, 500), Paint());
const Rect.fromLTRB(5, 6, 400, 500), SurfacePaint());
rc.endRecording();
expect(rc.pictureBounds, const Rect.fromLTRB(5.0, 6.0, 400.0, 500.0));
});
......@@ -414,7 +413,7 @@ void testMain() async {
..translate(0, 100)
..scale(1, -1)
..clipRect(const Rect.fromLTRB(0, 0, 100, 50), ClipOp.intersect)
..drawRect(const Rect.fromLTRB(0, 0, 100, 100), Paint());
..drawRect(const Rect.fromLTRB(0, 0, 100, 100), SurfacePaint());
rc.endRecording();
expect(rc.pictureBounds, const Rect.fromLTRB(0.0, 50.0, 100.0, 100.0));
......@@ -428,7 +427,7 @@ void testMain() async {
..translate(50, 50)
..rotate(math.pi / 4.0)
..clipRect(const Rect.fromLTWH(-20, -20, 40, 40), ClipOp.intersect)
..drawRect(const Rect.fromLTWH(-80, -80, 160, 160), Paint());
..drawRect(const Rect.fromLTWH(-80, -80, 160, 160), SurfacePaint());
rc.endRecording();
expect(
......@@ -447,7 +446,7 @@ void testMain() async {
rc
..translate(50, 50)
..rotate(math.pi / 4.0)
..drawLine(const Offset(0, 0), const Offset(20, 20), Paint());
..drawLine(const Offset(0, 0), const Offset(20, 20), SurfacePaint());
rc.endRecording();
expect(
......@@ -467,7 +466,7 @@ void testMain() async {
path.lineTo(100, 97);
rc.drawPath(
path,
Paint()
SurfacePaint()
..style = PaintingStyle.stroke
..strokeWidth = 2.0
..color = const Color(0xFFFF0000));
......@@ -476,7 +475,7 @@ void testMain() async {
path.lineTo(97, 100);
rc.drawPath(
path,
Paint()
SurfacePaint()
..style = PaintingStyle.stroke
..strokeWidth = 2.0
..color = const Color(0xFF00FF00));
......@@ -498,7 +497,7 @@ void testMain() async {
RRect.fromLTRBR(0.5, 100.5, 80.7, 150.7, const Radius.circular(10)));
rc.drawPath(
path,
Paint()
SurfacePaint()
..style = PaintingStyle.stroke
..strokeWidth = 2.0
..color = const Color(0xFF404000));
......@@ -522,7 +521,7 @@ void testMain() async {
path.close();
rc.drawPath(
path,
Paint()
SurfacePaint()
..style = PaintingStyle.stroke
..strokeWidth = 2.0
..color = const Color(0xFF404000));
......@@ -624,7 +623,7 @@ void testMain() async {
final SurfacePaint zeroSpreadPaint = SurfacePaint();
painter(canvas, zeroSpreadPaint);
sb.addPicture(Offset.zero, recorder.endRecording());
sb.addPicture(Offset.zero, drawBounds(canvas.pictureBounds));
sb.addPicture(Offset.zero, drawBounds(canvas.pictureBounds!));
sb.pop();
}
......@@ -638,7 +637,7 @@ void testMain() async {
..strokeWidth = 5.0;
painter(canvas, thickStrokePaint);
sb.addPicture(Offset.zero, recorder.endRecording());
sb.addPicture(Offset.zero, drawBounds(canvas.pictureBounds));
sb.addPicture(Offset.zero, drawBounds(canvas.pictureBounds!));
sb.pop();
}
......@@ -651,7 +650,7 @@ void testMain() async {
..maskFilter = const MaskFilter.blur(BlurStyle.normal, 5.0);
painter(canvas, maskFilterBlurPaint);
sb.addPicture(Offset.zero, recorder.endRecording());
sb.addPicture(Offset.zero, drawBounds(canvas.pictureBounds));
sb.addPicture(Offset.zero, drawBounds(canvas.pictureBounds!));
sb.pop();
}
......@@ -666,15 +665,15 @@ void testMain() async {
..maskFilter = const MaskFilter.blur(BlurStyle.normal, 5.0);
painter(canvas, thickStrokeAndBlurPaint);
sb.addPicture(Offset.zero, recorder.endRecording());
sb.addPicture(Offset.zero, drawBounds(canvas.pictureBounds));
sb.addPicture(Offset.zero, drawBounds(canvas.pictureBounds!));
sb.pop();
}
sb.pop();
}
final html.Element sceneElement = sb.build().webOnlyRootElement;
html.document.body.append(sceneElement);
final html.Element sceneElement = sb.build().webOnlyRootElement!;
html.document.body!.append(sceneElement);
try {
await matchGoldenFile(
'paint_spread_bounds.png',
......
......@@ -138,7 +138,7 @@ final ui.TextStyle _defaultTextStyle = ui.TextStyle(
fontSize: 14,
);
ui.Paragraph paragraph(
EngineParagraph paragraph(
String text, {
ui.ParagraphStyle? paragraphStyle,
ui.TextStyle? textStyle,
......@@ -149,7 +149,9 @@ ui.Paragraph paragraph(
builder.pushStyle(textStyle ?? _defaultTextStyle);
builder.addText(text);
builder.pop();
return builder.build()..layout(ui.ParagraphConstraints(width: maxWidth));
final EngineParagraph paragraph = builder.build() as EngineParagraph;
paragraph.layout(ui.ParagraphConstraints(width: maxWidth));
return paragraph;
}
/// Configures the test to use bundled Roboto and Ahem fonts to avoid golden
......
......@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.6
import 'dart:async';
import 'package:test/bootstrap/browser.dart';
......@@ -39,13 +38,13 @@ void testMain() async {
setUpStableTestFonts();
Paragraph warning(String text) {
EngineParagraph warning(String text) {
return paragraph(text, textStyle: warningStyle);
}
testEachCanvas('maxLines clipping', (EngineCanvas canvas) {
Offset offset = Offset.zero;
Paragraph p;
EngineParagraph p;
// All three lines are rendered.
p = paragraph(threeLines);
......@@ -73,7 +72,7 @@ void testMain() async {
testEachCanvas('maxLines with overflow', (EngineCanvas canvas) {
Offset offset = Offset.zero;
Paragraph p;
EngineParagraph p;
// Only the first line is rendered with no ellipsis because the first line
// doesn't overflow.
......@@ -94,7 +93,7 @@ void testMain() async {
offset = offset.translate(0, p.height + 10);
// Only the first line is rendered with an ellipsis.
if (!WebExperiments.instance.useCanvasText) {
if (!WebExperiments.instance!.useCanvasText) {
// This is now correct with the canvas-based measurement, so we shouldn't
// print the "(wrong)" warning.
p = warning('(wrong)');
......@@ -111,7 +110,7 @@ void testMain() async {
// Only the first two lines are rendered and the ellipsis appears on the 2nd
// line.
if (!WebExperiments.instance.useCanvasText) {
if (!WebExperiments.instance!.useCanvasText) {
// This is now correct with the canvas-based measurement, so we shouldn't
// print the "(wrong)" warning.
p = warning('(wrong)');
......@@ -131,7 +130,7 @@ void testMain() async {
testEachCanvas('long unbreakable text', (EngineCanvas canvas) {
Offset offset = Offset.zero;
Paragraph p;
EngineParagraph p;
// The whole line is rendered unbroken when there are no constraints.
p = paragraph(longUnbreakable);
......
......@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.6
import 'package:test/bootstrap/browser.dart';
import 'package:ui/ui.dart';
import 'package:ui/src/engine.dart';
......
......@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.6
import 'package:test/bootstrap/browser.dart';
import 'package:test/test.dart';
......
......@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.6
import 'dart:html';
import 'package:test/bootstrap/browser.dart';
......@@ -22,7 +21,7 @@ void testMain() async {
await webOnlyInitializeTestDomRenderer();
String fallback;
late String fallback;
setUp(() {
if (operatingSystem == OperatingSystem.macOs ||
operatingSystem == OperatingSystem.iOs) {
......@@ -89,14 +88,14 @@ void testMain() async {
});
test('lay out unattached paragraph', () {
final DomParagraphBuilder builder = DomParagraphBuilder(ParagraphStyle(
final DomParagraphBuilder builder = DomParagraphBuilder(EngineParagraphStyle(
fontFamily: 'sans-serif',
fontStyle: FontStyle.normal,
fontWeight: FontWeight.normal,
fontSize: 14.0,
));
builder.addText('How do you do this fine morning?');
final DomParagraph paragraph = builder.build();
final DomParagraph paragraph = builder.build() as DomParagraph;
expect(paragraph.paragraphElement.parent, isNull);
expect(paragraph.height, 0.0);
......@@ -155,18 +154,18 @@ void testMain() async {
});
test('$ParagraphBuilder detects plain text', () {
DomParagraphBuilder builder = DomParagraphBuilder(ParagraphStyle(
DomParagraphBuilder builder = DomParagraphBuilder(EngineParagraphStyle(
fontFamily: 'sans-serif',
fontStyle: FontStyle.normal,
fontWeight: FontWeight.normal,
fontSize: 15.0,
));
builder.addText('hi');
DomParagraph paragraph = builder.build();
DomParagraph paragraph = builder.build() as DomParagraph;
expect(paragraph.plainText, isNotNull);
expect(paragraph.geometricStyle.fontWeight, FontWeight.normal);
builder = DomParagraphBuilder(ParagraphStyle(
builder = DomParagraphBuilder(EngineParagraphStyle(
fontFamily: 'sans-serif',
fontStyle: FontStyle.normal,
fontWeight: FontWeight.normal,
......@@ -174,13 +173,13 @@ void testMain() async {
));
builder.pushStyle(TextStyle(fontWeight: FontWeight.bold));
builder.addText('hi');
paragraph = builder.build();
paragraph = builder.build() as DomParagraph;
expect(paragraph.plainText, isNotNull);
expect(paragraph.geometricStyle.fontWeight, FontWeight.bold);
});
test('$ParagraphBuilder detects rich text', () {
final DomParagraphBuilder builder = DomParagraphBuilder(ParagraphStyle(
final DomParagraphBuilder builder = DomParagraphBuilder(EngineParagraphStyle(
fontFamily: 'sans-serif',
fontStyle: FontStyle.normal,
fontWeight: FontWeight.normal,
......@@ -189,27 +188,27 @@ void testMain() async {
builder.addText('h');
builder.pushStyle(TextStyle(fontWeight: FontWeight.bold));
builder.addText('i');
final DomParagraph paragraph = builder.build();
final DomParagraph paragraph = builder.build() as DomParagraph;
expect(paragraph.plainText, isNull);
expect(paragraph.geometricStyle.fontWeight, FontWeight.normal);
});
test('$ParagraphBuilder treats empty text as plain', () {
final DomParagraphBuilder builder = DomParagraphBuilder(ParagraphStyle(
final DomParagraphBuilder builder = DomParagraphBuilder(EngineParagraphStyle(
fontFamily: 'sans-serif',
fontStyle: FontStyle.normal,
fontWeight: FontWeight.normal,
fontSize: 15.0,
));
builder.pushStyle(TextStyle(fontWeight: FontWeight.bold));
final DomParagraph paragraph = builder.build();
final DomParagraph paragraph = builder.build() as DomParagraph;
expect(paragraph.plainText, '');
expect(paragraph.geometricStyle.fontWeight, FontWeight.bold);
});
// Regression test for https://github.com/flutter/flutter/issues/34931.
test('hit test on styled text returns correct span offset', () {
final DomParagraphBuilder builder = DomParagraphBuilder(ParagraphStyle(
final DomParagraphBuilder builder = DomParagraphBuilder(EngineParagraphStyle(
fontFamily: 'sans-serif',
fontStyle: FontStyle.normal,
fontWeight: FontWeight.normal,
......@@ -223,7 +222,7 @@ void testMain() async {
builder.addText(secondSpanText);
builder.pushStyle(TextStyle(fontStyle: FontStyle.italic));
builder.addText('followed by a link');
final DomParagraph paragraph = builder.build();
final DomParagraph paragraph = builder.build() as DomParagraph;
paragraph.layout(const ParagraphConstraints(width: 800.0));
expect(paragraph.plainText, isNull);
const int secondSpanStartPosition = firstSpanText.length;
......@@ -239,7 +238,7 @@ void testMain() async {
const fontFamily = 'sans-serif';
const fontSize = 20.0;
final style = TextStyle(fontFamily: fontFamily, fontSize: fontSize);
final DomParagraphBuilder builder = DomParagraphBuilder(ParagraphStyle(
final DomParagraphBuilder builder = DomParagraphBuilder(EngineParagraphStyle(
fontFamily: fontFamily,
fontSize: fontSize,
));
......@@ -326,7 +325,7 @@ void testMain() async {
'test te04 test050 '
*/
final DomParagraph paragraph = builder.build();
final DomParagraph paragraph = builder.build() as DomParagraph;
paragraph.layout(ParagraphConstraints(width: 800));
// Reference the offsets with the output of `Display arrangement`.
......@@ -358,7 +357,7 @@ void testMain() async {
test(
'should not set fontFamily to effectiveFontFamily for spans in rich text',
() {
final DomParagraphBuilder builder = DomParagraphBuilder(ParagraphStyle(
final DomParagraphBuilder builder = DomParagraphBuilder(EngineParagraphStyle(
fontFamily: 'Roboto',
fontStyle: FontStyle.normal,
fontWeight: FontWeight.normal,
......@@ -371,7 +370,7 @@ void testMain() async {
builder.pushStyle(TextStyle(fontSize: 30.0, fontWeight: FontWeight.normal));
const String secondSpanText = 'def';
builder.addText(secondSpanText);
final DomParagraph paragraph = builder.build();
final DomParagraph paragraph = builder.build() as DomParagraph;
paragraph.layout(const ParagraphConstraints(width: 800.0));
expect(paragraph.plainText, isNull);
final List<SpanElement> spans =
......@@ -389,14 +388,14 @@ void testMain() async {
// Set this to false so it doesn't default to 'Ahem' font.
debugEmulateFlutterTesterEnvironment = false;
final DomParagraphBuilder builder = DomParagraphBuilder(ParagraphStyle(
final DomParagraphBuilder builder = DomParagraphBuilder(EngineParagraphStyle(
fontFamily: 'SomeFont',
fontSize: 12.0,
));
builder.addText('Hello');
final DomParagraph paragraph = builder.build();
final DomParagraph paragraph = builder.build() as DomParagraph;
expect(paragraph.paragraphElement.style.fontFamily,
'SomeFont, $fallback, sans-serif');
......@@ -411,14 +410,14 @@ void testMain() async {
// Set this to false so it doesn't default to 'Ahem' font.
debugEmulateFlutterTesterEnvironment = false;
final DomParagraphBuilder builder = DomParagraphBuilder(ParagraphStyle(
final DomParagraphBuilder builder = DomParagraphBuilder(EngineParagraphStyle(
fontFamily: 'serif',
fontSize: 12.0,
));
builder.addText('Hello');
final DomParagraph paragraph = builder.build();
final DomParagraph paragraph = builder.build() as DomParagraph;
expect(paragraph.paragraphElement.style.fontFamily, 'serif');
debugEmulateFlutterTesterEnvironment = true;
......@@ -428,14 +427,14 @@ void testMain() async {
// Set this to false so it doesn't default to 'Ahem' font.
debugEmulateFlutterTesterEnvironment = false;
final DomParagraphBuilder builder = DomParagraphBuilder(ParagraphStyle(
final DomParagraphBuilder builder = DomParagraphBuilder(EngineParagraphStyle(
fontFamily: 'MyFont 2000',
fontSize: 12.0,
));
builder.addText('Hello');
final DomParagraph paragraph = builder.build();
final DomParagraph paragraph = builder.build() as DomParagraph;
expect(paragraph.paragraphElement.style.fontFamily,
'"MyFont 2000", $fallback, sans-serif');
......
......@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.6
import 'dart:io';
import 'package:args/args.dart';
......@@ -129,8 +128,8 @@ void main(List<String> arguments) async {
}
PropertiesSyncer getSyncer(
String wordBreakProperties,
String lineBreakProperties,
String? wordBreakProperties,
String? lineBreakProperties,
bool dry,
) {
if (wordBreakProperties == null && lineBreakProperties == null) {
......@@ -151,8 +150,8 @@ PropertiesSyncer getSyncer(
: WordBreakPropertiesSyncer(wordBreakProperties, '$wordBreakCodegen');
} else {
return dry
? LineBreakPropertiesSyncer.dry(lineBreakProperties)
: LineBreakPropertiesSyncer(lineBreakProperties, '$lineBreakCodegen');
? LineBreakPropertiesSyncer.dry(lineBreakProperties!)
: LineBreakPropertiesSyncer(lineBreakProperties!, '$lineBreakCodegen');
}
}
......@@ -168,7 +167,7 @@ abstract class PropertiesSyncer {
_dryRun = true;
final String _src;
final String _dest;
final String? _dest;
final bool _dryRun;
String get prefix;
......@@ -189,7 +188,7 @@ abstract class PropertiesSyncer {
if (_dryRun) {
print(output);
} else {
final IOSink sink = File(_dest).openWrite();
final IOSink sink = File(_dest!).openWrite();
sink.write(output);
}
}
......@@ -305,17 +304,17 @@ class PropertyCollection {
.map(parseLineIntoUnicodeRange)
.toList();
// Insert the default property if it doesn't exist.
final EnumValue found = enumCollection.values.firstWhere(
(property) => property.name == defaultProperty,
final EnumValue? found = enumCollection.values.cast<EnumValue?>().firstWhere(
(property) => property!.name == defaultProperty,
orElse: () => null,
);
if (found == null) {
enumCollection.add(defaultProperty);
}
ranges = processRanges(unprocessedRanges, defaultProperty);
ranges = processRanges(unprocessedRanges, defaultProperty).toList();
}
List<UnicodeRange> ranges;
late List<UnicodeRange> ranges;
final EnumCollection enumCollection = EnumCollection();
......@@ -336,7 +335,7 @@ class PropertyCollection {
final String propertyStr = split[1].trim();
final EnumValue property = normalizationTable.containsKey(propertyStr)
? enumCollection.add(normalizationTable[propertyStr], propertyStr)
? enumCollection.add(normalizationTable[propertyStr]!, propertyStr)
: enumCollection.add(propertyStr);
return UnicodeRange(
......@@ -351,7 +350,7 @@ class PropertyCollection {
class EnumCollection {
final List<EnumValue> values = <EnumValue>[];
EnumValue add(String name, [String normalizedFrom]) {
EnumValue add(String name, [String? normalizedFrom]) {
final int index =
values.indexWhere((EnumValue value) => value.name == name);
EnumValue value;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册