diff --git a/.cirrus.yml b/.cirrus.yml index d90a760e2258b..728a4538cca7a 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -127,7 +127,7 @@ task: script: - cd $ENGINE_PATH/src/flutter/lib/web_ui - $ENGINE_PATH/src/out/host_debug_unopt/dart-sdk/bin/pub get - - $ENGINE_PATH/src/out/host_debug_unopt/dart-sdk/bin/dartanalyzer --fatal-warnings --fatal-hints dev/ lib/ test/ tool/ + - $ENGINE_PATH/src/out/host_debug_unopt/dart-sdk/bin/dartanalyzer --enable-experiment=non-nullable --fatal-warnings --fatal-hints dev/ lib/ test/ tool/ - name: format_and_dart_test format_script: | diff --git a/lib/web_ui/analysis_options.yaml b/lib/web_ui/analysis_options.yaml index 5b40ea7c85c1e..869fffe973553 100644 --- a/lib/web_ui/analysis_options.yaml +++ b/lib/web_ui/analysis_options.yaml @@ -3,6 +3,8 @@ # uncommented, we'll delete this file and simply inherit the root options. analyzer: + enable-experiment: + - non-nullable strong-mode: # TODO(uncomment) implicit-casts: false implicit-dynamic: false diff --git a/lib/web_ui/build.canvaskit.yaml b/lib/web_ui/build.canvaskit.yaml index e628a26122839..3eee9e132401d 100644 --- a/lib/web_ui/build.canvaskit.yaml +++ b/lib/web_ui/build.canvaskit.yaml @@ -11,6 +11,8 @@ targets: dart2js_args: - --no-minify - --enable-asserts + - --enable-experiment=non-nullable + - --no-sound-null-safety - -DFLUTTER_WEB_USE_SKIA=true generate_for: include: diff --git a/lib/web_ui/build.html.yaml b/lib/web_ui/build.html.yaml index 3a208b20455e7..b469539d305da 100644 --- a/lib/web_ui/build.html.yaml +++ b/lib/web_ui/build.html.yaml @@ -10,6 +10,8 @@ targets: dart2js_args: - --no-minify - --enable-asserts + - --enable-experiment=non-nullable + - --no-sound-null-safety generate_for: include: - test/**.dart diff --git a/lib/web_ui/dev/integration_tests_manager.dart b/lib/web_ui/dev/integration_tests_manager.dart index 3abf8817bffa8..dff29c866d396 100644 --- a/lib/web_ui/dev/integration_tests_manager.dart +++ b/lib/web_ui/dev/integration_tests_manager.dart @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// @dart = 2.6 + import 'dart:io' as io; import 'package:path/path.dart' as pathlib; import 'package:web_driver_installer/chrome_driver_installer.dart'; @@ -51,7 +53,7 @@ class IntegrationTestsManager { // LUCI installs driver from CIPD, so we skip installing it on LUCI. await _prepareDriver(); } else { - await _verifyDriverForLUCI(); + _verifyDriverForLUCI(); } await _startDriver(_browserDriverDir.path); // TODO(nurhan): https://github.com/flutter/flutter/issues/52987 @@ -109,13 +111,13 @@ class IntegrationTestsManager { } } - void _startDriver(String workingDirectory) async { + Future _startDriver(String workingDirectory) async { await startProcess('./chromedriver/chromedriver', ['--port=4444'], workingDirectory: workingDirectory); print('INFO: Driver started'); } - void _prepareDriver() async { + Future _prepareDriver() async { if (_browserDriverDir.existsSync()) { _browserDriverDir.deleteSync(recursive: true); } @@ -130,7 +132,10 @@ class IntegrationTestsManager { final String chromeDriverVersion = await queryChromeDriverVersion(); ChromeDriverInstaller chromeDriverInstaller = ChromeDriverInstaller.withVersion(chromeDriverVersion); - await chromeDriverInstaller.install(alwaysInstall: true); + // TODO(yjbanov): remove this dynamic hack when chromeDriverInstaller.install returns Future + // https://github.com/flutter/flutter/issues/59376 + final dynamic installationFuture = chromeDriverInstaller.install(alwaysInstall: true) as dynamic; + await installationFuture; io.Directory.current = temp; } @@ -172,7 +177,7 @@ class IntegrationTestsManager { .whereType() .toList(); - final List e2eTestsToRun = List(); + final List e2eTestsToRun = []; final List blockedTests = blockedTestsListsMap[getBlockedTestsListMapKey(_browser)] ?? []; @@ -265,7 +270,7 @@ class IntegrationTestsManager { // Whether the project has the pubspec.yaml file. bool pubSpecFound = false; // The test directory 'test_driver'. - io.Directory testDirectory = null; + io.Directory testDirectory; for (io.FileSystemEntity e in entities) { // The tests should be under this directories. diff --git a/lib/web_ui/dev/test_runner.dart b/lib/web_ui/dev/test_runner.dart index b33c73e668644..c11a4b3dc47e3 100644 --- a/lib/web_ui/dev/test_runner.dart +++ b/lib/web_ui/dev/test_runner.dart @@ -446,6 +446,7 @@ class TestCommand extends Command with ArgUtils { 'run', 'build_runner', 'build', + '--enable-experiment=non-nullable', 'test', '-o', forCanvasKit ? canvasKitOutputRelativePath : 'build', diff --git a/lib/web_ui/dev/utils.dart b/lib/web_ui/dev/utils.dart index 66184b413ef72..96633acb761fa 100644 --- a/lib/web_ui/dev/utils.dart +++ b/lib/web_ui/dev/utils.dart @@ -67,7 +67,7 @@ Future runProcess( } /// Runs [executable]. Do not follow the exit code or the output. -void startProcess( +Future startProcess( String executable, List arguments, { String workingDirectory, diff --git a/lib/web_ui/lib/src/engine.dart b/lib/web_ui/lib/src/engine.dart index ae1f6fc6b0f15..857d6acd1b76e 100644 --- a/lib/web_ui/lib/src/engine.dart +++ b/lib/web_ui/lib/src/engine.dart @@ -152,7 +152,7 @@ void registerHotRestartListener(ui.VoidCallback listener) { /// environment in the native embedder. // TODO(yjbanov): we should refactor the code such that the framework does not // call this method directly. -void webOnlyInitializeEngine() { +void initializeEngine() { if (_engineInitialized) { return; } diff --git a/lib/web_ui/lib/src/engine/compositor/embedded_views.dart b/lib/web_ui/lib/src/engine/compositor/embedded_views.dart index 60d218d0d0e47..d5a76e55a3c36 100644 --- a/lib/web_ui/lib/src/engine/compositor/embedded_views.dart +++ b/lib/web_ui/lib/src/engine/compositor/embedded_views.dart @@ -93,8 +93,8 @@ class HtmlViewEmbedder { return; } - final PlatformViewFactory factory = - platformViewRegistry.registeredFactories[viewType]; + final ui.PlatformViewFactory factory = + ui.platformViewRegistry.registeredFactories[viewType]; if (factory == null) { callback(codec.encodeErrorEnvelope( code: 'unregistered_view_type', diff --git a/lib/web_ui/lib/src/engine/compositor/initialization.dart b/lib/web_ui/lib/src/engine/compositor/initialization.dart index 36284e1d2ac7a..3f7ee1ce07a31 100644 --- a/lib/web_ui/lib/src/engine/compositor/initialization.dart +++ b/lib/web_ui/lib/src/engine/compositor/initialization.dart @@ -51,5 +51,10 @@ js.JsObject canvasKit; /// The Skia font collection. SkiaFontCollection skiaFontCollection; +/// Initializes [skiaFontCollection]. +void ensureSkiaFontCollectionInitialized() { + skiaFontCollection ??= SkiaFontCollection(); +} + /// The scene host, where the root canvas and overlay canvases are added to. html.Element skiaSceneHost; diff --git a/lib/web_ui/lib/src/engine/platform_views.dart b/lib/web_ui/lib/src/engine/platform_views.dart index d422f9a3ecf84..1d686da046b3f 100644 --- a/lib/web_ui/lib/src/engine/platform_views.dart +++ b/lib/web_ui/lib/src/engine/platform_views.dart @@ -5,90 +5,7 @@ // @dart = 2.6 part of engine; -/// A registry for factories that create platform views. -class PlatformViewRegistry { - final Map registeredFactories = - {}; - - final Map _createdViews = {}; - - /// Private constructor so this class can be a singleton. - PlatformViewRegistry._(); - - /// Register [viewTypeId] as being creating by the given [factory]. - bool registerViewFactory(String viewTypeId, PlatformViewFactory factory) { - if (registeredFactories.containsKey(viewTypeId)) { - return false; - } - registeredFactories[viewTypeId] = factory; - return true; - } - - /// Returns the view that has been created with the given [id], or `null` if - /// no such view exists. - html.Element getCreatedView(int id) { - return _createdViews[id]; - } -} - -/// A function which takes a unique [id] and creates an HTML element. -typedef PlatformViewFactory = html.Element Function(int viewId); - -/// The platform view registry for this app. -final PlatformViewRegistry platformViewRegistry = PlatformViewRegistry._(); - -/// Handles a platform call to `flutter/platform_views`. -/// -/// Used to create platform views. -void handlePlatformViewCall( - ByteData data, - ui.PlatformMessageResponseCallback callback, -) { - const MethodCodec codec = StandardMethodCodec(); - final MethodCall decoded = codec.decodeMethodCall(data); - - switch (decoded.method) { - case 'create': - _createPlatformView(decoded, callback); - return; - case 'dispose': - _disposePlatformView(decoded, callback); - return; - } - callback(null); -} - -void _createPlatformView( - MethodCall methodCall, ui.PlatformMessageResponseCallback callback) { - final Map args = methodCall.arguments; - final int id = args['id']; - final String viewType = args['viewType']; - const MethodCodec codec = StandardMethodCodec(); - - // TODO(het): Use 'direction', 'width', and 'height'. - if (!platformViewRegistry.registeredFactories.containsKey(viewType)) { - callback(codec.encodeErrorEnvelope( - code: 'Unregistered factory', - message: "No factory registered for viewtype '$viewType'", - )); - return; - } - // TODO(het): Use creation parameters. - final html.Element element = - platformViewRegistry.registeredFactories[viewType](id); - - platformViewRegistry._createdViews[id] = element; - callback(codec.encodeSuccessEnvelope(null)); -} - -void _disposePlatformView( - MethodCall methodCall, ui.PlatformMessageResponseCallback callback) { - final int id = methodCall.arguments; - const MethodCodec codec = StandardMethodCodec(); - - // Remove the root element of the view from the DOM. - platformViewRegistry._createdViews[id]?.remove(); - platformViewRegistry._createdViews.remove(id); - - callback(codec.encodeSuccessEnvelope(null)); -} +// TODO(yjbanov): The code in this file was temporarily moved to lib/web_ui/lib/ui.dart +// during the NNBD migration so that `dart:ui` does not have to export +// `dart:_engine`. NNBD does not allow exported non-migrated libraries +// from migrated libraries. diff --git a/lib/web_ui/lib/src/engine/plugins.dart b/lib/web_ui/lib/src/engine/plugins.dart index e1dbab184ac58..b419ecab4e419 100644 --- a/lib/web_ui/lib/src/engine/plugins.dart +++ b/lib/web_ui/lib/src/engine/plugins.dart @@ -6,7 +6,3 @@ part of engine; Future Function(String, ByteData, ui.PlatformMessageResponseCallback) pluginMessageCallHandler; - -void webOnlySetPluginHandler(Future Function(String, ByteData, ui.PlatformMessageResponseCallback) handler) { - pluginMessageCallHandler = handler; -} diff --git a/lib/web_ui/lib/src/engine/semantics/incrementable.dart b/lib/web_ui/lib/src/engine/semantics/incrementable.dart index 5ae975aa4fd1f..aec945a769b65 100644 --- a/lib/web_ui/lib/src/engine/semantics/incrementable.dart +++ b/lib/web_ui/lib/src/engine/semantics/incrementable.dart @@ -110,13 +110,13 @@ class Incrementable extends RoleManager { _element.setAttribute('aria-valuenow', surrogateTextValue); _element.setAttribute('aria-valuetext', semanticsObject.value); - final bool canIncrease = semanticsObject.increasedValue != null; + final bool canIncrease = semanticsObject.increasedValue.isNotEmpty; final String surrogateMaxTextValue = canIncrease ? '${_currentSurrogateValue + 1}' : surrogateTextValue; _element.max = surrogateMaxTextValue; _element.setAttribute('aria-valuemax', surrogateMaxTextValue); - final bool canDecrease = semanticsObject.decreasedValue != null; + final bool canDecrease = semanticsObject.decreasedValue.isNotEmpty; final String surrogateMinTextValue = canDecrease ? '${_currentSurrogateValue - 1}' : surrogateTextValue; _element.min = surrogateMinTextValue; diff --git a/lib/web_ui/lib/src/engine/surface/canvas.dart b/lib/web_ui/lib/src/engine/surface/canvas.dart index 07133b1d6e345..eff7ec956b87f 100644 --- a/lib/web_ui/lib/src/engine/surface/canvas.dart +++ b/lib/web_ui/lib/src/engine/surface/canvas.dart @@ -87,7 +87,7 @@ class SurfaceCanvas implements ui.Canvas { @override void clipRect(ui.Rect/*!*/ rect, - {ui.ClipOp clipOp/*!*/ = ui.ClipOp.intersect, bool/*!*/ doAntiAlias = true}) { + {ui.ClipOp/*!*/ clipOp = ui.ClipOp.intersect, bool/*!*/ doAntiAlias = true}) { assert(rectIsValid(rect)); assert(clipOp != null); assert(doAntiAlias != null); diff --git a/lib/web_ui/lib/src/engine/surface/platform_view.dart b/lib/web_ui/lib/src/engine/surface/platform_view.dart index 981c8882f75da..8f0fd5cfd0de2 100644 --- a/lib/web_ui/lib/src/engine/surface/platform_view.dart +++ b/lib/web_ui/lib/src/engine/surface/platform_view.dart @@ -47,7 +47,7 @@ class PersistedPlatformView extends PersistedLeafSurface { }'''; _shadowRoot.append(_styleReset); final html.Element platformView = - platformViewRegistry.getCreatedView(viewId); + ui.platformViewRegistry.getCreatedView(viewId); if (platformView != null) { _shadowRoot.append(platformView); } else { @@ -67,7 +67,7 @@ class PersistedPlatformView extends PersistedLeafSurface { ..height = '${height}px'; // Set size of the root element created by the PlatformView. final html.Element platformView = - platformViewRegistry.getCreatedView(viewId); + ui.platformViewRegistry.getCreatedView(viewId); if (platformView != null) { platformView.style ..width = '${width}px' diff --git a/lib/web_ui/lib/src/engine/util.dart b/lib/web_ui/lib/src/engine/util.dart index 2f5319d934dee..1f4e5c386aab5 100644 --- a/lib/web_ui/lib/src/engine/util.dart +++ b/lib/web_ui/lib/src/engine/util.dart @@ -12,7 +12,7 @@ typedef Callback = void Function(T result); /// /// Return value should be null on success, and a string error message on /// failure. -typedef Callbacker = String Function(Callback callback); +typedef Callbacker = String/*?*/ Function(Callback callback); /// Converts a method that receives a value-returning callback to a method that /// returns a Future. diff --git a/lib/web_ui/lib/src/engine/window.dart b/lib/web_ui/lib/src/engine/window.dart index 0e65080fa00a4..d396a3faa966a 100644 --- a/lib/web_ui/lib/src/engine/window.dart +++ b/lib/web_ui/lib/src/engine/window.dart @@ -582,7 +582,7 @@ class EngineWindow extends ui.Window { if (experimentalUseSkia) { rasterizer.viewEmbedder.handlePlatformViewCall(data, callback); } else { - handlePlatformViewCall(data, callback); + ui.handlePlatformViewCall(data, callback); } return; diff --git a/lib/web_ui/lib/src/ui/annotations.dart b/lib/web_ui/lib/src/ui/annotations.dart index 4af5f3b5e3fee..977ca70ca7273 100644 --- a/lib/web_ui/lib/src/ui/annotations.dart +++ b/lib/web_ui/lib/src/ui/annotations.dart @@ -4,7 +4,7 @@ // TODO(dnfield): Remove unused_import ignores when https://github.com/dart-lang/sdk/issues/35164 is resolved. -// @dart = 2.6 +// @dart = 2.9 part of ui; // TODO(dnfield): Update this if/when we default this to on in the tool, @@ -39,7 +39,7 @@ part of ui; /// } /// } /// ``` -const _KeepToString/*!*/ keepToString = _KeepToString(); +const _KeepToString keepToString = _KeepToString(); class _KeepToString { const _KeepToString(); diff --git a/lib/web_ui/lib/src/ui/canvas.dart b/lib/web_ui/lib/src/ui/canvas.dart index b34c5789be42c..7f5cc742025d0 100644 --- a/lib/web_ui/lib/src/ui/canvas.dart +++ b/lib/web_ui/lib/src/ui/canvas.dart @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.6 +// @dart = 2.9 part of ui; /// Defines how a list of points is interpreted when drawing a set of points. @@ -70,11 +70,11 @@ class Vertices { /// If the [indices] parameter is provided, all values in the list must be /// valid index values for [positions]. factory Vertices( - VertexMode/*!*/ mode, - List/*!*/ positions, { - List/*?*/ textureCoordinates, - List/*?*/ colors, - List/*?*/ indices, + VertexMode mode, + List positions, { + List? textureCoordinates, + List? colors, + List? indices, }) { if (engine.experimentalUseSkia) { return engine.SkVertices(mode, positions, @@ -106,11 +106,11 @@ class Vertices { /// If the [indices] list is provided, all values in the list must be /// valid index values for [positions]. factory Vertices.raw( - VertexMode/*!*/ mode, - Float32List/*!*/ positions, { - Float32List/*?*/ textureCoordinates, - Int32List/*?*/ colors, - Uint16List/*?*/ indices, + VertexMode mode, + Float32List positions, { + Float32List? textureCoordinates, + Int32List? colors, + Uint16List? indices, }) { if (engine.experimentalUseSkia) { return engine.SkVertices.raw(mode, positions, @@ -147,14 +147,14 @@ abstract class PictureRecorder { /// call to [endRecording], and false if either this /// [PictureRecorder] has not yet been associated with a [Canvas], /// or the [endRecording] method has already been called. - bool/*!*/ get isRecording; + bool get isRecording; /// Finishes recording graphical operations. /// /// Returns a picture containing the graphical operations that have been /// recorded thus far. After calling this function, both the picture recorder /// and the canvas objects are invalid and cannot be used further. - Picture/*!*/ endRecording(); + Picture endRecording(); } /// An interface for recording graphical operations. @@ -175,11 +175,11 @@ abstract class PictureRecorder { /// The current transform and clip can be saved and restored using the stack /// managed by the [save], [saveLayer], and [restore] methods. abstract class Canvas { - factory Canvas(PictureRecorder/*!*/ recorder, [Rect/*?*/ cullRect]) { + factory Canvas(PictureRecorder recorder, [Rect? cullRect]) { if (engine.experimentalUseSkia) { return engine.CanvasKitCanvas(recorder, cullRect); } else { - return engine.SurfaceCanvas(recorder, cullRect); + return engine.SurfaceCanvas(recorder as engine.EnginePictureRecorder, cullRect); } } @@ -302,7 +302,7 @@ abstract class Canvas { /// for subsequent commands. /// * [BlendMode], which discusses the use of [Paint.blendMode] with /// [saveLayer]. - void saveLayer(Rect/*?*/ bounds, Paint/*!*/ paint); + void saveLayer(Rect? bounds, Paint paint); /// Pops the current save stack, if there is anything to pop. /// Otherwise, does nothing. @@ -319,11 +319,11 @@ abstract class Canvas { /// each matching call to [restore] decrements it. /// /// This number cannot go below 1. - int/*!*/ getSaveCount(); + int getSaveCount(); /// Add a translation to the current transform, shifting the coordinate space /// horizontally by the first argument and vertically by the second argument. - void translate(double/*!*/ dx, double/*!*/ dy); + void translate(double dx, double dy); /// Add an axis-aligned scale to the current transform, scaling by the first /// argument in the horizontal direction and the second in the vertical @@ -331,20 +331,20 @@ abstract class Canvas { /// /// If [sy] is unspecified, [sx] will be used for the scale in both /// directions. - void scale(double/*!*/ sx, [double/*?*/ sy]); + void scale(double sx, [double? sy]); /// Add a rotation to the current transform. The argument is in radians clockwise. - void rotate(double/*!*/ radians); + void rotate(double radians); /// Add an axis-aligned skew to the current transform, with the first argument /// being the horizontal skew in radians clockwise around the origin, and the /// second argument being the vertical skew in radians clockwise around the /// origin. - void skew(double/*!*/ sx, double/*!*/ sy); + void skew(double sx, double sy); /// Multiply the current transform by the specified 4⨉4 transformation matrix /// specified as a list of values in column-major order. - void transform(Float64List/*!*/ matrix4); + void transform(Float64List matrix4); /// Reduces the clip region to the intersection of the current clip and the /// given rectangle. @@ -357,8 +357,8 @@ abstract class Canvas { /// /// Use [ClipOp.difference] to subtract the provided rectangle from the /// current clip. - void clipRect(Rect/*!*/ rect, - {ClipOp clipOp/*!*/ = ClipOp.intersect, bool/*!*/ doAntiAlias = true}); + void clipRect(Rect rect, + {ClipOp clipOp = ClipOp.intersect, bool doAntiAlias = true}); /// Reduces the clip region to the intersection of the current clip and the /// given rounded rectangle. @@ -368,7 +368,7 @@ abstract class Canvas { /// If multiple draw commands intersect with the clip boundary, this can result /// in incorrect blending at the clip boundary. See [saveLayer] for a /// discussion of how to address that and some examples of using [clipRRect]. - void clipRRect(RRect/*!*/ rrect, {bool/*!*/ doAntiAlias = true}); + void clipRRect(RRect rrect, {bool doAntiAlias = true}); /// Reduces the clip region to the intersection of the current clip and the /// given [Path]. @@ -379,50 +379,50 @@ abstract class Canvas { /// multiple draw commands intersect with the clip boundary, this can result /// in incorrect blending at the clip boundary. See [saveLayer] for a /// discussion of how to address that. - void clipPath(Path/*!*/ path, {bool/*!*/ doAntiAlias = true}); + void clipPath(Path path, {bool doAntiAlias = true}); /// Paints the given [Color] onto the canvas, applying the given /// [BlendMode], with the given color being the source and the background /// being the destination. - void drawColor(Color/*!*/ color, BlendMode/*!*/ blendMode); + void drawColor(Color color, BlendMode blendMode); /// Draws a line between the given points using the given paint. The line is /// stroked, the value of the [Paint.style] is ignored for this call. /// /// The `p1` and `p2` arguments are interpreted as offsets from the origin. - void drawLine(Offset/*!*/ p1, Offset/*!*/ p2, Paint/*!*/ paint); + void drawLine(Offset p1, Offset p2, Paint paint); /// Fills the canvas with the given [Paint]. /// /// To fill the canvas with a solid color and blend mode, consider /// [drawColor] instead. - void drawPaint(Paint/*!*/ paint); + void drawPaint(Paint paint); /// Draws a rectangle with the given [Paint]. Whether the rectangle is filled /// or stroked (or both) is controlled by [Paint.style]. - void drawRect(Rect/*!*/ rect, Paint/*!*/ paint); + void drawRect(Rect rect, Paint paint); /// Draws a rounded rectangle with the given [Paint]. Whether the rectangle is /// filled or stroked (or both) is controlled by [Paint.style]. - void drawRRect(RRect/*!*/ rrect, Paint/*!*/ paint); + void drawRRect(RRect rrect, Paint paint); /// Draws a shape consisting of the difference between two rounded rectangles /// with the given [Paint]. Whether this shape is filled or stroked (or both) /// is controlled by [Paint.style]. /// /// This shape is almost but not quite entirely unlike an annulus. - void drawDRRect(RRect/*!*/ outer, RRect/*!*/ inner, Paint/*!*/ paint); + void drawDRRect(RRect outer, RRect inner, Paint paint); /// Draws an axis-aligned oval that fills the given axis-aligned rectangle /// with the given [Paint]. Whether the oval is filled or stroked (or both) is /// controlled by [Paint.style]. - void drawOval(Rect/*!*/ rect, Paint/*!*/ paint); + void drawOval(Rect rect, Paint paint); /// Draws a circle centered at the point given by the first argument and /// that has the radius given by the second argument, with the [Paint] given in /// the third argument. Whether the circle is filled or stroked (or both) is /// controlled by [Paint.style]. - void drawCircle(Offset/*!*/ c, double/*!*/ radius, Paint/*!*/ paint); + void drawCircle(Offset c, double radius, Paint paint); /// Draw an arc scaled to fit inside the given rectangle. It starts from /// startAngle radians around the oval up to startAngle + sweepAngle @@ -434,17 +434,17 @@ abstract class Canvas { /// not closed, forming a circle segment. /// /// This method is optimized for drawing arcs and should be faster than [Path.arcTo]. - void drawArc(Rect/*!*/ rect, double/*!*/ startAngle, double/*!*/ sweepAngle, bool/*!*/ useCenter, - Paint/*!*/ paint); + void drawArc(Rect rect, double startAngle, double sweepAngle, bool useCenter, + Paint paint); /// Draws the given [Path] with the given [Paint]. Whether this shape is /// filled or stroked (or both) is controlled by [Paint.style]. If the path is /// filled, then subpaths within it are implicitly closed (see [Path.close]). - void drawPath(Path/*!*/ path, Paint/*!*/ paint); + void drawPath(Path path, Paint paint); /// Draws the given [Image] into the canvas with its top-left corner at the /// given [Offset]. The image is composited into the canvas using the given [Paint]. - void drawImage(Image/*!*/ image, Offset/*!*/ offset, Paint/*!*/ paint); + void drawImage(Image image, Offset offset, Paint paint); /// Draws the subset of the given image described by the `src` argument into /// the canvas in the axis-aligned rectangle given by the `dst` argument. @@ -455,7 +455,7 @@ abstract class Canvas { /// Multiple calls to this method with different arguments (from the same /// image) can be batched into a single call to [drawAtlas] to improve /// performance. - void drawImageRect(Image/*!*/ image, Rect/*!*/ src, Rect/*!*/ dst, Paint/*!*/ paint); + void drawImageRect(Image image, Rect src, Rect dst, Paint paint); /// Draws the given [Image] into the canvas using the given [Paint]. /// @@ -470,11 +470,11 @@ abstract class Canvas { /// five regions are drawn by stretching them to fit such that they exactly /// cover the destination rectangle while maintaining their relative /// positions. - void drawImageNine(Image/*!*/ image, Rect/*!*/ center, Rect/*!*/ dst, Paint/*!*/ paint); + void drawImageNine(Image image, Rect center, Rect dst, Paint paint); /// Draw the given picture onto the canvas. To create a picture, see /// [PictureRecorder]. - void drawPicture(Picture/*!*/ picture); + void drawPicture(Picture picture); /// Draws the text in the given [Paragraph] into this canvas at the given /// [Offset]. @@ -496,7 +496,7 @@ abstract class Canvas { /// If the text is centered, the centering axis will be at the position /// described by adding half of the [ParagraphConstraints.width] given to /// [Paragraph.layout], to the `offset` argument's [Offset.dx] coordinate. - void drawParagraph(Paragraph/*!*/ paragraph, Offset/*!*/ offset); + void drawParagraph(Paragraph paragraph, Offset offset); /// Draws a sequence of points according to the given [PointMode]. /// @@ -506,7 +506,7 @@ abstract class Canvas { /// /// * [drawRawPoints], which takes `points` as a [Float32List] rather than a /// [List]. - void drawPoints(PointMode/*!*/ pointMode, List/*!*/ points, Paint/*!*/ paint); + void drawPoints(PointMode pointMode, List points, Paint paint); /// Draws a sequence of points according to the given [PointMode]. /// @@ -517,9 +517,9 @@ abstract class Canvas { /// /// * [drawPoints], which takes `points` as a [List] rather than a /// [List]. - void drawRawPoints(PointMode/*!*/ pointMode, Float32List/*!*/ points, Paint/*!*/ paint); + void drawRawPoints(PointMode pointMode, Float32List points, Paint paint); - void drawVertices(Vertices/*!*/ vertices, BlendMode/*!*/ blendMode, Paint/*!*/ paint); + void drawVertices(Vertices vertices, BlendMode blendMode, Paint paint); /// Draws part of an image - the [atlas] - onto the canvas. /// @@ -534,13 +534,13 @@ abstract class Canvas { /// * [drawRawAtlas], which takes its arguments as typed data lists rather /// than objects. void drawAtlas( - Image/*!*/ atlas, - List/*!*/ transforms, - List/*!*/ rects, - List/*!*/ colors, - BlendMode/*!*/ blendMode, - Rect/*?*/ cullRect, - Paint/*!*/ paint, + Image atlas, + List transforms, + List rects, + List colors, + BlendMode blendMode, + Rect? cullRect, + Paint paint, ); /// Draws part of an image - the [atlas] - onto the canvas. @@ -564,13 +564,13 @@ abstract class Canvas { /// * [drawAtlas], which takes its arguments as objects rather than typed /// data lists. void drawRawAtlas( - Image/*!*/ atlas, - Float32List/*!*/ rstTransforms, - Float32List/*!*/ rects, - Int32List/*!*/ colors, - BlendMode/*!*/ blendMode, - Rect/*?*/ cullRect, - Paint/*!*/ paint, + Image atlas, + Float32List rstTransforms, + Float32List rects, + Int32List colors, + BlendMode blendMode, + Rect? cullRect, + Paint paint, ); /// Draws a shadow for a [Path] representing the given material elevation. @@ -580,10 +580,10 @@ abstract class Canvas { /// /// The arguments must not be null. void drawShadow( - Path/*!*/ path, - Color/*!*/ color, - double/*!*/ elevation, - bool/*!*/ transparentOccluder, + Path path, + Color color, + double elevation, + bool transparentOccluder, ); } @@ -603,7 +603,7 @@ abstract class Picture { /// /// Although the image is returned synchronously, the picture is actually /// rasterized the first time the image is drawn and then cached. - Future/*!*/ toImage(int/*!*/ width, int/*!*/ height); + Future toImage(int width, int height); /// Release the resources used by this object. The object is no longer usable /// after this method is called. @@ -613,7 +613,7 @@ abstract class Picture { /// /// The actual size of this picture may be larger, particularly if it contains /// references to image or other large objects. - int/*!*/ get approximateBytesUsed; + int get approximateBytesUsed; } /// Determines the winding rule that decides how the interior of a [Path] is diff --git a/lib/web_ui/lib/src/ui/channel_buffers.dart b/lib/web_ui/lib/src/ui/channel_buffers.dart index 3b2623ec092f8..5d3db5da5d9d2 100644 --- a/lib/web_ui/lib/src/ui/channel_buffers.dart +++ b/lib/web_ui/lib/src/ui/channel_buffers.dart @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.6 +// @dart = 2.9 part of ui; /// A saved platform message for a channel with its callback. @@ -14,12 +14,12 @@ class _StoredMessage { _StoredMessage(this._data, this._callback); /// Representation of the message's payload. - final ByteData/*?*/ _data; - ByteData/*?*/ get data => _data; + final ByteData? _data; + ByteData? get data => _data; /// Callback to be called when the message is received. - final PlatformMessageResponseCallback/*!*/ _callback; - PlatformMessageResponseCallback/*!*/ get callback => _callback; + final PlatformMessageResponseCallback _callback; + PlatformMessageResponseCallback get callback => _callback; } /// A fixed-size circular queue. @@ -43,7 +43,7 @@ class _RingBuffer { /// A callback that get's called when items are ejected from the [_RingBuffer] /// by way of an overflow or a resizing. - Function(T) _dropItemCallback; + Function(T)? _dropItemCallback; set dropItemCallback(Function(T) callback) { _dropItemCallback = callback; } @@ -60,7 +60,7 @@ class _RingBuffer { } /// Returns null when empty. - T pop() { + T? pop() { return _queue.isEmpty ? null : _queue.removeFirst(); } @@ -70,9 +70,7 @@ class _RingBuffer { int result = 0; while (_queue.length > lengthLimit) { final T item = _queue.removeFirst(); - if (_dropItemCallback != null) { - _dropItemCallback(item); - } + _dropItemCallback?.call(item); result += 1; } return result; @@ -86,7 +84,7 @@ class _RingBuffer { } /// Signature for [ChannelBuffers.drain]. -typedef DrainChannelCallback = Future/*!*/ Function(ByteData/*?*/, PlatformMessageResponseCallback/*!*/); +typedef DrainChannelCallback = Future Function(ByteData?, PlatformMessageResponseCallback); /// Storage of channel messages until the channels are completely routed, /// i.e. when a message handler is attached to the channel on the framework side. @@ -116,8 +114,8 @@ class ChannelBuffers { static const String kControlChannelName = 'dev.flutter/channel-buffers'; /// A mapping between a channel name and its associated [_RingBuffer]. - final Map> _messages = - >{}; + final Map?> _messages = + ?>{}; _RingBuffer<_StoredMessage> _makeRingBuffer(int size) { final _RingBuffer<_StoredMessage> result = _RingBuffer<_StoredMessage>(size); @@ -130,8 +128,8 @@ class ChannelBuffers { } /// Returns true on overflow. - bool/*!*/ push(String/*!*/ channel, ByteData/*?*/ data, PlatformMessageResponseCallback/*!*/ callback) { - _RingBuffer<_StoredMessage> queue = _messages[channel]; + bool push(String channel, ByteData? data, PlatformMessageResponseCallback callback) { + _RingBuffer<_StoredMessage>? queue = _messages[channel]; if (queue == null) { queue = _makeRingBuffer(kDefaultBufferSize); _messages[channel] = queue; @@ -150,14 +148,14 @@ class ChannelBuffers { } /// Returns null on underflow. - _StoredMessage _pop(String channel) { - final _RingBuffer<_StoredMessage> queue = _messages[channel]; - final _StoredMessage result = queue?.pop(); + _StoredMessage? _pop(String channel) { + final _RingBuffer<_StoredMessage>? queue = _messages[channel]; + final _StoredMessage? result = queue?.pop(); return result; } bool _isEmpty(String channel) { - final _RingBuffer<_StoredMessage> queue = _messages[channel]; + final _RingBuffer<_StoredMessage>? queue = _messages[channel]; return (queue == null) ? true : queue.isEmpty; } @@ -166,7 +164,7 @@ class ChannelBuffers { /// This could result in the dropping of messages if newSize is less /// than the current length of the queue. void _resize(String channel, int newSize) { - _RingBuffer<_StoredMessage> queue = _messages[channel]; + _RingBuffer<_StoredMessage>? queue = _messages[channel]; if (queue == null) { queue = _makeRingBuffer(newSize); _messages[channel] = queue; @@ -182,9 +180,9 @@ class ChannelBuffers { /// /// This should be called once a channel is prepared to handle messages /// (i.e. when a message handler is setup in the framework). - Future/*!*/ drain(String/*!*/ channel, DrainChannelCallback/*!*/ callback) async { + Future drain(String channel, DrainChannelCallback callback) async { while (!_isEmpty(channel)) { - final _StoredMessage message = _pop(channel); + final _StoredMessage message = _pop(channel)!; await callback(message.data, message.callback); } } @@ -204,7 +202,7 @@ class ChannelBuffers { /// Arity: 2 /// Format: `resize\r\r` /// Description: Allows you to set the size of a channel's buffer. - void handleMessage(ByteData/*!*/ data) { + void handleMessage(ByteData data) { final List command = _getString(data).split('\r'); if (command.length == /*arity=*/2 + 1 && command[0] == 'resize') { _resize(command[1], int.parse(command[2])); @@ -220,4 +218,4 @@ class ChannelBuffers { /// /// See also: /// * [BinaryMessenger] - The place where ChannelBuffers are typically read. -final ChannelBuffers/*!*/ channelBuffers = ChannelBuffers(); +final ChannelBuffers channelBuffers = ChannelBuffers(); diff --git a/lib/web_ui/lib/src/ui/compositing.dart b/lib/web_ui/lib/src/ui/compositing.dart index 8ef96780b1d85..df903d529957f 100644 --- a/lib/web_ui/lib/src/ui/compositing.dart +++ b/lib/web_ui/lib/src/ui/compositing.dart @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.6 +// @dart = 2.9 part of ui; /// An opaque object representing a composited scene. @@ -14,7 +14,7 @@ part of ui; abstract class Scene { /// Creates a raster image representation of the current state of the scene. /// This is a slow operation that is performed on a background thread. - Future/*!*/ toImage(int width, int height); + Future toImage(int width, int height); /// Releases the resources used by this scene. /// @@ -125,10 +125,10 @@ abstract class SceneBuilder { /// This is equivalent to [pushTransform] with a matrix with only translation. /// /// See [pop] for details about the operation stack. - OffsetEngineLayer/*?*/ pushOffset( - double/*!*/ dx, - double/*!*/ dy, { - OffsetEngineLayer/*?*/ oldLayer, + OffsetEngineLayer? pushOffset( + double dx, + double dy, { + OffsetEngineLayer? oldLayer, }); /// Pushes a transform operation onto the operation stack. @@ -136,9 +136,9 @@ abstract class SceneBuilder { /// The objects are transformed by the given matrix before rasterization. /// /// See [pop] for details about the operation stack. - TransformEngineLayer/*?*/ pushTransform( - Float64List/*!*/ matrix4, { - TransformEngineLayer/*?*/ oldLayer, + TransformEngineLayer? pushTransform( + Float64List matrix4, { + TransformEngineLayer? oldLayer, }); /// Pushes a rectangular clip operation onto the operation stack. @@ -147,10 +147,10 @@ abstract class SceneBuilder { /// /// See [pop] for details about the operation stack, and [Clip] for different clip modes. /// By default, the clip will be anti-aliased (clip = [Clip.antiAlias]). - ClipRectEngineLayer/*?*/ pushClipRect( - Rect/*!*/ rect, { - Clip/*!*/ clipBehavior = Clip.antiAlias, - ClipRectEngineLayer/*?*/ oldLayer, + ClipRectEngineLayer? pushClipRect( + Rect rect, { + Clip clipBehavior = Clip.antiAlias, + ClipRectEngineLayer? oldLayer, }); /// Pushes a rounded-rectangular clip operation onto the operation stack. @@ -158,10 +158,10 @@ abstract class SceneBuilder { /// Rasterization outside the given rounded rectangle is discarded. /// /// See [pop] for details about the operation stack. - ClipRRectEngineLayer/*?*/ pushClipRRect( - RRect/*!*/ rrect, { - Clip/*!*/ clipBehavior, - ClipRRectEngineLayer/*?*/ oldLayer, + ClipRRectEngineLayer? pushClipRRect( + RRect rrect, { + required Clip clipBehavior, + ClipRRectEngineLayer? oldLayer, }); /// Pushes a path clip operation onto the operation stack. @@ -169,10 +169,10 @@ abstract class SceneBuilder { /// Rasterization outside the given path is discarded. /// /// See [pop] for details about the operation stack. - ClipPathEngineLayer/*?*/ pushClipPath( - Path/*!*/ path, { - Clip/*!*/ clipBehavior = Clip.antiAlias, - ClipPathEngineLayer/*?*/ oldLayer, + ClipPathEngineLayer? pushClipPath( + Path path, { + Clip clipBehavior = Clip.antiAlias, + ClipPathEngineLayer? oldLayer, }); /// Pushes an opacity operation onto the operation stack. @@ -183,10 +183,10 @@ abstract class SceneBuilder { /// opacity). /// /// See [pop] for details about the operation stack. - OpacityEngineLayer/*?*/ pushOpacity( - int/*!*/ alpha, { - Offset/*!*/ offset = Offset.zero, - OpacityEngineLayer/*?*/ oldLayer, + OpacityEngineLayer? pushOpacity( + int alpha, { + Offset offset = Offset.zero, + OpacityEngineLayer? oldLayer, }); /// Pushes a color filter operation onto the operation stack. @@ -199,9 +199,9 @@ abstract class SceneBuilder { /// {@macro dart.ui.sceneBuilder.oldLayerVsRetained} /// /// See [pop] for details about the operation stack. - ColorFilterEngineLayer/*?*/ pushColorFilter( - ColorFilter/*!*/ filter, { - ColorFilterEngineLayer/*?*/ oldLayer, + ColorFilterEngineLayer? pushColorFilter( + ColorFilter filter, { + ColorFilterEngineLayer? oldLayer, }); /// Pushes an image filter operation onto the operation stack. @@ -214,9 +214,9 @@ abstract class SceneBuilder { /// {@macro dart.ui.sceneBuilder.oldLayerVsRetained} /// /// See [pop] for details about the operation stack. - ImageFilterEngineLayer/*?*/ pushImageFilter( - ImageFilter/*!*/ filter, { - ImageFilterEngineLayer/*?*/ oldLayer, + ImageFilterEngineLayer? pushImageFilter( + ImageFilter filter, { + ImageFilterEngineLayer? oldLayer, }); /// Pushes a backdrop filter operation onto the operation stack. @@ -225,9 +225,9 @@ abstract class SceneBuilder { /// rasterizing the given objects. /// /// See [pop] for details about the operation stack. - BackdropFilterEngineLayer/*?*/ pushBackdropFilter( - ImageFilter/*!*/ filter, { - BackdropFilterEngineLayer/*?*/ oldLayer, + BackdropFilterEngineLayer? pushBackdropFilter( + ImageFilter filter, { + BackdropFilterEngineLayer? oldLayer, }); /// Pushes a shader mask operation onto the operation stack. @@ -236,11 +236,11 @@ abstract class SceneBuilder { /// rectangle using the given blend mode. /// /// See [pop] for details about the operation stack. - ShaderMaskEngineLayer/*?*/ pushShaderMask( - Shader/*!*/ shader, - Rect/*!*/ maskRect, - BlendMode/*!*/ blendMode, { - ShaderMaskEngineLayer/*?*/ oldLayer, + ShaderMaskEngineLayer? pushShaderMask( + Shader shader, + Rect maskRect, + BlendMode blendMode, { + ShaderMaskEngineLayer? oldLayer, }); /// Pushes a physical layer operation for an arbitrary shape onto the @@ -255,13 +255,13 @@ abstract class SceneBuilder { /// color of the layer background. /// /// See [pop] for details about the operation stack, and [Clip] for different clip modes. - PhysicalShapeEngineLayer/*?*/ pushPhysicalShape({ - Path/*!*/ path, - double/*!*/ elevation, - Color/*!*/ color, - Color/*?*/ shadowColor, - Clip/*!*/ clipBehavior = Clip.none, - PhysicalShapeEngineLayer/*?*/ oldLayer, + PhysicalShapeEngineLayer? pushPhysicalShape({ + required Path path, + required double elevation, + required Color color, + Color? shadowColor, + Clip clipBehavior = Clip.none, + PhysicalShapeEngineLayer? oldLayer, }); /// Add a retained engine layer subtree from previous frames. @@ -272,7 +272,7 @@ abstract class SceneBuilder { /// Therefore, when implementing a subclass of the [Layer] concept defined in /// the rendering layer of Flutter's framework, once this is called, there's /// no need to call [addToScene] for its children layers. - void addRetained(EngineLayer/*!*/ retainedLayer); + void addRetained(EngineLayer retainedLayer); /// Ends the effect of the most recently pushed operation. /// @@ -305,16 +305,16 @@ abstract class SceneBuilder { /// /// See also the [PerformanceOverlayOption] enum in the rendering library. /// for more details. - void addPerformanceOverlay(int/*!*/ enabledOptions, Rect/*!*/ bounds); + void addPerformanceOverlay(int enabledOptions, Rect bounds); /// Adds a [Picture] to the scene. /// /// The picture is rasterized at the given offset. void addPicture( - Offset/*!*/ offset, - Picture/*!*/ picture, { - bool/*!*/ isComplexHint = false, - bool/*!*/ willChangeHint = false, + Offset offset, + Picture picture, { + bool isComplexHint = false, + bool willChangeHint = false, }); /// Adds a backend texture to the scene. @@ -322,11 +322,11 @@ abstract class SceneBuilder { /// The texture is scaled to the given size and rasterized at the given /// offset. void addTexture( - int/*!*/ textureId, { - Offset/*!*/ offset = Offset.zero, - double/*!*/ width = 0.0, - double/*!*/ height = 0.0, - bool/*!*/ freeze = false, + int textureId, { + Offset offset = Offset.zero, + double width = 0.0, + double height = 0.0, + bool freeze = false, }); /// Adds a platform view (e.g an iOS UIView) to the scene. @@ -346,20 +346,20 @@ abstract class SceneBuilder { /// embedded UIView. In addition to that, on iOS versions greater than 9, the Flutter frames are /// synchronized with the UIView frames adding additional performance overhead. void addPlatformView( - int/*!*/ viewId, { - Offset/*!*/ offset = Offset.zero, - double/*!*/ width = 0.0, - double/*!*/ height = 0.0, + int viewId, { + Offset offset = Offset.zero, + double width = 0.0, + double height = 0.0, }); /// (Fuchsia-only) Adds a scene rendered by another application to the scene /// for this application. void addChildScene({ - Offset/*!*/ offset = Offset.zero, - double/*!*/ width = 0.0, - double/*!*/ height = 0.0, - SceneHost/*!*/ sceneHost, - bool/*!*/ hitTestable = true, + Offset offset = Offset.zero, + double width = 0.0, + double height = 0.0, + required SceneHost sceneHost, + bool hitTestable = true, }); /// Sets a threshold after which additional debugging information should be @@ -369,7 +369,7 @@ abstract class SceneBuilder { /// interested in using this feature, please contact [flutter-dev](https://groups.google.com/forum/#!forum/flutter-dev). /// We'll hopefully be able to figure out how to make this feature more useful /// to you. - void setRasterizerTracingThreshold(int/*!*/ frameInterval); + void setRasterizerTracingThreshold(int frameInterval); /// Sets whether the raster cache should checkerboard cached entries. This is /// only useful for debugging purposes. @@ -387,13 +387,13 @@ abstract class SceneBuilder { /// /// Currently this interface is difficult to use by end-developers. If you're /// interested in using this feature, please contact [flutter-dev](https://groups.google.com/forum/#!forum/flutter-dev). - void setCheckerboardRasterCacheImages(bool/*!*/ checkerboard); + void setCheckerboardRasterCacheImages(bool checkerboard); /// Sets whether the compositor should checkerboard layers that are rendered /// to offscreen bitmaps. /// /// This is only useful for debugging purposes. - void setCheckerboardOffscreenLayers(bool/*!*/ checkerboard); + void setCheckerboardOffscreenLayers(bool checkerboard); /// Finishes building the scene. /// @@ -403,18 +403,18 @@ abstract class SceneBuilder { /// /// After calling this function, the scene builder object is invalid and /// cannot be used further. - Scene/*!*/ build(); + Scene build(); /// Set properties on the linked scene. These properties include its bounds, /// as well as whether it can be the target of focus events or not. void setProperties( - double/*!*/ width, - double/*!*/ height, - double/*!*/ insetTop, - double/*!*/ insetRight, - double/*!*/ insetBottom, - double/*!*/ insetLeft, - bool/*!*/ focusable, + double width, + double height, + double insetTop, + double insetRight, + double insetBottom, + double insetLeft, + bool focusable, ); } @@ -436,9 +436,9 @@ class SceneHost { /// The SceneHost takes ownership of the provided ViewHolder token. SceneHost( dynamic viewHolderToken, - void Function()/*!*/ viewConnectedCallback, - void Function()/*!*/ viewDisconnectedCallback, - void Function(bool/*!*/)/*!*/ viewStateChangedCallback, + void Function() viewConnectedCallback, + void Function() viewDisconnectedCallback, + void Function(bool) viewStateChangedCallback, ); /// Releases the resources associated with the SceneHost. @@ -449,13 +449,13 @@ class SceneHost { /// Set properties on the linked scene. These properties include its bounds, /// as well as whether it can be the target of focus events or not. void setProperties( - double/*!*/ width, - double/*!*/ height, - double/*!*/ insetTop, - double/*!*/ insetRight, - double/*!*/ insetBottom, - double/*!*/ insetLeft, - bool/*!*/ focusable, + double width, + double height, + double insetTop, + double insetRight, + double insetBottom, + double insetLeft, + bool focusable, ) { throw UnimplementedError(); } diff --git a/lib/web_ui/lib/src/ui/geometry.dart b/lib/web_ui/lib/src/ui/geometry.dart index 5ed8a48508aa7..5e069c2a8b867 100644 --- a/lib/web_ui/lib/src/ui/geometry.dart +++ b/lib/web_ui/lib/src/ui/geometry.dart @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.6 +// @dart = 2.9 part of ui; /// Base class for [Size] and [Offset], which are both ways to describe @@ -14,11 +14,11 @@ abstract class OffsetBase { /// The first argument sets the horizontal component, and the second the /// vertical component. const OffsetBase(this._dx, this._dy) - : assert(_dx != null), - assert(_dy != null); + : assert(_dx != null), // ignore: unnecessary_null_comparison + assert(_dy != null); // ignore: unnecessary_null_comparison - final double/*!*/ _dx; - final double/*!*/ _dy; + final double _dx; + final double _dy; /// Returns true if either component is [double.infinity], and false if both /// are finite (or negative infinity, or NaN). @@ -29,7 +29,7 @@ abstract class OffsetBase { /// See also: /// /// * [isFinite], which is true if both components are finite (and not NaN). - bool/*!*/ get isInfinite => _dx >= double.infinity || _dy >= double.infinity; + bool get isInfinite => _dx >= double.infinity || _dy >= double.infinity; /// Whether both components are finite (neither infinite nor NaN). /// @@ -37,7 +37,7 @@ abstract class OffsetBase { /// /// * [isInfinite], which returns true if either component is equal to /// positive infinity. - bool/*!*/ get isFinite => _dx.isFinite && _dy.isFinite; + bool get isFinite => _dx.isFinite && _dy.isFinite; /// Less-than operator. Compares an [Offset] or [Size] to another [Offset] or /// [Size], and returns true if both the horizontal and vertical values of the @@ -46,7 +46,7 @@ abstract class OffsetBase { /// /// This is a partial ordering. It is possible for two values to be neither /// less, nor greater than, nor equal to, another. - bool/*!*/ operator <(OffsetBase/*!*/ other) => _dx < other._dx && _dy < other._dy; + bool operator <(OffsetBase other) => _dx < other._dx && _dy < other._dy; /// Less-than-or-equal-to operator. Compares an [Offset] or [Size] to another /// [Offset] or [Size], and returns true if both the horizontal and vertical @@ -56,7 +56,7 @@ abstract class OffsetBase { /// /// This is a partial ordering. It is possible for two values to be neither /// less, nor greater than, nor equal to, another. - bool/*!*/ operator <=(OffsetBase/*!*/ other) => _dx <= other._dx && _dy <= other._dy; + bool operator <=(OffsetBase other) => _dx <= other._dx && _dy <= other._dy; /// Greater-than operator. Compares an [Offset] or [Size] to another [Offset] /// or [Size], and returns true if both the horizontal and vertical values of @@ -66,7 +66,7 @@ abstract class OffsetBase { /// /// This is a partial ordering. It is possible for two values to be neither /// less, nor greater than, nor equal to, another. - bool/*!*/ operator >(OffsetBase/*!*/ other) => _dx > other._dx && _dy > other._dy; + bool operator >(OffsetBase other) => _dx > other._dx && _dy > other._dy; /// Greater-than-or-equal-to operator. Compares an [Offset] or [Size] to /// another [Offset] or [Size], and returns true if both the horizontal and @@ -76,24 +76,24 @@ abstract class OffsetBase { /// /// This is a partial ordering. It is possible for two values to be neither /// less, nor greater than, nor equal to, another. - bool/*!*/ operator >=(OffsetBase/*!*/ other) => _dx >= other._dx && _dy >= other._dy; + bool operator >=(OffsetBase other) => _dx >= other._dx && _dy >= other._dy; /// Equality operator. Compares an [Offset] or [Size] to another [Offset] or /// [Size], and returns true if the horizontal and vertical values of the /// left-hand-side operand are equal to the horizontal and vertical values of /// the right-hand-side operand respectively. Returns false otherwise. @override - bool/*!*/ operator ==(dynamic other) { + bool operator ==(dynamic other) { return other is OffsetBase && other._dx == _dx && other._dy == _dy; } @override - int/*!*/ get hashCode => hashValues(_dx, _dy); + int get hashCode => hashValues(_dx, _dy); @override - String/*!*/ toString() => 'OffsetBase(${_dx.toStringAsFixed(1)}, ${_dy.toStringAsFixed(1)})'; + String toString() => 'OffsetBase(${_dx.toStringAsFixed(1)}, ${_dy.toStringAsFixed(1)})'; } /// An immutable 2D floating-point offset. @@ -120,37 +120,37 @@ abstract class OffsetBase { class Offset extends OffsetBase { /// Creates an offset. The first argument sets [dx], the horizontal component, /// and the second sets [dy], the vertical component. - const Offset(double/*!*/ dx, double/*!*/ dy) : super(dx, dy); + const Offset(double dx, double dy) : super(dx, dy); /// Creates an offset from its [direction] and [distance]. /// /// The direction is in radians clockwise from the positive x-axis. /// /// The distance can be omitted, to create a unit vector (distance = 1.0). - factory Offset.fromDirection(double/*!*/ direction, [ double/*!*/ distance = 1.0 ]) { + factory Offset.fromDirection(double direction, [ double distance = 1.0 ]) { return Offset(distance * math.cos(direction), distance * math.sin(direction)); } /// The x component of the offset. /// /// The y component is given by [dy]. - double/*!*/ get dx => _dx; + double get dx => _dx; /// The y component of the offset. /// /// The x component is given by [dx]. - double/*!*/ get dy => _dy; + double get dy => _dy; /// The magnitude of the offset. /// /// If you need this value to compare it to another [Offset]'s distance, /// consider using [distanceSquared] instead, since it is cheaper to compute. - double/*!*/ get distance => math.sqrt(dx * dx + dy * dy); + double get distance => math.sqrt(dx * dx + dy * dy); /// The square of the magnitude of the offset. /// /// This is cheaper than computing the [distance] itself. - double/*!*/ get distanceSquared => dx * dx + dy * dy; + double get distanceSquared => dx * dx + dy * dy; /// The angle of this offset as radians clockwise from the positive x-axis, in /// the range -[pi] to [pi], assuming positive values of the x-axis go to the @@ -179,7 +179,7 @@ class Offset extends OffsetBase { /// /// * [distance], to compute the magnitude of the vector. /// * [Canvas.rotate], which uses the same convention for its angle. - double/*!*/ get direction => math.atan2(dy, dx); + double get direction => math.atan2(dy, dx); /// An offset with zero magnitude. /// @@ -213,7 +213,7 @@ class Offset extends OffsetBase { /// Offset a = const Offset(10.0, 10.0); /// Offset b = -a; // same as: a.scale(-1.0, -1.0) /// ``` - Offset/*!*/ scale(double/*!*/ scaleX, double/*!*/ scaleY) => Offset(dx * scaleX, dy * scaleY); + Offset scale(double scaleX, double scaleY) => Offset(dx * scaleX, dy * scaleY); /// Returns a new offset with translateX added to the x component and /// translateY added to the y component. @@ -227,7 +227,7 @@ class Offset extends OffsetBase { /// Offset c = a + b; // same as: a.translate(b.dx, b.dy) /// Offset d = a - b; // same as: a.translate(-b.dx, -b.dy) /// ``` - Offset/*!*/ translate(double/*!*/ translateX, double/*!*/ translateY) => Offset(dx + translateX, dy + translateY); + Offset translate(double translateX, double translateY) => Offset(dx + translateX, dy + translateY); /// Unary negation operator. /// @@ -235,7 +235,7 @@ class Offset extends OffsetBase { /// /// If the [Offset] represents an arrow on a plane, this operator returns the /// same arrow but pointing in the reverse direction. - Offset/*!*/ operator -() => Offset(-dx, -dy); + Offset operator -() => Offset(-dx, -dy); /// Binary subtraction operator. /// @@ -244,7 +244,7 @@ class Offset extends OffsetBase { /// left-hand-side operand's [dy] minus the right-hand-side operand's [dy]. /// /// See also [translate]. - Offset/*!*/ operator -(Offset/*!*/ other) => Offset(dx - other.dx, dy - other.dy); + Offset operator -(Offset other) => Offset(dx - other.dx, dy - other.dy); /// Binary addition operator. /// @@ -253,7 +253,7 @@ class Offset extends OffsetBase { /// two operands. /// /// See also [translate]. - Offset/*!*/ operator +(Offset/*!*/ other) => Offset(dx + other.dx, dy + other.dy); + Offset operator +(Offset other) => Offset(dx + other.dx, dy + other.dy); /// Multiplication operator. /// @@ -262,7 +262,7 @@ class Offset extends OffsetBase { /// right-hand-side operand (a double). /// /// See also [scale]. - Offset/*!*/ operator *(double/*!*/ operand) => Offset(dx * operand, dy * operand); + Offset operator *(double operand) => Offset(dx * operand, dy * operand); /// Division operator. /// @@ -271,21 +271,21 @@ class Offset extends OffsetBase { /// operand (a double). /// /// See also [scale]. - Offset/*!*/ operator /(double/*!*/ operand) => Offset(dx / operand, dy / operand); + Offset operator /(double operand) => Offset(dx / operand, dy / operand); /// Integer (truncating) division operator. /// /// Returns an offset whose coordinates are the coordinates of the /// left-hand-side operand (an Offset) divided by the scalar right-hand-side /// operand (a double), rounded towards zero. - Offset/*!*/ operator ~/(double/*!*/ operand) => Offset((dx ~/ operand).toDouble(), (dy ~/ operand).toDouble()); + Offset operator ~/(double operand) => Offset((dx ~/ operand).toDouble(), (dy ~/ operand).toDouble()); /// Modulo (remainder) operator. /// /// Returns an offset whose coordinates are the remainder of dividing the /// coordinates of the left-hand-side operand (an Offset) by the scalar /// right-hand-side operand (a double). - Offset/*!*/ operator %(double/*!*/ operand) => Offset(dx % operand, dy % operand); + Offset operator %(double operand) => Offset(dx % operand, dy % operand); /// Rectangle constructor operator. /// @@ -297,7 +297,7 @@ class Offset extends OffsetBase { /// Rect myRect = Offset.zero & const Size(100.0, 100.0); /// // same as: Rect.fromLTWH(0.0, 0.0, 100.0, 100.0) /// ``` - Rect/*!*/ operator &(Size/*!*/ other) => Rect.fromLTWH(dx, dy, other.width, other.height); + Rect operator &(Size other) => Rect.fromLTWH(dx, dy, other.width, other.height); /// Linearly interpolate between two offsets. /// @@ -314,8 +314,8 @@ class Offset extends OffsetBase { /// /// Values for `t` are usually obtained from an [Animation], such as /// an [AnimationController]. - static Offset/*?*/ lerp(Offset/*?*/ a, Offset/*?*/ b, double/*!*/ t) { - assert(t != null); + static Offset? lerp(Offset? a, Offset? b, double t) { + assert(t != null); // ignore: unnecessary_null_comparison if (b == null) { if (a == null) { return null; @@ -333,17 +333,17 @@ class Offset extends OffsetBase { /// Compares two Offsets for equality. @override - bool/*!*/ operator ==(dynamic other) { + bool operator ==(dynamic other) { return other is Offset && other.dx == dx && other.dy == dy; } @override - int/*!*/ get hashCode => hashValues(dx, dy); + int get hashCode => hashValues(dx, dy); @override - String/*!*/ toString() => 'Offset(${dx.toStringAsFixed(1)}, ${dy.toStringAsFixed(1)})'; + String toString() => 'Offset(${dx.toStringAsFixed(1)}, ${dy.toStringAsFixed(1)})'; } /// Holds a 2D floating-point size. @@ -351,11 +351,11 @@ class Offset extends OffsetBase { /// You can think of this as an [Offset] from the origin. class Size extends OffsetBase { /// Creates a [Size] with the given [width] and [height]. - const Size(double/*!*/ width, double/*!*/ height) : super(width, height); + const Size(double width, double height) : super(width, height); /// Creates an instance of [Size] that has the same values as another. // Used by the rendering library's _DebugSize hack. - Size.copy(Size/*!*/ source) : super(source.width, source.height); + Size.copy(Size source) : super(source.width, source.height); /// Creates a square [Size] whose [width] and [height] are the given dimension. /// @@ -363,13 +363,13 @@ class Size extends OffsetBase { /// /// * [Size.fromRadius], which is more convenient when the available size /// is the radius of a circle. - const Size.square(double/*!*/ dimension) : super(dimension, dimension); + const Size.square(double dimension) : super(dimension, dimension); /// Creates a [Size] with the given [width] and an infinite [height]. - const Size.fromWidth(double/*!*/ width) : super(width, double.infinity); + const Size.fromWidth(double width) : super(width, double.infinity); /// Creates a [Size] with the given [height] and an infinite [width]. - const Size.fromHeight(double/*!*/ height) : super(double.infinity, height); + const Size.fromHeight(double height) : super(double.infinity, height); /// Creates a square [Size] whose [width] and [height] are twice the given /// dimension. @@ -379,13 +379,13 @@ class Size extends OffsetBase { /// See also: /// /// * [Size.square], which creates a square with the given dimension. - const Size.fromRadius(double/*!*/ radius) : super(radius * 2.0, radius * 2.0); + const Size.fromRadius(double radius) : super(radius * 2.0, radius * 2.0); /// The horizontal extent of this size. - double/*!*/ get width => _dx; + double get width => _dx; /// The vertical extent of this size. - double/*!*/ get height => _dy; + double get height => _dy; /// The aspect ratio of this size. /// @@ -401,7 +401,7 @@ class Size extends OffsetBase { /// ratio. /// * [FittedBox], a widget that (in most modes) attempts to maintain a /// child widget's aspect ratio while changing its size. - double/*!*/ get aspectRatio { + double get aspectRatio { if (height != 0.0) return width / height; if (width > 0.0) @@ -425,7 +425,7 @@ class Size extends OffsetBase { /// Whether this size encloses a non-zero area. /// /// Negative areas are considered empty. - bool/*!*/ get isEmpty => width <= 0.0 || height <= 0.0; + bool get isEmpty => width <= 0.0 || height <= 0.0; /// Binary subtraction operator for [Size]. /// @@ -443,7 +443,7 @@ class Size extends OffsetBase { /// right-hand-side operand, and a [height] consisting of the [height] of the /// left-hand-side operand minus the [Offset.dy] dimension of the /// right-hand-side operand. - OffsetBase/*!*/ operator -(OffsetBase/*!*/ other) { + OffsetBase operator -(OffsetBase other) { if (other is Size) return Offset(width - other.width, height - other.height); if (other is Offset) @@ -458,41 +458,41 @@ class Size extends OffsetBase { /// right-hand-side operand, an [Offset], and whose [height] is the sum of the /// [height] of the left-hand-side operand and the [Offset.dy] dimension of /// the right-hand-side operand. - Size/*!*/ operator +(Offset/*!*/ other) => Size(width + other.dx, height + other.dy); + Size operator +(Offset other) => Size(width + other.dx, height + other.dy); /// Multiplication operator. /// /// Returns a [Size] whose dimensions are the dimensions of the left-hand-side /// operand (a [Size]) multiplied by the scalar right-hand-side operand (a /// [double]). - Size/*!*/ operator *(double/*!*/ operand) => Size(width * operand, height * operand); + Size operator *(double operand) => Size(width * operand, height * operand); /// Division operator. /// /// Returns a [Size] whose dimensions are the dimensions of the left-hand-side /// operand (a [Size]) divided by the scalar right-hand-side operand (a /// [double]). - Size/*!*/ operator /(double/*!*/ operand) => Size(width / operand, height / operand); + Size operator /(double operand) => Size(width / operand, height / operand); /// Integer (truncating) division operator. /// /// Returns a [Size] whose dimensions are the dimensions of the left-hand-side /// operand (a [Size]) divided by the scalar right-hand-side operand (a /// [double]), rounded towards zero. - Size/*!*/ operator ~/(double/*!*/ operand) => Size((width ~/ operand).toDouble(), (height ~/ operand).toDouble()); + Size operator ~/(double operand) => Size((width ~/ operand).toDouble(), (height ~/ operand).toDouble()); /// Modulo (remainder) operator. /// /// Returns a [Size] whose dimensions are the remainder of dividing the /// left-hand-side operand (a [Size]) by the scalar right-hand-side operand (a /// [double]). - Size/*!*/ operator %(double/*!*/ operand) => Size(width % operand, height % operand); + Size operator %(double operand) => Size(width % operand, height % operand); /// The lesser of the magnitudes of the [width] and the [height]. - double/*!*/ get shortestSide => math.min(width.abs(), height.abs()); + double get shortestSide => math.min(width.abs(), height.abs()); /// The greater of the magnitudes of the [width] and the [height]. - double/*!*/ get longestSide => math.max(width.abs(), height.abs()); + double get longestSide => math.max(width.abs(), height.abs()); // Convenience methods that do the equivalent of calling the similarly named // methods on a Rect constructed from the given origin and this size. @@ -502,60 +502,60 @@ class Size extends OffsetBase { /// and this [Size]. /// /// See also [Rect.topLeft]. - Offset/*!*/ topLeft(Offset/*!*/ origin) => origin; + Offset topLeft(Offset origin) => origin; /// The offset to the center of the top edge of the rectangle described by the /// given offset (which is interpreted as the top-left corner) and this size. /// /// See also [Rect.topCenter]. - Offset/*!*/ topCenter(Offset origin) => Offset(origin.dx + width / 2.0, origin.dy); + Offset topCenter(Offset origin) => Offset(origin.dx + width / 2.0, origin.dy); /// The offset to the intersection of the top and right edges of the rectangle /// described by the given offset (which is interpreted as the top-left corner) /// and this size. /// /// See also [Rect.topRight]. - Offset/*!*/ topRight(Offset/*!*/ origin) => Offset(origin.dx + width, origin.dy); + Offset topRight(Offset origin) => Offset(origin.dx + width, origin.dy); /// The offset to the center of the left edge of the rectangle described by the /// given offset (which is interpreted as the top-left corner) and this size. /// /// See also [Rect.centerLeft]. - Offset/*!*/ centerLeft(Offset/*!*/ origin) => Offset(origin.dx, origin.dy + height / 2.0); + Offset centerLeft(Offset origin) => Offset(origin.dx, origin.dy + height / 2.0); /// The offset to the point halfway between the left and right and the top and /// bottom edges of the rectangle described by the given offset (which is /// interpreted as the top-left corner) and this size. /// /// See also [Rect.center]. - Offset/*!*/ center(Offset/*!*/ origin) => Offset(origin.dx + width / 2.0, origin.dy + height / 2.0); + Offset center(Offset origin) => Offset(origin.dx + width / 2.0, origin.dy + height / 2.0); /// The offset to the center of the right edge of the rectangle described by the /// given offset (which is interpreted as the top-left corner) and this size. /// /// See also [Rect.centerLeft]. - Offset/*!*/ centerRight(Offset/*!*/ origin) => Offset(origin.dx + width, origin.dy + height / 2.0); + Offset centerRight(Offset origin) => Offset(origin.dx + width, origin.dy + height / 2.0); /// The offset to the intersection of the bottom and left edges of the /// rectangle described by the given offset (which is interpreted as the /// top-left corner) and this size. /// /// See also [Rect.bottomLeft]. - Offset/*!*/ bottomLeft(Offset/*!*/ origin) => Offset(origin.dx, origin.dy + height); + Offset bottomLeft(Offset origin) => Offset(origin.dx, origin.dy + height); /// The offset to the center of the bottom edge of the rectangle described by /// the given offset (which is interpreted as the top-left corner) and this /// size. /// /// See also [Rect.bottomLeft]. - Offset/*!*/ bottomCenter(Offset/*!*/ origin) => Offset(origin.dx + width / 2.0, origin.dy + height); + Offset bottomCenter(Offset origin) => Offset(origin.dx + width / 2.0, origin.dy + height); /// The offset to the intersection of the bottom and right edges of the /// rectangle described by the given offset (which is interpreted as the /// top-left corner) and this size. /// /// See also [Rect.bottomRight]. - Offset/*!*/ bottomRight(Offset/*!*/ origin) => Offset(origin.dx + width, origin.dy + height); + Offset bottomRight(Offset origin) => Offset(origin.dx + width, origin.dy + height); /// Whether the point specified by the given offset (which is assumed to be /// relative to the top left of the size) lies between the left and right and @@ -563,12 +563,12 @@ class Size extends OffsetBase { /// /// Rectangles include their top and left edges but exclude their bottom and /// right edges. - bool/*!*/ contains(Offset/*!*/ offset) { + bool contains(Offset offset) { return offset.dx >= 0.0 && offset.dx < width && offset.dy >= 0.0 && offset.dy < height; } /// A [Size] with the [width] and [height] swapped. - Size/*!*/ get flipped => Size(height, width); + Size get flipped => Size(height, width); /// Linearly interpolate between two sizes /// @@ -585,8 +585,8 @@ class Size extends OffsetBase { /// /// Values for `t` are usually obtained from an [Animation], such as /// an [AnimationController]. - static Size/*?*/ lerp(Size/*?*/ a, Size/*?*/ b, double/*!*/ t) { - assert(t != null); + static Size? lerp(Size? a, Size? b, double t) { + assert(t != null); // ignore: unnecessary_null_comparison if (b == null) { if (a == null) { return null; @@ -605,17 +605,17 @@ class Size extends OffsetBase { /// Compares two Sizes for equality. // We don't compare the runtimeType because of _DebugSize in the framework. @override - bool/*!*/ operator ==(dynamic other) { + bool operator ==(dynamic other) { return other is Size && other._dx == _dx && other._dy == _dy; } @override - int/*!*/ get hashCode => hashValues(_dx, _dy); + int get hashCode => hashValues(_dx, _dy); @override - String/*!*/ toString() => 'Size(${width.toStringAsFixed(1)}, ${height.toStringAsFixed(1)})'; + String toString() => 'Size(${width.toStringAsFixed(1)}, ${height.toStringAsFixed(1)})'; } /// An immutable, 2D, axis-aligned, floating-point rectangle whose coordinates @@ -630,22 +630,22 @@ class Size extends OffsetBase { class Rect { /// Construct a rectangle from its left, top, right, and bottom edges. const Rect.fromLTRB(this.left, this.top, this.right, this.bottom) - : assert(left != null), - assert(top != null), - assert(right != null), - assert(bottom != null); + : assert(left != null), // ignore: unnecessary_null_comparison + assert(top != null), // ignore: unnecessary_null_comparison + assert(right != null), // ignore: unnecessary_null_comparison + assert(bottom != null); // ignore: unnecessary_null_comparison /// Construct a rectangle from its left and top edges, its width, and its /// height. /// /// To construct a [Rect] from an [Offset] and a [Size], you can use the /// rectangle constructor operator `&`. See [Offset.&]. - const Rect.fromLTWH(double/*!*/ left, double/*!*/ top, double/*!*/ width, double/*!*/ height) : this.fromLTRB(left, top, left + width, top + height); + const Rect.fromLTWH(double left, double top, double width, double height) : this.fromLTRB(left, top, left + width, top + height); /// Construct a rectangle that bounds the given circle. /// /// The `center` argument is assumed to be an offset from the origin. - Rect.fromCircle({ Offset/*!*/ center, double/*!*/ radius }) : this.fromCenter( + Rect.fromCircle({ required Offset center, required double radius }) : this.fromCenter( center: center, width: radius * 2, height: radius * 2, @@ -654,7 +654,7 @@ class Rect { /// Constructs a rectangle from its center point, width, and height. /// /// The `center` argument is assumed to be an offset from the origin. - Rect.fromCenter({ Offset center/*!*/, double/*!*/ width, double/*!*/ height }) : this.fromLTRB( + Rect.fromCenter({ required Offset center, required double width, required double height }) : this.fromLTRB( center.dx - width / 2, center.dy - height / 2, center.dx + width / 2, @@ -663,7 +663,7 @@ class Rect { /// Construct the smallest rectangle that encloses the given offsets, treating /// them as vectors from the origin. - Rect.fromPoints(Offset/*!*/ a, Offset/*!*/ b) : this.fromLTRB( + Rect.fromPoints(Offset a, Offset b) : this.fromLTRB( math.min(a.dx, b.dx), math.min(a.dy, b.dy), math.max(a.dx, b.dx), @@ -671,29 +671,29 @@ class Rect { ); /// The offset of the left edge of this rectangle from the x axis. - final double/*!*/ left; + final double left; /// The offset of the top edge of this rectangle from the y axis. - final double/*!*/ top; + final double top; /// The offset of the right edge of this rectangle from the x axis. - final double/*!*/ right; + final double right; /// The offset of the bottom edge of this rectangle from the y axis. - final double/*!*/ bottom; + final double bottom; /// The distance between the left and right edges of this rectangle. - double/*!*/ get width => right - left; + double get width => right - left; /// The distance between the top and bottom edges of this rectangle. - double/*!*/ get height => bottom - top; + double get height => bottom - top; /// The distance between the upper-left corner and the lower-right corner of /// this rectangle. - Size/*!*/ get size => Size(width, height); + Size get size => Size(width, height); /// Whether any of the dimensions are `NaN`. - bool/*!*/ get hasNaN => left.isNaN || top.isNaN || right.isNaN || bottom.isNaN; + bool get hasNaN => left.isNaN || top.isNaN || right.isNaN || bottom.isNaN; /// A rectangle with left, top, right, and bottom edges all at zero. static const Rect zero = Rect.fromLTRB(0.0, 0.0, 0.0, 0.0); @@ -708,7 +708,7 @@ class Rect { /// Whether any of the coordinates of this rectangle are equal to positive infinity. // included for consistency with Offset and Size - bool/*!*/ get isInfinite { + bool get isInfinite { return left >= double.infinity || top >= double.infinity || right >= double.infinity @@ -716,17 +716,17 @@ class Rect { } /// Whether all coordinates of this rectangle are finite. - bool/*!*/ get isFinite => left.isFinite && top.isFinite && right.isFinite && bottom.isFinite; + bool get isFinite => left.isFinite && top.isFinite && right.isFinite && bottom.isFinite; /// Whether this rectangle encloses a non-zero area. Negative areas are /// considered empty. - bool/*!*/ get isEmpty => left >= right || top >= bottom; + bool get isEmpty => left >= right || top >= bottom; /// Returns a new rectangle translated by the given offset. /// /// To translate a rectangle by separate x and y components rather than by an /// [Offset], consider [translate]. - Rect/*!*/ shift(Offset/*!*/ offset) { + Rect shift(Offset offset) { return Rect.fromLTRB(left + offset.dx, top + offset.dy, right + offset.dx, bottom + offset.dy); } @@ -735,23 +735,23 @@ class Rect { /// /// To translate a rectangle by an [Offset] rather than by separate x and y /// components, consider [shift]. - Rect/*!*/ translate(double/*!*/ translateX, double/*!*/ translateY) { + Rect translate(double translateX, double translateY) { return Rect.fromLTRB(left + translateX, top + translateY, right + translateX, bottom + translateY); } /// Returns a new rectangle with edges moved outwards by the given delta. - Rect/*!*/ inflate(double/*!*/ delta) { + Rect inflate(double delta) { return Rect.fromLTRB(left - delta, top - delta, right + delta, bottom + delta); } /// Returns a new rectangle with edges moved inwards by the given delta. - Rect/*!*/ deflate(double/*!*/ delta) => inflate(-delta); + Rect deflate(double delta) => inflate(-delta); /// Returns a new rectangle that is the intersection of the given /// rectangle and this rectangle. The two rectangles must overlap /// for this to be meaningful. If the two rectangles do not overlap, /// then the resulting Rect will have a negative width or height. - Rect/*!*/ intersect(Rect/*!*/ other) { + Rect intersect(Rect other) { return Rect.fromLTRB( math.max(left, other.left), math.max(top, other.top), @@ -762,7 +762,7 @@ class Rect { /// Returns a new rectangle which is the bounding box containing this /// rectangle and the given rectangle. - Rect/*!*/ expandToInclude(Rect/*!*/ other) { + Rect expandToInclude(Rect other) { return Rect.fromLTRB( math.min(left, other.left), math.min(top, other.top), @@ -772,7 +772,7 @@ class Rect { } /// Whether `other` has a nonzero area of overlap with this rectangle. - bool/*!*/ overlaps(Rect/*!*/ other) { + bool overlaps(Rect other) { if (right <= other.left || other.right <= left) return false; if (bottom <= other.top || other.bottom <= top) @@ -782,57 +782,57 @@ class Rect { /// The lesser of the magnitudes of the [width] and the [height] of this /// rectangle. - double/*!*/ get shortestSide => math.min(width.abs(), height.abs()); + double get shortestSide => math.min(width.abs(), height.abs()); /// The greater of the magnitudes of the [width] and the [height] of this /// rectangle. - double/*!*/ get longestSide => math.max(width.abs(), height.abs()); + double get longestSide => math.max(width.abs(), height.abs()); /// The offset to the intersection of the top and left edges of this rectangle. /// /// See also [Size.topLeft]. - Offset/*!*/ get topLeft => Offset(left, top); + Offset get topLeft => Offset(left, top); /// The offset to the center of the top edge of this rectangle. /// /// See also [Size.topCenter]. - Offset/*!*/ get topCenter => Offset(left + width / 2.0, top); + Offset get topCenter => Offset(left + width / 2.0, top); /// The offset to the intersection of the top and right edges of this rectangle. /// /// See also [Size.topRight]. - Offset/*!*/ get topRight => Offset(right, top); + Offset get topRight => Offset(right, top); /// The offset to the center of the left edge of this rectangle. /// /// See also [Size.centerLeft]. - Offset/*!*/ get centerLeft => Offset(left, top + height / 2.0); + Offset get centerLeft => Offset(left, top + height / 2.0); /// The offset to the point halfway between the left and right and the top and /// bottom edges of this rectangle. /// /// See also [Size.center]. - Offset/*!*/ get center => Offset(left + width / 2.0, top + height / 2.0); + Offset get center => Offset(left + width / 2.0, top + height / 2.0); /// The offset to the center of the right edge of this rectangle. /// /// See also [Size.centerLeft]. - Offset/*!*/ get centerRight => Offset(right, top + height / 2.0); + Offset get centerRight => Offset(right, top + height / 2.0); /// The offset to the intersection of the bottom and left edges of this rectangle. /// /// See also [Size.bottomLeft]. - Offset/*!*/ get bottomLeft => Offset(left, bottom); + Offset get bottomLeft => Offset(left, bottom); /// The offset to the center of the bottom edge of this rectangle. /// /// See also [Size.bottomLeft]. - Offset/*!*/ get bottomCenter => Offset(left + width / 2.0, bottom); + Offset get bottomCenter => Offset(left + width / 2.0, bottom); /// The offset to the intersection of the bottom and right edges of this rectangle. /// /// See also [Size.bottomRight]. - Offset/*!*/ get bottomRight => Offset(right, bottom); + Offset get bottomRight => Offset(right, bottom); /// Whether the point specified by the given offset (which is assumed to be /// relative to the origin) lies between the left and right and the top and @@ -840,7 +840,7 @@ class Rect { /// /// Rectangles include their top and left edges but exclude their bottom and /// right edges. - bool/*!*/ contains(Offset/*!*/ offset) { + bool contains(Offset offset) { return offset.dx >= left && offset.dx < right && offset.dy >= top && offset.dy < bottom; } @@ -859,8 +859,8 @@ class Rect { /// /// Values for `t` are usually obtained from an [Animation], such as /// an [AnimationController]. - static Rect/*?*/ lerp(Rect/*?*/ a, Rect/*?*/ b, double/*!*/ t) { - assert(t != null); + static Rect? lerp(Rect? a, Rect? b, double t) { + assert(t != null); // ignore: unnecessary_null_comparison if (b == null) { if (a == null) { return null; @@ -883,7 +883,7 @@ class Rect { } @override - bool/*!*/ operator ==(dynamic other) { + bool operator ==(dynamic other) { if (identical(this, other)) return true; if (runtimeType != other.runtimeType) @@ -896,25 +896,25 @@ class Rect { } @override - int/*!*/ get hashCode => hashValues(left, top, right, bottom); + int get hashCode => hashValues(left, top, right, bottom); @override - String/*!*/ toString() => 'Rect.fromLTRB(${left.toStringAsFixed(1)}, ${top.toStringAsFixed(1)}, ${right.toStringAsFixed(1)}, ${bottom.toStringAsFixed(1)})'; + String toString() => 'Rect.fromLTRB(${left.toStringAsFixed(1)}, ${top.toStringAsFixed(1)}, ${right.toStringAsFixed(1)}, ${bottom.toStringAsFixed(1)})'; } /// A radius for either circular or elliptical shapes. class Radius { /// Constructs a circular radius. [x] and [y] will have the same radius value. - const Radius.circular(double/*!*/ radius) : this.elliptical(radius, radius); + const Radius.circular(double radius) : this.elliptical(radius, radius); /// Constructs an elliptical radius with the given radii. const Radius.elliptical(this.x, this.y); /// The radius value on the horizontal axis. - final double/*!*/ x; + final double x; /// The radius value on the vertical axis. - final double/*!*/ y; + final double y; /// A radius with [x] and [y] values set to zero. /// @@ -929,49 +929,49 @@ class Radius { /// occur as part of expressions. For example, negating a radius of one pixel /// and then adding the result to another radius is equivalent to subtracting /// a radius of one pixel from the other. - Radius/*!*/ operator -() => Radius.elliptical(-x, -y); + Radius operator -() => Radius.elliptical(-x, -y); /// Binary subtraction operator. /// /// Returns a radius whose [x] value is the left-hand-side operand's [x] /// minus the right-hand-side operand's [x] and whose [y] value is the /// left-hand-side operand's [y] minus the right-hand-side operand's [y]. - Radius/*!*/ operator -(Radius/*!*/ other) => Radius.elliptical(x - other.x, y - other.y); + Radius operator -(Radius other) => Radius.elliptical(x - other.x, y - other.y); /// Binary addition operator. /// /// Returns a radius whose [x] value is the sum of the [x] values of the /// two operands, and whose [y] value is the sum of the [y] values of the /// two operands. - Radius/*!*/ operator +(Radius/*!*/ other) => Radius.elliptical(x + other.x, y + other.y); + Radius operator +(Radius other) => Radius.elliptical(x + other.x, y + other.y); /// Multiplication operator. /// /// Returns a radius whose coordinates are the coordinates of the /// left-hand-side operand (a radius) multiplied by the scalar /// right-hand-side operand (a double). - Radius/*!*/ operator *(double/*!*/ operand) => Radius.elliptical(x * operand, y * operand); + Radius operator *(double operand) => Radius.elliptical(x * operand, y * operand); /// Division operator. /// /// Returns a radius whose coordinates are the coordinates of the /// left-hand-side operand (a radius) divided by the scalar right-hand-side /// operand (a double). - Radius/*!*/ operator /(double/*!*/ operand) => Radius.elliptical(x / operand, y / operand); + Radius operator /(double operand) => Radius.elliptical(x / operand, y / operand); /// Integer (truncating) division operator. /// /// Returns a radius whose coordinates are the coordinates of the /// left-hand-side operand (a radius) divided by the scalar right-hand-side /// operand (a double), rounded towards zero. - Radius/*!*/ operator ~/(double/*!*/ operand) => Radius.elliptical((x ~/ operand).toDouble(), (y ~/ operand).toDouble()); + Radius operator ~/(double operand) => Radius.elliptical((x ~/ operand).toDouble(), (y ~/ operand).toDouble()); /// Modulo (remainder) operator. /// /// Returns a radius whose coordinates are the remainder of dividing the /// coordinates of the left-hand-side operand (a radius) by the scalar /// right-hand-side operand (a double). - Radius/*!*/ operator %(double/*!*/ operand) => Radius.elliptical(x % operand, y % operand); + Radius operator %(double operand) => Radius.elliptical(x % operand, y % operand); /// Linearly interpolate between two radii. /// @@ -988,8 +988,8 @@ class Radius { /// /// Values for `t` are usually obtained from an [Animation], such as /// an [AnimationController]. - static Radius/*?*/ lerp(Radius/*?*/ a, Radius/*?*/ b, double/*!*/ t) { - assert(t != null); + static Radius? lerp(Radius? a, Radius? b, double t) { + assert(t != null); // ignore: unnecessary_null_comparison if (b == null) { if (a == null) { return null; @@ -1010,7 +1010,7 @@ class Radius { } @override - bool/*!*/ operator ==(dynamic other) { + bool operator ==(dynamic other) { if (identical(this, other)) return true; if (runtimeType != other.runtimeType) @@ -1022,10 +1022,10 @@ class Radius { } @override - int/*!*/ get hashCode => hashValues(x, y); + int get hashCode => hashValues(x, y); @override - String/*!*/ toString() { + String toString() { return x == y ? 'Radius.circular(${x.toStringAsFixed(1)})' : 'Radius.elliptical(${x.toStringAsFixed(1)}, ' '${y.toStringAsFixed(1)})'; @@ -1036,8 +1036,8 @@ class Radius { class RRect { /// Construct a rounded rectangle from its left, top, right, and bottom edges, /// and the same radii along its horizontal axis and its vertical axis. - const RRect.fromLTRBXY(double/*!*/ left, double/*!*/ top, double/*!*/ right, double/*!*/ bottom, - double/*!*/ radiusX, double/*!*/ radiusY) : this._raw( + const RRect.fromLTRBXY(double left, double top, double right, double bottom, + double radiusX, double radiusY) : this._raw( top: top, left: left, right: right, @@ -1055,8 +1055,8 @@ class RRect { /// Construct a rounded rectangle from its left, top, right, and bottom edges, /// and the same radius in each corner. - RRect.fromLTRBR(double/*!*/ left, double/*!*/ top, double/*!*/ right, double/*!*/ bottom, - Radius/*!*/ radius) + RRect.fromLTRBR(double left, double top, double right, double bottom, + Radius radius) : this._raw( top: top, left: left, @@ -1075,7 +1075,7 @@ class RRect { /// Construct a rounded rectangle from its bounding box and the same radii /// along its horizontal axis and its vertical axis. - RRect.fromRectXY(Rect/*!*/ rect, double/*!*/ radiusX, double/*!*/ radiusY) + RRect.fromRectXY(Rect rect, double radiusX, double radiusY) : this._raw( top: rect.top, left: rect.left, @@ -1094,7 +1094,7 @@ class RRect { /// Construct a rounded rectangle from its bounding box and a radius that is /// the same in each corner. - RRect.fromRectAndRadius(Rect/*!*/ rect, Radius/*!*/ radius) + RRect.fromRectAndRadius(Rect rect, Radius radius) : this._raw( top: rect.top, left: rect.left, @@ -1116,14 +1116,14 @@ class RRect { /// /// The corner radii default to [Radius.zero], i.e. right-angled corners. RRect.fromLTRBAndCorners( - double/*!*/ left, - double/*!*/ top, - double/*!*/ right, - double/*!*/ bottom, { - Radius/*!*/ topLeft = Radius.zero, - Radius/*!*/ topRight = Radius.zero, - Radius/*!*/ bottomRight = Radius.zero, - Radius/*!*/ bottomLeft = Radius.zero, + double left, + double top, + double right, + double bottom, { + Radius topLeft = Radius.zero, + Radius topRight = Radius.zero, + Radius bottomRight = Radius.zero, + Radius bottomLeft = Radius.zero, }) : this._raw( top: top, left: left, @@ -1151,12 +1151,12 @@ class RRect { /// /// The corner radii default to [Radius.zero], i.e. right-angled corners RRect.fromRectAndCorners( - Rect/*!*/ rect, + Rect rect, { - Radius/*!*/ topLeft = Radius.zero, - Radius/*!*/ topRight = Radius.zero, - Radius/*!*/ bottomRight = Radius.zero, - Radius/*!*/ bottomLeft = Radius.zero + Radius topLeft = Radius.zero, + Radius topRight = Radius.zero, + Radius bottomRight = Radius.zero, + Radius bottomLeft = Radius.zero } ) : this._raw( top: rect.top, @@ -1194,77 +1194,77 @@ class RRect { this.blRadiusX = 0.0, this.blRadiusY = 0.0, bool uniformRadii = false, - }) : assert(left != null), - assert(top != null), - assert(right != null), - assert(bottom != null), - assert(tlRadiusX != null), - assert(tlRadiusY != null), - assert(trRadiusX != null), - assert(trRadiusY != null), - assert(brRadiusX != null), - assert(brRadiusY != null), - assert(blRadiusX != null), - assert(blRadiusY != null), + }) : assert(left != null), // ignore: unnecessary_null_comparison + assert(top != null), // ignore: unnecessary_null_comparison + assert(right != null), // ignore: unnecessary_null_comparison + assert(bottom != null), // ignore: unnecessary_null_comparison + assert(tlRadiusX != null), // ignore: unnecessary_null_comparison + assert(tlRadiusY != null), // ignore: unnecessary_null_comparison + assert(trRadiusX != null), // ignore: unnecessary_null_comparison + assert(trRadiusY != null), // ignore: unnecessary_null_comparison + assert(brRadiusX != null), // ignore: unnecessary_null_comparison + assert(brRadiusY != null), // ignore: unnecessary_null_comparison + assert(blRadiusX != null), // ignore: unnecessary_null_comparison + assert(blRadiusY != null), // ignore: unnecessary_null_comparison this.webOnlyUniformRadii = uniformRadii; /// The offset of the left edge of this rectangle from the x axis. - final double/*!*/ left; + final double left; /// The offset of the top edge of this rectangle from the y axis. - final double/*!*/ top; + final double top; /// The offset of the right edge of this rectangle from the x axis. - final double/*!*/ right; + final double right; /// The offset of the bottom edge of this rectangle from the y axis. - final double/*!*/ bottom; + final double bottom; /// The top-left horizontal radius. - final double/*!*/ tlRadiusX; + final double tlRadiusX; /// The top-left vertical radius. - final double/*!*/ tlRadiusY; + final double tlRadiusY; /// The top-left [Radius]. - Radius/*!*/ get tlRadius => Radius.elliptical(tlRadiusX, tlRadiusY); + Radius get tlRadius => Radius.elliptical(tlRadiusX, tlRadiusY); /// The top-right horizontal radius. - final double/*!*/ trRadiusX; + final double trRadiusX; /// The top-right vertical radius. - final double/*!*/ trRadiusY; + final double trRadiusY; /// The top-right [Radius]. - Radius/*!*/ get trRadius => Radius.elliptical(trRadiusX, trRadiusY); + Radius get trRadius => Radius.elliptical(trRadiusX, trRadiusY); /// The bottom-right horizontal radius. - final double/*!*/ brRadiusX; + final double brRadiusX; /// The bottom-right vertical radius. - final double/*!*/ brRadiusY; + final double brRadiusY; /// The bottom-right [Radius]. - Radius/*!*/ get brRadius => Radius.elliptical(brRadiusX, brRadiusY); + Radius get brRadius => Radius.elliptical(brRadiusX, brRadiusY); /// The bottom-left horizontal radius. - final double/*!*/ blRadiusX; + final double blRadiusX; /// The bottom-left vertical radius. - final double/*!*/ blRadiusY; + final double blRadiusY; /// If radii is equal for all corners. // webOnly - final bool/*!*/ webOnlyUniformRadii; + final bool webOnlyUniformRadii; /// The bottom-left [Radius]. - Radius/*!*/ get blRadius => Radius.elliptical(blRadiusX, blRadiusY); + Radius get blRadius => Radius.elliptical(blRadiusX, blRadiusY); /// A rounded rectangle with all the values set to zero. static const RRect zero = RRect._raw(); /// Returns a new [RRect] translated by the given offset. - RRect/*!*/ shift(Offset/*!*/ offset) { + RRect shift(Offset offset) { return RRect._raw( left: left + offset.dx, top: top + offset.dy, @@ -1283,7 +1283,7 @@ class RRect { /// Returns a new [RRect] with edges and radii moved outwards by the given /// delta. - RRect/*!*/ inflate(double/*!*/ delta) { + RRect inflate(double delta) { return RRect._raw( left: left - delta, top: top - delta, @@ -1301,22 +1301,22 @@ class RRect { } /// Returns a new [RRect] with edges and radii moved inwards by the given delta. - RRect/*!*/ deflate(double/*!*/ delta) => inflate(-delta); + RRect deflate(double delta) => inflate(-delta); /// The distance between the left and right edges of this rectangle. - double/*!*/ get width => right - left; + double get width => right - left; /// The distance between the top and bottom edges of this rectangle. - double/*!*/ get height => bottom - top; + double get height => bottom - top; /// The bounding box of this rounded rectangle (the rectangle with no rounded corners). - Rect/*!*/ get outerRect => Rect.fromLTRB(left, top, right, bottom); + Rect get outerRect => Rect.fromLTRB(left, top, right, bottom); /// The non-rounded rectangle that is constrained by the smaller of the two /// diagonals, with each diagonal traveling through the middle of the curve /// corners. The middle of a corner is the intersection of the curve with its /// respective quadrant bisector. - Rect/*!*/ get safeInnerRect { + Rect get safeInnerRect { const double kInsetFactor = 0.29289321881; // 1-cos(pi/4) final double leftRadius = math.max(blRadiusX, tlRadiusX); @@ -1338,7 +1338,7 @@ class RRect { /// intersection of the [wideMiddleRect] and the [tallMiddleRect]. If any of /// the intersections are void, the resulting [Rect] will have negative width /// or height. - Rect/*!*/ get middleRect { + Rect get middleRect { final double leftRadius = math.max(blRadiusX, tlRadiusX); final double topRadius = math.max(tlRadiusY, trRadiusY); final double rightRadius = math.max(trRadiusX, brRadiusX); @@ -1355,7 +1355,7 @@ class RRect { /// has the full width of the rounded rectangle. If the rounded rectangle does /// not have an axis-aligned intersection of its left and right side, the /// resulting [Rect] will have negative width or height. - Rect/*!*/ get wideMiddleRect { + Rect get wideMiddleRect { final double topRadius = math.max(tlRadiusY, trRadiusY); final double bottomRadius = math.max(brRadiusY, blRadiusY); return Rect.fromLTRB( @@ -1370,7 +1370,7 @@ class RRect { /// has the full height of the rounded rectangle. If the rounded rectangle /// does not have an axis-aligned intersection of its top and bottom side, the /// resulting [Rect] will have negative width or height. - Rect/*!*/ get tallMiddleRect { + Rect get tallMiddleRect { final double leftRadius = math.max(blRadiusX, tlRadiusX); final double rightRadius = math.max(trRadiusX, brRadiusX); return Rect.fromLTRB( @@ -1383,14 +1383,14 @@ class RRect { /// Whether this rounded rectangle encloses a non-zero area. /// Negative areas are considered empty. - bool/*!*/ get isEmpty => left >= right || top >= bottom; + bool get isEmpty => left >= right || top >= bottom; /// Whether all coordinates of this rounded rectangle are finite. - bool/*!*/ get isFinite => left.isFinite && top.isFinite && right.isFinite && bottom.isFinite; + bool get isFinite => left.isFinite && top.isFinite && right.isFinite && bottom.isFinite; /// Whether this rounded rectangle is a simple rectangle with zero /// corner radii. - bool/*!*/ get isRect { + bool get isRect { return (tlRadiusX == 0.0 || tlRadiusY == 0.0) && (trRadiusX == 0.0 || trRadiusY == 0.0) && (blRadiusX == 0.0 || blRadiusY == 0.0) && @@ -1398,7 +1398,7 @@ class RRect { } /// Whether this rounded rectangle has a side with no straight section. - bool/*!*/ get isStadium { + bool get isStadium { return tlRadius == trRadius && trRadius == brRadius && brRadius == blRadius @@ -1406,7 +1406,7 @@ class RRect { } /// Whether this rounded rectangle has no side with a straight section. - bool/*!*/ get isEllipse { + bool get isEllipse { return tlRadius == trRadius && trRadius == brRadius && brRadius == blRadius @@ -1415,24 +1415,24 @@ class RRect { } /// Whether this rounded rectangle would draw as a circle. - bool/*!*/ get isCircle => width == height && isEllipse; + bool get isCircle => width == height && isEllipse; /// The lesser of the magnitudes of the [width] and the [height] of this /// rounded rectangle. - double/*!*/ get shortestSide => math.min(width.abs(), height.abs()); + double get shortestSide => math.min(width.abs(), height.abs()); /// The greater of the magnitudes of the [width] and the [height] of this /// rounded rectangle. - double/*!*/ get longestSide => math.max(width.abs(), height.abs()); + double get longestSide => math.max(width.abs(), height.abs()); /// Whether any of the dimensions are `NaN`. - bool/*!*/ get hasNaN => left.isNaN || top.isNaN || right.isNaN || bottom.isNaN || + bool get hasNaN => left.isNaN || top.isNaN || right.isNaN || bottom.isNaN || trRadiusX.isNaN || trRadiusY.isNaN || tlRadiusX.isNaN || tlRadiusY.isNaN || brRadiusX.isNaN || brRadiusY.isNaN || blRadiusX.isNaN || blRadiusY.isNaN; /// The offset to the point halfway between the left and right and the top and /// bottom edges of this rectangle. - Offset/*!*/ get center => Offset(left + width / 2.0, top + height / 2.0); + Offset get center => Offset(left + width / 2.0, top + height / 2.0); // Returns the minimum between min and scale to which radius1 and radius2 // should be scaled with in order not to exceed the limit. @@ -1452,7 +1452,7 @@ class RRect { /// /// See the [Skia scaling implementation](https://github.com/google/skia/blob/master/src/core/SkRRect.cpp) /// for more details. - RRect/*!*/ scaleRadii() { + RRect scaleRadii() { double scale = 1.0; scale = _getMin(scale, blRadiusY, tlRadiusY, height); scale = _getMin(scale, tlRadiusX, trRadiusX, width); @@ -1499,7 +1499,7 @@ class RRect { /// radii the first time it is called on a particular [RRect] instance. When /// using this method, prefer to reuse existing [RRect]s rather than /// recreating the object each time. - bool/*!*/ contains(Offset/*!*/ point) { + bool contains(Offset point) { if (point.dx < left || point.dx >= right || point.dy < top || point.dy >= bottom) return false; // outside bounding box @@ -1562,8 +1562,8 @@ class RRect { /// /// Values for `t` are usually obtained from an [Animation], such as /// an [AnimationController]. - static RRect/*?*/ lerp(RRect/*?*/ a, RRect/*?*/ b, double/*!*/ t) { - assert(t != null); + static RRect? lerp(RRect? a, RRect? b, double t) { + assert(t != null); // ignore: unnecessary_null_comparison if (b == null) { if (a == null) { return null; @@ -1620,7 +1620,7 @@ class RRect { } @override - bool/*!*/ operator ==(dynamic other) { + bool operator ==(dynamic other) { if (identical(this, other)) return true; if (runtimeType != other.runtimeType) @@ -1641,12 +1641,12 @@ class RRect { } @override - int/*!*/ get hashCode => hashValues(left, top, right, bottom, + int get hashCode => hashValues(left, top, right, bottom, tlRadiusX, tlRadiusY, trRadiusX, trRadiusY, blRadiusX, blRadiusY, brRadiusX, brRadiusY); @override - String/*!*/ toString() { + String toString() { final String rect = '${left.toStringAsFixed(1)}, ' '${top.toStringAsFixed(1)}, ' '${right.toStringAsFixed(1)}, ' @@ -1698,7 +1698,7 @@ class RSTransform { /// computations of the sine and cosine of the rotation so that they can be /// reused over multiple calls to this constructor, it may be more efficient /// to directly use this constructor instead. - RSTransform(double/*!*/ scos, double/*!*/ ssin, double/*!*/ tx, double/*!*/ ty) { + RSTransform(double scos, double ssin, double tx, double ty) { _value ..[0] = scos ..[1] = ssin @@ -1726,12 +1726,12 @@ class RSTransform { /// over multiple [RSTransform] objects, it may be more efficient to directly /// use the more direct [new RSTransform] constructor instead. factory RSTransform.fromComponents({ - double/*!*/ rotation, - double/*!*/ scale, - double/*!*/ anchorX, - double/*!*/ anchorY, - double/*!*/ translateX, - double/*!*/ translateY + required double rotation, + required double scale, + required double anchorX, + required double anchorY, + required double translateX, + required double translateY }) { final double scos = math.cos(rotation) * scale; final double ssin = math.sin(rotation) * scale; @@ -1743,18 +1743,18 @@ class RSTransform { final Float32List _value = Float32List(4); /// The cosine of the rotation multiplied by the scale factor. - double/*!*/ get scos => _value[0]; + double get scos => _value[0]; /// The sine of the rotation multiplied by that same scale factor. - double/*!*/ get ssin => _value[1]; + double get ssin => _value[1]; /// The x coordinate of the translation, minus [scos] multiplied by the /// x-coordinate of the rotation point, plus [ssin] multiplied by the /// y-coordinate of the rotation point. - double/*!*/ get tx => _value[2]; + double get tx => _value[2]; /// The y coordinate of the translation, minus [ssin] multiplied by the /// x-coordinate of the rotation point, minus [scos] multiplied by the /// y-coordinate of the rotation point. - double/*!*/ get ty => _value[3]; + double get ty => _value[3]; } diff --git a/lib/web_ui/lib/src/ui/hash_codes.dart b/lib/web_ui/lib/src/ui/hash_codes.dart index 08c766d1122ba..69aeb33bb8556 100644 --- a/lib/web_ui/lib/src/ui/hash_codes.dart +++ b/lib/web_ui/lib/src/ui/hash_codes.dart @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.6 +// @dart = 2.9 part of ui; class _HashEnd { const _HashEnd(); } @@ -12,7 +12,7 @@ const _HashEnd _hashEnd = _HashEnd(); // // Borrowed from the dart sdk: sdk/lib/math/jenkins_smi_hash.dart. class _Jenkins { - static int combine(int hash, Object o) { + static int combine(int hash, Object? o) { assert(o is! Iterable); hash = 0x1fffffff & (hash + o.hashCode); hash = 0x1fffffff & (hash + ((0x0007ffff & hash) << 10)); @@ -42,14 +42,14 @@ class _Jenkins { /// ```dart /// int hashCode => hashValues(foo, bar, hashList(quux), baz); /// ``` -int/*!*/ hashValues( - Object/*?*/ arg01, Object/*?*/ arg02, [ Object/*?*/ arg03 = _hashEnd, - Object/*?*/ arg04 = _hashEnd, Object/*?*/ arg05 = _hashEnd, Object/*?*/ arg06 = _hashEnd, - Object/*?*/ arg07 = _hashEnd, Object/*?*/ arg08 = _hashEnd, Object/*?*/ arg09 = _hashEnd, - Object/*?*/ arg10 = _hashEnd, Object/*?*/ arg11 = _hashEnd, Object/*?*/ arg12 = _hashEnd, - Object/*?*/ arg13 = _hashEnd, Object/*?*/ arg14 = _hashEnd, Object/*?*/ arg15 = _hashEnd, - Object/*?*/ arg16 = _hashEnd, Object/*?*/ arg17 = _hashEnd, Object/*?*/ arg18 = _hashEnd, - Object/*?*/ arg19 = _hashEnd, Object/*?*/ arg20 = _hashEnd ]) { +int hashValues( + Object? arg01, Object? arg02, [ Object? arg03 = _hashEnd, + Object? arg04 = _hashEnd, Object? arg05 = _hashEnd, Object? arg06 = _hashEnd, + Object? arg07 = _hashEnd, Object? arg08 = _hashEnd, Object? arg09 = _hashEnd, + Object? arg10 = _hashEnd, Object? arg11 = _hashEnd, Object? arg12 = _hashEnd, + Object? arg13 = _hashEnd, Object? arg14 = _hashEnd, Object? arg15 = _hashEnd, + Object? arg16 = _hashEnd, Object? arg17 = _hashEnd, Object? arg18 = _hashEnd, + Object? arg19 = _hashEnd, Object? arg20 = _hashEnd ]) { int result = 0; result = _Jenkins.combine(result, arg01); result = _Jenkins.combine(result, arg02); @@ -114,10 +114,10 @@ int/*!*/ hashValues( /// Combine the [Object.hashCode] values of an arbitrary number of objects from /// an [Iterable] into one value. This function will return the same value if /// given null as if given an empty list. -int/*!*/ hashList(Iterable/*?*/ arguments) { +int hashList(Iterable? arguments) { int result = 0; if (arguments != null) { - for (Object argument in arguments) + for (Object? argument in arguments) result = _Jenkins.combine(result, argument); } return _Jenkins.finish(result); diff --git a/lib/web_ui/lib/src/ui/initialization.dart b/lib/web_ui/lib/src/ui/initialization.dart index 8ebcdc01421b5..9fa6810f25e8e 100644 --- a/lib/web_ui/lib/src/ui/initialization.dart +++ b/lib/web_ui/lib/src/ui/initialization.dart @@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.6 +// @dart = 2.9 part of ui; /// Initializes the platform. -Future/*!*/ webOnlyInitializePlatform({ - engine.AssetManager/*?*/ assetManager, +Future webOnlyInitializePlatform({ + engine.AssetManager? assetManager, }) { final Future initializationFuture = _initializePlatform(assetManager: assetManager); scheduleMicrotask(() { @@ -20,13 +20,13 @@ Future/*!*/ webOnlyInitializePlatform({ } Future _initializePlatform({ - engine.AssetManager assetManager, + engine.AssetManager? assetManager, }) async { if (!debugEmulateFlutterTesterEnvironment) { engine.window.locationStrategy = const engine.HashLocationStrategy(); } - engine.webOnlyInitializeEngine(); + engine.initializeEngine(); // This needs to be after `webOnlyInitializeEngine` because that is where the // canvaskit script is added to the page. @@ -39,25 +39,25 @@ Future _initializePlatform({ if (engine.experimentalUseSkia) { await engine.skiaFontCollection.ensureFontsLoaded(); } else { - await _fontCollection.ensureFontsLoaded(); + await _fontCollection!.ensureFontsLoaded(); } _webOnlyIsInitialized = true; } // TODO(yjbanov): can we make this late non-null? See https://github.com/dart-lang/sdk/issues/42214 -engine.AssetManager/*?*/ _assetManager; -engine.FontCollection _fontCollection; +engine.AssetManager? _assetManager; +engine.FontCollection? _fontCollection; bool _webOnlyIsInitialized = false; -bool/*!*/ get webOnlyIsInitialized => _webOnlyIsInitialized; +bool get webOnlyIsInitialized => _webOnlyIsInitialized; /// Specifies that the platform should use the given [AssetManager] to load /// assets. /// /// The given asset manager is used to initialize the font collection. -Future/*!*/ webOnlySetAssetManager(engine.AssetManager/*!*/ assetManager) async { - assert(assetManager != null, 'Cannot set assetManager to null'); +Future webOnlySetAssetManager(engine.AssetManager assetManager) async { + assert(assetManager != null, 'Cannot set assetManager to null'); // ignore: unnecessary_null_comparison if (assetManager == _assetManager) { return; } @@ -65,23 +65,23 @@ Future/*!*/ webOnlySetAssetManager(engine.AssetManager/*!*/ assetManager) _assetManager = assetManager; if (engine.experimentalUseSkia) { - engine.skiaFontCollection ??= engine.SkiaFontCollection(); + engine.ensureSkiaFontCollectionInitialized(); } else { _fontCollection ??= engine.FontCollection(); - _fontCollection.clear(); + _fontCollection!.clear(); } if (_assetManager != null) { if (engine.experimentalUseSkia) { - await engine.skiaFontCollection.registerFonts(_assetManager); + await engine.skiaFontCollection.registerFonts(_assetManager!); } else { - await _fontCollection.registerFonts(_assetManager); + await _fontCollection!.registerFonts(_assetManager!); } } if (debugEmulateFlutterTesterEnvironment && !engine.experimentalUseSkia) { - _fontCollection.debugRegisterTestFonts(); + _fontCollection!.debugRegisterTestFonts(); } } @@ -92,10 +92,10 @@ Future/*!*/ webOnlySetAssetManager(engine.AssetManager/*!*/ assetManager) /// /// For example in these tests we use a predictable-size font which makes widget /// tests less flaky. -bool/*!*/ get debugEmulateFlutterTesterEnvironment => +bool get debugEmulateFlutterTesterEnvironment => _debugEmulateFlutterTesterEnvironment; -set debugEmulateFlutterTesterEnvironment(bool/*!*/ value) { +set debugEmulateFlutterTesterEnvironment(bool value) { _debugEmulateFlutterTesterEnvironment = value; if (_debugEmulateFlutterTesterEnvironment) { const Size logicalSize = Size(800.0, 600.0); @@ -107,7 +107,7 @@ set debugEmulateFlutterTesterEnvironment(bool/*!*/ value) { bool _debugEmulateFlutterTesterEnvironment = false; /// This class handles downloading assets over the network. -engine.AssetManager/*!*/ get webOnlyAssetManager => _assetManager; +engine.AssetManager get webOnlyAssetManager => _assetManager!; /// A collection of fonts that may be used by the platform. -engine.FontCollection/*!*/ get webOnlyFontCollection => _fontCollection; +engine.FontCollection get webOnlyFontCollection => _fontCollection!; diff --git a/lib/web_ui/lib/src/ui/lerp.dart b/lib/web_ui/lib/src/ui/lerp.dart index e4b92c4eb9491..bcc278f8a92be 100644 --- a/lib/web_ui/lib/src/ui/lerp.dart +++ b/lib/web_ui/lib/src/ui/lerp.dart @@ -2,29 +2,29 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.6 +// @dart = 2.9 part of ui; /// Linearly interpolate between two numbers. -double/*?*/ lerpDouble(num/*?*/ a, num/*?*/ b, double/*!*/ t) { +double? lerpDouble(num? a, num? b, double t) { if (a == null && b == null) { return null; } a ??= 0.0; b ??= 0.0; - return a + (b - a) * t; + return a + (b - a) * t as double; } -double/*!*/ _lerpDouble(double/*!*/ a, double/*!*/ b, double/*!*/ t) { +double _lerpDouble(double a, double b, double t) { return a + (b - a) * t; } -double/*!*/ _lerpInt(int/*!*/ a, int/*!*/ b, double/*!*/ t) { +double _lerpInt(int a, int b, double t) { return a + (b - a) * t; } /// Same as [num.clamp] but specialized for [int]. -int/*!*/ _clampInt(int/*!*/ value, int/*!*/ min, int/*!*/ max) { +int _clampInt(int value, int min, int max) { assert(min <= max); if (value < min) { return min; diff --git a/lib/web_ui/lib/src/ui/natives.dart b/lib/web_ui/lib/src/ui/natives.dart index 1cdcb68c75a11..e4bf1a2f5ba40 100644 --- a/lib/web_ui/lib/src/ui/natives.dart +++ b/lib/web_ui/lib/src/ui/natives.dart @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.6 +// @dart = 2.9 part of ui; // Corelib 'print' implementation. @@ -16,11 +16,11 @@ void _printDebug(dynamic arg) { } class _Logger { - static void _printString(String/*?*/ s) { + static void _printString(String? s) { print(s); } - static void _printDebugString(String/*?*/ s) { - html.window.console.error(s); + static void _printDebugString(String? s) { + html.window.console.error(s!); } } @@ -40,6 +40,6 @@ class _Logger { /// ``` /// /// This function is only effective in debug and dynamic modes, and will throw in AOT mode. -List/*!*/ saveCompilationTrace() { +List saveCompilationTrace() { throw UnimplementedError(); } diff --git a/lib/web_ui/lib/src/ui/painting.dart b/lib/web_ui/lib/src/ui/painting.dart index 51474bebd608f..46c41b4b0d31a 100644 --- a/lib/web_ui/lib/src/ui/painting.dart +++ b/lib/web_ui/lib/src/ui/painting.dart @@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.6 +// @dart = 2.9 part of ui; // ignore: unused_element, Used in Shader assert. bool _offsetIsValid(Offset offset) { - assert(offset != null, 'Offset argument was null.'); + assert(offset != null, 'Offset argument was null.'); // ignore: unnecessary_null_comparison assert(!offset.dx.isNaN && !offset.dy.isNaN, 'Offset argument contained a NaN value.'); return true; @@ -15,12 +15,12 @@ bool _offsetIsValid(Offset offset) { // ignore: unused_element, Used in Shader assert. bool _matrix4IsValid(Float32List matrix4) { - assert(matrix4 != null, 'Matrix4 argument was null.'); + assert(matrix4 != null, 'Matrix4 argument was null.'); // ignore: unnecessary_null_comparison assert(matrix4.length == 16, 'Matrix4 must have 16 entries.'); return true; } -void _validateColorStops(List colors, List colorStops) { +void _validateColorStops(List colors, List? colorStops) { if (colorStops == null) { if (colors.length != 2) throw ArgumentError( @@ -44,10 +44,10 @@ class Color { /// Bits 16-23 are the red value. /// Bits 8-15 are the green value. /// Bits 0-7 are the blue value. - const Color(int/*!*/ value) : this.value = value & 0xFFFFFFFF; + const Color(int value) : this.value = value & 0xFFFFFFFF; /// Construct a color from the lower 8 bits of four integers. - const Color.fromARGB(int/*!*/ a, int/*!*/ r, int/*!*/ g, int/*!*/ b) + const Color.fromARGB(int a, int r, int g, int b) : value = (((a & 0xff) << 24) | ((r & 0xff) << 16) | ((g & 0xff) << 8) | @@ -65,7 +65,7 @@ class Color { /// Out of range values are brought into range using modulo 255. /// /// See also [fromARGB], which takes the opacity as an integer value. - const Color.fromRGBO(int/*!*/ r, int/*!*/ g, int/*!*/ b, double/*!*/ opacity) + const Color.fromRGBO(int r, int g, int b, double opacity) : value = ((((opacity * 0xff ~/ 1) & 0xff) << 24) | ((r & 0xff) << 16) | ((g & 0xff) << 8) | @@ -78,51 +78,51 @@ class Color { /// Bits 16-23 are the red value. /// Bits 8-15 are the green value. /// Bits 0-7 are the blue value. - final int/*!*/ value; + final int value; /// The alpha channel of this color in an 8 bit value. - int/*!*/ get alpha => (0xff000000 & value) >> 24; + int get alpha => (0xff000000 & value) >> 24; /// The alpha channel of this color as a double. - double/*!*/ get opacity => alpha / 0xFF; + double get opacity => alpha / 0xFF; /// The red channel of this color in an 8 bit value. - int/*!*/ get red => (0x00ff0000 & value) >> 16; + int get red => (0x00ff0000 & value) >> 16; /// The green channel of this color in an 8 bit value. - int/*!*/ get green => (0x0000ff00 & value) >> 8; + int get green => (0x0000ff00 & value) >> 8; /// The blue channel of this color in an 8 bit value. - int/*!*/ get blue => (0x000000ff & value) >> 0; + int get blue => (0x000000ff & value) >> 0; /// Returns a new color that matches this color with the alpha channel /// replaced with a (which ranges from 0 to 255). - Color/*!*/ withAlpha(int/*!*/ a) { + Color withAlpha(int a) { return Color.fromARGB(a, red, green, blue); } /// Returns a new color that matches this color with the alpha channel /// replaced with the given opacity (which ranges from 0.0 to 1.0). - Color/*!*/ withOpacity(double/*!*/ opacity) { + Color withOpacity(double opacity) { assert(opacity >= 0.0 && opacity <= 1.0); return withAlpha((255.0 * opacity).round()); } /// Returns a new color that matches this color with the red channel replaced /// with r. - Color/*!*/ withRed(int/*!*/ r) { + Color withRed(int r) { return Color.fromARGB(alpha, r, green, blue); } /// Returns a new color that matches this color with the green channel /// replaced with g. - Color/*!*/ withGreen(int/*!*/ g) { + Color withGreen(int g) { return Color.fromARGB(alpha, red, g, blue); } /// Returns a new color that matches this color with the blue channel replaced /// with b. - Color/*!*/ withBlue(int/*!*/ b) { + Color withBlue(int b) { return Color.fromARGB(alpha, red, green, b); } @@ -131,7 +131,7 @@ class Color { if (component <= 0.03928) { return component / 12.92; } - return math.pow((component + 0.055) / 1.055, 2.4); + return math.pow((component + 0.055) / 1.055, 2.4) as double; } /// Returns a brightness value between 0 for darkest and 1 for lightest. @@ -140,7 +140,7 @@ class Color { /// computationally expensive to calculate. /// /// See . - double/*!*/ computeLuminance() { + double computeLuminance() { // See final double R = _linearizeColorComponent(red / 0xFF); final double G = _linearizeColorComponent(green / 0xFF); @@ -170,8 +170,8 @@ class Color { /// /// Values for `t` are usually obtained from an [Animation], such as /// an [AnimationController]. - static Color/*?*/ lerp(Color/*?*/ a, Color/*?*/ b, double/*!*/ t) { - assert(t != null); + static Color? lerp(Color? a, Color? b, double t) { + assert(t != null); // ignore: unnecessary_null_comparison if (b == null) { if (a == null) { return null; @@ -200,7 +200,7 @@ class Color { /// enhancement when trying to avoid needless alpha blending compositing /// operations for two things that are solid colors with the same shape, but /// overlay each other: instead, just paint one with the combined color. - static Color/*!*/ alphaBlend(Color/*!*/ foreground, Color/*!*/ background) { + static Color alphaBlend(Color foreground, Color background) { final int alpha = foreground.alpha; if (alpha == 0x00) { // Foreground completely transparent. @@ -233,13 +233,13 @@ class Color { /// Returns an alpha value representative of the provided [opacity] value. /// /// The [opacity] value may not be null. - static int/*!*/ getAlphaFromOpacity(double/*!*/ opacity) { - assert(opacity != null); + static int getAlphaFromOpacity(double opacity) { + assert(opacity != null); // ignore: unnecessary_null_comparison return (opacity.clamp(0.0, 1.0) * 255).round(); } @override - bool/*!*/ operator ==(dynamic other) { + bool operator ==(dynamic other) { if (identical(this, other)) { return true; } @@ -251,10 +251,10 @@ class Color { } @override - int/*!*/ get hashCode => value.hashCode; + int get hashCode => value.hashCode; @override - String/*!*/ toString() { + String toString() { return 'Color(0x${value.toRadixString(16).padLeft(8, '0')})'; } } @@ -939,14 +939,14 @@ abstract class Paint { /// * [Canvas.saveLayer], which uses its [Paint]'s [blendMode] to composite /// the layer when [restore] is called. /// * [BlendMode], which discusses the user of [saveLayer] with [blendMode]. - BlendMode/*!*/ get blendMode; - set blendMode(BlendMode/*!*/ value); + BlendMode get blendMode; + set blendMode(BlendMode value); /// Whether to paint inside shapes, the edges of shapes, or both. /// /// If null, defaults to [PaintingStyle.fill]. - PaintingStyle/*!*/ get style; - set style(PaintingStyle/*!*/ value); + PaintingStyle get style; + set style(PaintingStyle value); /// How wide to make edges drawn when [style] is set to /// [PaintingStyle.stroke] or [PaintingStyle.strokeAndFill]. The @@ -954,43 +954,43 @@ abstract class Paint { /// orthogonal to the direction of the path. /// /// The values null and 0.0 correspond to a hairline width. - double/*!*/ get strokeWidth; - set strokeWidth(double/*!*/ value); + double get strokeWidth; + set strokeWidth(double value); /// The kind of finish to place on the end of lines drawn when /// [style] is set to [PaintingStyle.stroke] or /// [PaintingStyle.strokeAndFill]. /// /// If null, defaults to [StrokeCap.butt], i.e. no caps. - StrokeCap/*!*/ get strokeCap; - set strokeCap(StrokeCap/*!*/ value); + StrokeCap get strokeCap; + set strokeCap(StrokeCap value); /// The kind of finish to use for line segment joins. /// [style] is set to [PaintingStyle.stroke] or /// [PaintingStyle.strokeAndFill]. Only applies to drawPath not drawPoints. /// /// If null, defaults to [StrokeCap.butt], i.e. no caps. - StrokeJoin/*!*/ get strokeJoin; - set strokeJoin(StrokeJoin/*!*/ value); + StrokeJoin get strokeJoin; + set strokeJoin(StrokeJoin value); /// Whether to apply anti-aliasing to lines and images drawn on the /// canvas. /// /// Defaults to true. The value null is treated as false. - bool/*!*/ get isAntiAlias; - set isAntiAlias(bool/*!*/ value); + bool get isAntiAlias; + set isAntiAlias(bool value); - Color/*!*/ get color; - set color(Color/*!*/ value); + Color get color; + set color(Color value); /// Whether the colors of the image are inverted when drawn. /// /// Inverting the colors of an image applies a new color filter that will /// be composed with any user provided color filters. This is primarily /// used for implementing smart invert on iOS. - bool/*!*/ get invertColors; + bool get invertColors; - set invertColors(bool/*!*/ value); + set invertColors(bool value); /// The shader to use when stroking or filling a shape. /// @@ -1002,15 +1002,15 @@ abstract class Paint { /// * [ImageShader], a shader that tiles an [Image]. /// * [colorFilter], which overrides [shader]. /// * [color], which is used if [shader] and [colorFilter] are null. - Shader/*?*/ get shader; - set shader(Shader/*?*/ value); + Shader? get shader; + set shader(Shader? value); /// A mask filter (for example, a blur) to apply to a shape after it has been /// drawn but before it has been composited into the image. /// /// See [MaskFilter] for details. - MaskFilter/*?*/ get maskFilter; - set maskFilter(MaskFilter/*?*/ value); + MaskFilter? get maskFilter; + set maskFilter(MaskFilter? value); /// Controls the performance vs quality trade-off to use when applying /// filters, such as [maskFilter], or when drawing images, as with @@ -1018,8 +1018,8 @@ abstract class Paint { /// /// Defaults to [FilterQuality.none]. // TODO(ianh): verify that the image drawing methods actually respect this - FilterQuality/*!*/ get filterQuality; - set filterQuality(FilterQuality/*!*/ value); + FilterQuality get filterQuality; + set filterQuality(FilterQuality value); /// A color filter to apply when a shape is drawn or when a layer is /// composited. @@ -1027,11 +1027,11 @@ abstract class Paint { /// See [ColorFilter] for details. /// /// When a shape is being drawn, [colorFilter] overrides [color] and [shader]. - ColorFilter/*?*/ get colorFilter; - set colorFilter(ColorFilter/*?*/ value); + ColorFilter? get colorFilter; + set colorFilter(ColorFilter? value); - double/*!*/ get strokeMiterLimit; - set strokeMiterLimit(double/*!*/ value); + double get strokeMiterLimit; + set strokeMiterLimit(double value); /// The [ImageFilter] to use when drawing raster images. /// @@ -1055,8 +1055,8 @@ abstract class Paint { /// See also: /// /// * [MaskFilter], which is used for drawing geometry. - ImageFilter/*?*/ get imageFilter; - set imageFilter(ImageFilter/*?*/ value); + ImageFilter? get imageFilter; + set imageFilter(ImageFilter? value); } /// Base class for objects such as [Gradient] and [ImageShader] which @@ -1090,12 +1090,12 @@ abstract class Gradient extends Shader { /// `colorStops` contain null values, this constructor will throw a /// [NoSuchMethodError]. factory Gradient.linear( - Offset/*!*/ from, - Offset/*!*/ to, - List/*!*/ colors, [ - List/*?*/ colorStops, - TileMode/*!*/ tileMode = TileMode.clamp, - Float64List/*?*/ matrix4, + Offset from, + Offset to, + List colors, [ + List? colorStops, + TileMode tileMode = TileMode.clamp, + Float64List? matrix4, ]) => engine.GradientLinear(from, to, colors, colorStops, tileMode, matrix4); @@ -1129,20 +1129,19 @@ abstract class Gradient extends Shader { /// provided and not equal to `center`, at least one of the two offsets must /// not be equal to [Offset.zero]. factory Gradient.radial( - Offset/*!*/ center, - double/*!*/ radius, - List/*!*/ colors, [ - List/*?*/ colorStops, - TileMode/*!*/ tileMode = TileMode.clamp, - Float64List/*?*/ matrix4, - Offset/*?*/ focal, - double/*!*/ focalRadius = 0.0, + Offset center, + double radius, + List colors, [ + List? colorStops, + TileMode tileMode = TileMode.clamp, + Float64List? matrix4, + Offset? focal, + double focalRadius = 0.0, ]) { - focalRadius ??= 0.0; _validateColorStops(colors, colorStops); // If focal is null or focal radius is null, this should be treated as a regular radial gradient // If focal == center and the focal radius is 0.0, it's still a regular radial gradient - final Float32List matrix32 = matrix4 != null ? engine.toMatrix32(matrix4) : null; + final Float32List? matrix32 = matrix4 != null ? engine.toMatrix32(matrix4) : null; if (focal == null || (focal == center && focalRadius == 0.0)) { return engine.GradientRadial( center, radius, colors, colorStops, tileMode, matrix32); @@ -1181,13 +1180,13 @@ abstract class Gradient extends Shader { /// specified 4x4 matrix relative to the local coordinate system. `matrix4` /// must be a column-major matrix packed into a list of 16 values. factory Gradient.sweep( - Offset/*!*/ center, - List/*!*/ colors, [ - List/*?*/ colorStops, + Offset center, + List colors, [ + List? colorStops, TileMode tileMode = TileMode.clamp, double startAngle/*?*/ = 0.0, double endAngle/*!*/ = math.pi * 2, - Float64List/*?*/ matrix4, + Float64List? matrix4, ]) => engine.GradientSweep( center, colors, colorStops, tileMode, startAngle, endAngle, matrix4 != null ? engine.toMatrix32(matrix4) : null); @@ -1201,10 +1200,10 @@ abstract class Gradient extends Shader { /// [Canvas.drawImage]. abstract class Image { /// The number of image pixels along the image's horizontal axis. - int/*!*/ get width; + int get width; /// The number of image pixels along the image's vertical axis. - int/*!*/ get height; + int get height; /// Converts the [Image] object into a byte array. /// @@ -1213,7 +1212,7 @@ abstract class Image { /// /// Returns a future that completes with the binary image data or an error /// if encoding fails. - Future/*!*/ toByteData( + Future toByteData( {ImageByteFormat format = ImageByteFormat.rawRgba}); /// Release the resources used by this object. The object is no longer usable @@ -1240,7 +1239,7 @@ abstract class ColorFilter { /// The output of this filter is then composited into the background according /// to the [Paint.blendMode], using the output of this filter as the source /// and the background as the destination. - const factory ColorFilter.mode(Color/*!*/ color, BlendMode/*!*/ blendMode) = + const factory ColorFilter.mode(Color color, BlendMode blendMode) = engine.EngineColorFilter.mode; /// Construct a color filter that transforms a color by a 4x5 matrix. @@ -1301,7 +1300,7 @@ abstract class ColorFilter { /// 0, 0, 0, 1, 0, /// ]); /// ``` - const factory ColorFilter.matrix(List/*!*/ matrix) = + const factory ColorFilter.matrix(List matrix) = engine.EngineColorFilter.matrix; /// Construct a color filter that applies the sRGB gamma curve to the RGB @@ -1370,20 +1369,20 @@ class MaskFilter { const MaskFilter.blur( this._style, this._sigma, - ) : assert(_style != null), - assert(_sigma != null); + ) : assert(_style != null), // ignore: unnecessary_null_comparison + assert(_sigma != null); // ignore: unnecessary_null_comparison - final BlurStyle/*!*/ _style; - final double/*!*/ _sigma; + final BlurStyle _style; + final double _sigma; /// On the web returns the value of sigma passed to [MaskFilter.blur]. - double/*!*/ get webOnlySigma => _sigma; + double get webOnlySigma => _sigma; /// On the web returns the value of `style` passed to [MaskFilter.blur]. - BlurStyle/*!*/ get webOnlyBlurStyle => _style; + BlurStyle get webOnlyBlurStyle => _style; @override - bool/*!*/ operator ==(dynamic other) { + bool operator ==(dynamic other) { if (other is! MaskFilter) { return false; } @@ -1392,14 +1391,14 @@ class MaskFilter { } @override - int/*!*/ get hashCode => hashValues(_style, _sigma); + int get hashCode => hashValues(_style, _sigma); - List/*!*/ webOnlySerializeToCssPaint() { - return [_style?.index, _sigma]; + List webOnlySerializeToCssPaint() { + return [_style.index, _sigma]; } @override - String/*!*/ toString() => 'MaskFilter.blur($_style, ${_sigma.toStringAsFixed(1)})'; + String toString() => 'MaskFilter.blur($_style, ${_sigma.toStringAsFixed(1)})'; } /// Quality levels for image filters. @@ -1447,8 +1446,8 @@ class ImageFilter { return engine.EngineImageFilter.blur(sigmaX: sigmaX, sigmaY: sigmaY); } - ImageFilter.matrix(Float64List/*!*/ matrix4, - {FilterQuality/*!*/ filterQuality = FilterQuality.low}) { + ImageFilter.matrix(Float64List matrix4, + {FilterQuality filterQuality = FilterQuality.low}) { // TODO(flutter_web): add implementation. throw UnimplementedError( 'ImageFilter.matrix not implemented for web platform.'); @@ -1503,12 +1502,12 @@ enum PixelFormat { } class _ImageInfo { - _ImageInfo(this.width, this.height, this.format, int/*?*/ rowBytes) : this.rowBytes = rowBytes ?? width * 4; + _ImageInfo(this.width, this.height, this.format, int? rowBytes) : this.rowBytes = rowBytes ?? width * 4; - int/*!*/ width; - int/*!*/ height; - int/*!*/ format; - int/*!*/ rowBytes; + int width; + int height; + int format; + int rowBytes; } /// Callback signature for [decodeImageFromList]. @@ -1527,11 +1526,11 @@ abstract class FrameInfo { FrameInfo._(); /// The duration this frame should be shown. - Duration/*!*/ get duration => Duration(milliseconds: _durationMillis); + Duration get duration => Duration(milliseconds: _durationMillis); int get _durationMillis => 0; /// The [Image] object for this frame. - Image/*!*/ get image; + Image get image; } /// A handle to an image codec. @@ -1544,25 +1543,25 @@ class Codec { Codec._(); /// Number of frames in this image. - int/*!*/ get frameCount => 0; + int get frameCount => 0; /// Number of times to repeat the animation. /// /// * 0 when the animation should be played once. /// * -1 for infinity repetitions. - int/*!*/ get repetitionCount => 0; + int get repetitionCount => 0; /// Fetches the next animation frame. /// /// Wraps back to the first frame after returning the last frame. /// /// The returned future can complete with an error if the decoding has failed. - Future/*!*/ getNextFrame() { - return engine.futurize(_getNextFrame); + Future getNextFrame() { + return engine.futurize(_getNextFrame); } /// Returns an error message on failure, null on success. - String _getNextFrame(engine.Callback callback) => null; + String? _getNextFrame(engine.Callback callback) => null; /// Release the resources used by this object. The object is no longer usable /// after this method is called. @@ -1578,12 +1577,12 @@ class Codec { /// /// The returned future can complete with an error if the image decoding has /// failed. -Future/*!*/ instantiateImageCodec( - Uint8List/*!*/ list, { - int/*?*/ targetWidth, - int/*?*/ targetHeight, +Future instantiateImageCodec( + Uint8List list, { + int? targetWidth, + int? targetHeight, }) { - return engine.futurize((engine.Callback callback) => + return _futurize((engine.Callback callback) => // TODO: Implement targetWidth and targetHeight support. _instantiateImageCodec(list, callback, null)); } @@ -1591,8 +1590,8 @@ Future/*!*/ instantiateImageCodec( /// Instantiates a [Codec] object for an image binary data. /// /// Returns an error message if the instantiation has failed, null otherwise. -String/*?*/ _instantiateImageCodec( - Uint8List list, engine.Callback callback, _ImageInfo/*?*/ imageInfo) { +String? _instantiateImageCodec( + Uint8List list, engine.Callback callback, _ImageInfo? imageInfo) { if (engine.experimentalUseSkia) { if (imageInfo == null) { engine.skiaInstantiateImageCodec(list, callback); @@ -1607,15 +1606,15 @@ String/*?*/ _instantiateImageCodec( return null; } -Future/*!*/ webOnlyInstantiateImageCodecFromUrl(Uri/*!*/ uri, - {engine.WebOnlyImageCodecChunkCallback/*?*/ chunkCallback}) { - return engine.futurize((engine.Callback callback) => +Future webOnlyInstantiateImageCodecFromUrl(Uri uri, + {engine.WebOnlyImageCodecChunkCallback? chunkCallback}) { + return _futurize((engine.Callback callback) => _instantiateImageCodecFromUrl(uri, chunkCallback, callback)); } -String/*?*/ _instantiateImageCodecFromUrl( +String? _instantiateImageCodecFromUrl( Uri uri, - engine.WebOnlyImageCodecChunkCallback chunkCallback, + engine.WebOnlyImageCodecChunkCallback? chunkCallback, engine.Callback callback) { callback(engine.HtmlCodec(uri.toString(), chunkCallback: chunkCallback)); return null; @@ -1625,12 +1624,12 @@ String/*?*/ _instantiateImageCodecFromUrl( /// /// This is a convenience wrapper around [instantiateImageCodec]. /// Prefer using [instantiateImageCodec] which also supports multi frame images. -void decodeImageFromList(Uint8List/*!*/ list, ImageDecoderCallback/*!*/ callback) { +void decodeImageFromList(Uint8List list, ImageDecoderCallback callback) { _decodeImageFromListAsync(list, callback); } Future _decodeImageFromListAsync( - Uint8List/*!*/ list, ImageDecoderCallback/*!*/ callback) async { + Uint8List list, ImageDecoderCallback callback) async { final Codec codec = await instantiateImageCodec(list); final FrameInfo frameInfo = await codec.getNextFrame(); callback(frameInfo.image); @@ -1644,16 +1643,16 @@ Future _decodeImageFromListAsync( /// data buffer. If unspecified, it defaults to [width] multipled by the /// number of bytes per pixel in the provided [format]. void decodeImageFromPixels( - Uint8List/*!*/ pixels, - int/*!*/ width, - int/*!*/ height, - PixelFormat/*!*/ format, - ImageDecoderCallback/*!*/ callback, - {int/*?*/ rowBytes, int/*?*/ targetWidth, int/*?*/ targetHeight} + Uint8List pixels, + int width, + int height, + PixelFormat format, + ImageDecoderCallback callback, + {int? rowBytes, int? targetWidth, int? targetHeight} ) { final _ImageInfo imageInfo = _ImageInfo(width, height, format.index, rowBytes); - final Future codecFuture = engine.futurize( + final Future codecFuture = _futurize( (engine.Callback callback) => _instantiateImageCodec(pixels, callback, imageInfo)); codecFuture @@ -1679,8 +1678,8 @@ class Shadow { this.color = const Color(_kColorDefault), this.offset = Offset.zero, this.blurRadius = 0.0, - }) : assert(color != null, 'Text shadow color was null.'), - assert(offset != null, 'Text shadow offset was null.'), + }) : assert(color != null, 'Text shadow color was null.'), // ignore: unnecessary_null_comparison + assert(offset != null, 'Text shadow offset was null.'), // ignore: unnecessary_null_comparison assert(blurRadius >= 0.0, 'Text shadow blur radius should be non-negative.'); @@ -1690,17 +1689,17 @@ class Shadow { /// /// The shadows are shapes composited directly over the base canvas, and do not /// represent optical occlusion. - final Color/*!*/ color; + final Color color; /// The displacement of the shadow from the casting element. /// /// Positive x/y offsets will shift the shadow to the right and down, while /// negative offsets shift the shadow to the left and up. The offsets are /// relative to the position of the element that is casting it. - final Offset/*!*/ offset; + final Offset offset; /// The standard deviation of the Gaussian to convolve with the shadow's shape. - final double/*!*/ blurRadius; + final double blurRadius; /// Converts a blur radius in pixels to sigmas. /// @@ -1708,14 +1707,14 @@ class Shadow { /// // See SkBlurMask::ConvertRadiusToSigma(). // - static double/*!*/ convertRadiusToSigma(double/*!*/ radius) { + static double convertRadiusToSigma(double radius) { return radius * 0.57735 + 0.5; } /// The [blurRadius] in sigmas instead of logical pixels. /// /// See the sigma argument to [MaskFilter.blur]. - double/*!*/ get blurSigma => convertRadiusToSigma(blurRadius); + double get blurSigma => convertRadiusToSigma(blurRadius); /// Create the [Paint] object that corresponds to this shadow description. /// @@ -1726,7 +1725,7 @@ class Shadow { /// This class does not provide a way to disable shadows to avoid inconsistencies /// in shadow blur rendering, primarily as a method of reducing test flakiness. /// [toPaint] should be overriden in subclasses to provide this functionality. - Paint/*!*/ toPaint() { + Paint toPaint() { return Paint() ..color = color ..maskFilter = MaskFilter.blur(BlurStyle.normal, blurSigma); @@ -1734,7 +1733,7 @@ class Shadow { /// Returns a new shadow with its [offset] and [blurRadius] scaled by the given /// factor. - Shadow/*!*/ scale(double/*!*/ factor) { + Shadow scale(double factor) { return Shadow( color: color, offset: offset * factor, @@ -1761,8 +1760,8 @@ class Shadow { /// Values for `t` are usually obtained from an [Animation], such as /// an [AnimationController]. /// {@endtemplate} - static Shadow/*?*/ lerp(Shadow/*?*/ a, Shadow/*?*/ b, double/*!*/ t) { - assert(t != null); + static Shadow? lerp(Shadow? a, Shadow? b, double t) { + assert(t != null); // ignore: unnecessary_null_comparison if (b == null) { if (a == null) { return null; @@ -1774,8 +1773,8 @@ class Shadow { return b.scale(t); } else { return Shadow( - color: Color.lerp(a.color, b.color, t), - offset: Offset.lerp(a.offset, b.offset, t), + color: Color.lerp(a.color, b.color, t)!, + offset: Offset.lerp(a.offset, b.offset, t)!, blurRadius: _lerpDouble(a.blurRadius, b.blurRadius, t), ); } @@ -1787,17 +1786,17 @@ class Shadow { /// If the lists differ in length, excess items are lerped with null. /// /// {@macro dart.ui.shadow.lerp} - static List/*?*/ lerpList(List/*?*/ a, List/*?*/ b, double/*!*/ t) { - assert(t != null); + static List? lerpList(List? a, List? b, double t) { + assert(t != null); // ignore: unnecessary_null_comparison if (a == null && b == null) { return null; } a ??= []; b ??= []; - final List result = []; + final List result = []; final int commonLength = math.min(a.length, b.length); for (int i = 0; i < commonLength; i += 1) - result.add(Shadow.lerp(a[i], b[i], t)); + result.add(Shadow.lerp(a[i], b[i], t)!); for (int i = commonLength; i < a.length; i += 1) result.add(a[i].scale(1.0 - t)); for (int i = commonLength; i < b.length; i += 1) { @@ -1807,7 +1806,7 @@ class Shadow { } @override - bool/*!*/ operator ==(dynamic other) { + bool operator ==(dynamic other) { if (identical(this, other)) { return true; } @@ -1821,10 +1820,10 @@ class Shadow { } @override - int/*!*/ get hashCode => hashValues(color, offset, blurRadius); + int get hashCode => hashValues(color, offset, blurRadius); @override - String/*!*/ toString() => 'TextShadow($color, $offset, $blurRadius)'; + String toString() => 'TextShadow($color, $offset, $blurRadius)'; } @@ -1836,10 +1835,10 @@ class ImageShader extends Shader { /// matrix to apply to the effect. All the arguments are required and must not /// be null. factory ImageShader( - Image/*!*/ image, - TileMode/*!*/ tmx, - TileMode/*!*/ tmy, - Float64List/*!*/ matrix4) { + Image image, + TileMode tmx, + TileMode tmy, + Float64List matrix4) { if (engine.experimentalUseSkia) { return engine.EngineImageShader(image, tmx, tmy, matrix4); } diff --git a/lib/web_ui/lib/src/ui/path.dart b/lib/web_ui/lib/src/ui/path.dart index 6b95b67d8b3b3..c303066b616f6 100644 --- a/lib/web_ui/lib/src/ui/path.dart +++ b/lib/web_ui/lib/src/ui/path.dart @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.6 +// @dart = 2.9 part of ui; /// A complex, one-dimensional subset of a plane. @@ -36,64 +36,64 @@ abstract class Path { /// /// This copy is fast and does not require additional memory unless either /// the `source` path or the path returned by this constructor are modified. - factory Path.from(Path/*!*/ source) { + factory Path.from(Path source) { if (engine.experimentalUseSkia) { - return engine.SkPath.from(source); + return engine.SkPath.from(source as engine.SkPath); } else { - return engine.SurfacePath.from(source); + return engine.SurfacePath.from(source as engine.SurfacePath); } } /// Determines how the interior of this path is calculated. /// /// Defaults to the non-zero winding rule, [PathFillType.nonZero]. - PathFillType/*!*/ get fillType; - set fillType(PathFillType/*!*/ value); + PathFillType get fillType; + set fillType(PathFillType value); /// Starts a new subpath at the given coordinate. - void moveTo(double/*!*/ x, double/*!*/ y); + void moveTo(double x, double y); /// Starts a new subpath at the given offset from the current point. - void relativeMoveTo(double/*!*/ dx, double/*!*/ dy); + void relativeMoveTo(double dx, double dy); /// Adds a straight line segment from the current point to the given /// point. - void lineTo(double/*!*/ x, double/*!*/ y); + void lineTo(double x, double y); /// Adds a straight line segment from the current point to the point /// at the given offset from the current point. - void relativeLineTo(double/*!*/ dx, double/*!*/ dy); + void relativeLineTo(double dx, double dy); /// Adds a quadratic bezier segment that curves from the current /// point to the given point (x2,y2), using the control point /// (x1,y1). - void quadraticBezierTo(double/*!*/ x1, double/*!*/ y1, double/*!*/ x2, double/*!*/ y2); + void quadraticBezierTo(double x1, double y1, double x2, double y2); /// Adds a quadratic bezier segment that curves from the current /// point to the point at the offset (x2,y2) from the current point, /// using the control point at the offset (x1,y1) from the current /// point. - void relativeQuadraticBezierTo(double/*!*/ x1, double/*!*/ y1, double/*!*/ x2, double/*!*/ y2); + void relativeQuadraticBezierTo(double x1, double y1, double x2, double y2); /// Adds a cubic bezier segment that curves from the current point /// to the given point (x3,y3), using the control points (x1,y1) and /// (x2,y2). void cubicTo( - double/*!*/ x1, double/*!*/ y1, double/*!*/ x2, double/*!*/ y2, double/*!*/ x3, double/*!*/ y3); + double x1, double y1, double x2, double y2, double x3, double y3); /// Adds a cubic bezier segment that curves from the current point /// to the point at the offset (x3,y3) from the current point, using /// the control points at the offsets (x1,y1) and (x2,y2) from the /// current point. void relativeCubicTo( - double/*!*/ x1, double/*!*/ y1, double/*!*/ x2, double/*!*/ y2, double/*!*/ x3, double/*!*/ y3); + double x1, double y1, double x2, double y2, double x3, double y3); /// Adds a bezier segment that curves from the current point to the /// given point (x2,y2), using the control points (x1,y1) and the /// weight w. If the weight is greater than 1, then the curve is a /// hyperbola; if the weight equals 1, it's a parabola; and if it is /// less than 1, it is an ellipse. - void conicTo(double/*!*/ x1, double/*!*/ y1, double/*!*/ x2, double/*!*/ y2, double/*!*/ w); + void conicTo(double x1, double y1, double x2, double y2, double w); /// Adds a bezier segment that curves from the current point to the /// point at the offset (x2,y2) from the current point, using the @@ -101,7 +101,7 @@ abstract class Path { /// the weight w. If the weight is greater than 1, then the curve is /// a hyperbola; if the weight equals 1, it's a parabola; and if it /// is less than 1, it is an ellipse. - void relativeConicTo(double/*!*/ x1, double/*!*/ y1, double/*!*/ x2, double/*!*/ y2, double/*!*/ w); + void relativeConicTo(double x1, double y1, double x2, double y2, double w); /// If the `forceMoveTo` argument is false, adds a straight line /// segment and an arc segment. @@ -120,7 +120,7 @@ abstract class Path { /// The line segment added if `forceMoveTo` is false starts at the /// current point and ends at the start of the arc. void arcTo( - Rect/*!*/ rect, double/*!*/ startAngle, double/*!*/ sweepAngle, bool/*!*/ forceMoveTo); + Rect rect, double startAngle, double sweepAngle, bool forceMoveTo); /// Appends up to four conic curves weighted to describe an oval of `radius` /// and rotated by `rotation`. @@ -138,11 +138,11 @@ abstract class Path { /// https://www.w3.org/TR/SVG/implnote.html#ArcConversionEndpointToCenter /// as reference for implementation. void arcToPoint( - Offset/*!*/ arcEnd, { - Radius/*!*/ radius = Radius.zero, - double/*!*/ rotation = 0.0, - bool/*!*/ largeArc = false, - bool/*!*/ clockwise = true, + Offset arcEnd, { + Radius radius = Radius.zero, + double rotation = 0.0, + bool largeArc = false, + bool clockwise = true, }); /// Appends up to four conic curves weighted to describe an oval of `radius` @@ -160,16 +160,16 @@ abstract class Path { /// fit the last path point if both are greater than zero but too small to /// describe an arc. void relativeArcToPoint( - Offset/*!*/ arcEndDelta, { - Radius/*!*/ radius = Radius.zero, - double/*!*/ rotation = 0.0, - bool/*!*/ largeArc = false, - bool/*!*/ clockwise = true, + Offset arcEndDelta, { + Radius radius = Radius.zero, + double rotation = 0.0, + bool largeArc = false, + bool clockwise = true, }); /// Adds a new subpath that consists of four lines that outline the /// given rectangle. - void addRect(Rect/*!*/ rect); + void addRect(Rect rect); /// Adds a new subpath that consists of a curve that forms the /// ellipse that fills the given rectangle. @@ -177,7 +177,7 @@ abstract class Path { /// To add a circle, pass an appropriate rectangle as `oval`. /// [Rect.fromCircle] can be used to easily describe the circle's center /// [Offset] and radius. - void addOval(Rect/*!*/ oval); + void addOval(Rect oval); /// Adds a new subpath with one arc segment that consists of the arc /// that follows the edge of the oval bounded by the given @@ -187,7 +187,7 @@ abstract class Path { /// crosses the horizontal line that intersects the center of the /// rectangle and with positive angles going clockwise around the /// oval. - void addArc(Rect/*!*/ oval, double/*!*/ startAngle, double/*!*/ sweepAngle); + void addArc(Rect oval, double startAngle, double sweepAngle); /// Adds a new subpath with a sequence of line segments that connect the given /// points. @@ -196,12 +196,12 @@ abstract class Path { /// last point to the first point. /// /// The `points` argument is interpreted as offsets from the origin. - void addPolygon(List/*!*/ points, bool/*!*/ close); + void addPolygon(List points, bool close); /// Adds a new subpath that consists of the straight lines and /// curves needed to form the rounded rectangle described by the /// argument. - void addRRect(RRect/*!*/ rrect); + void addRRect(RRect rrect); /// Adds a new subpath that consists of the given `path` offset by the given /// `offset`. @@ -209,7 +209,7 @@ abstract class Path { /// If `matrix4` is specified, the path will be transformed by this matrix /// after the matrix is translated by the given offset. The matrix is a 4x4 /// matrix stored in column major order. - void addPath(Path/*!*/ path, Offset/*!*/ offset, {Float64List/*?*/ matrix4}); + void addPath(Path path, Offset offset, {Float64List? matrix4}); /// Adds the given path to this path by extending the current segment of this /// path with the first segment of the given path. @@ -217,7 +217,7 @@ abstract class Path { /// If `matrix4` is specified, the path will be transformed by this matrix /// after the matrix is translated by the given `offset`. The matrix is a 4x4 /// matrix stored in column major order. - void extendWithPath(Path/*!*/ path, Offset/*!*/ offset, {Float64List/*?*/ matrix4}); + void extendWithPath(Path path, Offset offset, {Float64List? matrix4}); /// Closes the last subpath, as if a straight line had been drawn /// from the current point to the first point of the subpath. @@ -235,15 +235,15 @@ abstract class Path { /// The `point` argument is interpreted as an offset from the origin. /// /// Returns true if the point is in the path, and false otherwise. - bool/*!*/ contains(Offset/*!*/ point); + bool contains(Offset point); /// Returns a copy of the path with all the segments of every /// subpath translated by the given offset. - Path/*!*/ shift(Offset/*!*/ offset); + Path shift(Offset offset); /// Returns a copy of the path with all the segments of every /// sub path transformed by the given matrix. - Path/*!*/ transform(Float64List/*!*/ matrix4); + Path transform(Float64List matrix4); /// Computes the bounding rectangle for this path. /// @@ -260,7 +260,7 @@ abstract class Path { /// therefore ends up grossly overestimating the actual area covered by the /// circle. // see https://skia.org/user/api/SkPath_Reference#SkPath_getBounds - Rect/*!*/ getBounds(); + Rect getBounds(); /// Combines the two paths according to the manner specified by the given /// `operation`. @@ -268,9 +268,9 @@ abstract class Path { /// The resulting path will be constructed from non-overlapping contours. The /// curve order is reduced where possible so that cubics may be turned into /// quadratics, and quadratics maybe turned into lines. - static Path/*!*/ combine(PathOperation/*!*/ operation, Path/*!*/ path1, Path/*!*/ path2) { - assert(path1 != null); - assert(path2 != null); + static Path combine(PathOperation operation, Path path1, Path path2) { + assert(path1 != null); // ignore: unnecessary_null_comparison + assert(path2 != null); // ignore: unnecessary_null_comparison if (engine.experimentalUseSkia) { return engine.SkPath.combine(operation, path1, path2); } @@ -281,5 +281,5 @@ abstract class Path { /// /// If `forceClosed` is set to true, the contours of the path will be measured /// as if they had been closed, even if they were not explicitly closed. - PathMetrics computeMetrics({bool/*!*/ forceClosed = false}); + PathMetrics computeMetrics({bool forceClosed = false}); } diff --git a/lib/web_ui/lib/src/ui/path_metrics.dart b/lib/web_ui/lib/src/ui/path_metrics.dart index 65404001ac396..6d54888c2750d 100644 --- a/lib/web_ui/lib/src/ui/path_metrics.dart +++ b/lib/web_ui/lib/src/ui/path_metrics.dart @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.6 +// @dart = 2.9 part of ui; /// An iterable collection of [PathMetric] objects describing a [Path]. @@ -22,17 +22,17 @@ part of ui; /// use [toList] on this object. abstract class PathMetrics extends collection.IterableBase { @override - Iterator/*!*/ get iterator; + Iterator get iterator; } /// Used by [PathMetrics] to track iteration from one segment of a path to the /// next for measurement. abstract class PathMetricIterator implements Iterator { @override - PathMetric/*?*/ get current; + PathMetric get current; @override - bool/*!*/ moveNext(); + bool moveNext(); } /// Utilities for measuring a [Path] and extracting sub-paths. @@ -54,7 +54,7 @@ abstract class PathMetricIterator implements Iterator { /// to maintain consistency with native platforms. abstract class PathMetric { /// Return the total length of the current contour. - double/*!*/ get length; + double get length; /// The zero-based index of the contour. /// @@ -68,7 +68,7 @@ abstract class PathMetric { /// the contours of the path at the time the path's metrics were computed. If /// additional contours were added or existing contours updated, this metric /// will be invalid for the current state of the path. - int/*!*/ get contourIndex; + int get contourIndex; /// Computes the position of hte current contour at the given offset, and the /// angle of the path at that point. @@ -80,14 +80,14 @@ abstract class PathMetric { /// Returns null if the contour has zero [length]. /// /// The distance is clamped to the [length] of the current contour. - Tangent/*!*/ getTangentForOffset(double/*!*/ distance); + Tangent? getTangentForOffset(double distance); /// Given a start and stop distance, return the intervening segment(s). /// /// `start` and `end` are pinned to legal values (0..[length]) /// Returns null if the segment is 0 length or `start` > `stop`. /// Begin the segment with a moveTo if `startWithMoveTo` is true. - Path/*?*/ extractPath(double/*!*/ start, double/*!*/ end, {bool/*!*/ startWithMoveTo = true}); + Path? extractPath(double start, double end, {bool startWithMoveTo = true}); /// Whether the contour is closed. /// @@ -95,7 +95,7 @@ abstract class PathMetric { /// have been implied when using [Path.addRect]) or if `forceClosed` was /// specified as true in the call to [Path.computeMetrics]. Returns false /// otherwise. - bool/*!*/ get isClosed; + bool get isClosed; } /// The geometric description of a tangent: the angle at a point. @@ -108,14 +108,14 @@ class Tangent { /// /// The arguments must not be null. const Tangent(this.position, this.vector) - : assert(position != null), - assert(vector != null); + : assert(position != null), // ignore: unnecessary_null_comparison + assert(vector != null); // ignore: unnecessary_null_comparison /// Creates a [Tangent] based on the angle rather than the vector. /// /// The [vector] is computed to be the unit vector at the given angle, /// interpreted as clockwise radians from the x axis. - factory Tangent.fromAngle(Offset/*!*/ position, double/*!*/ angle) { + factory Tangent.fromAngle(Offset position, double angle) { return Tangent(position, Offset(math.cos(angle), math.sin(angle))); } @@ -123,14 +123,14 @@ class Tangent { /// /// When used with [PathMetric.getTangentForOffset], this represents the /// precise position that the given offset along the path corresponds to. - final Offset/*!*/ position; + final Offset position; /// The vector of the curve at [position]. /// /// When used with [PathMetric.getTangentForOffset], this is the vector of the /// curve that is at the given offset along the path (i.e. the direction of /// the curve at [position]). - final Offset/*!*/ vector; + final Offset vector; /// The direction of the curve at [position]. /// @@ -144,5 +144,5 @@ class Tangent { /// pointing upward toward the positive y-axis, i.e. in a counter-clockwise /// direction. // flip the sign to be consistent with [Path.arcTo]'s `sweepAngle` - double/*!*/ get angle => -math.atan2(vector.dy, vector.dx); + double get angle => -math.atan2(vector.dy, vector.dx); } diff --git a/lib/web_ui/lib/src/ui/pointer.dart b/lib/web_ui/lib/src/ui/pointer.dart index 9f4346aa4e99d..d541aba19f2d8 100644 --- a/lib/web_ui/lib/src/ui/pointer.dart +++ b/lib/web_ui/lib/src/ui/pointer.dart @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.6 +// @dart = 2.9 part of ui; /// How the pointer has changed since the last report. @@ -102,50 +102,50 @@ class PointerData { }); /// Time of event dispatch, relative to an arbitrary timeline. - final Duration/*!*/ timeStamp; + final Duration timeStamp; /// How the pointer has changed since the last report. - final PointerChange/*!*/ change; + final PointerChange change; /// The kind of input device for which the event was generated. - final PointerDeviceKind/*!*/ kind; + final PointerDeviceKind kind; /// The kind of signal for a pointer signal event. - final PointerSignalKind/*?*/ signalKind; + final PointerSignalKind? signalKind; /// Unique identifier for the pointing device, reused across interactions. - final int/*!*/ device; + final int device; /// Unique identifier for the pointer. /// /// This field changes for each new pointer down event. Framework uses this /// identifier to determine hit test result. - final int/*!*/ pointerIdentifier; + final int pointerIdentifier; /// X coordinate of the position of the pointer, in physical pixels in the /// global coordinate space. - final double/*!*/ physicalX; + final double physicalX; /// Y coordinate of the position of the pointer, in physical pixels in the /// global coordinate space. - final double/*!*/ physicalY; + final double physicalY; /// The distance of pointer movement on X coordinate in physical pixels. - final double/*!*/ physicalDeltaX; + final double physicalDeltaX; /// The distance of pointer movement on Y coordinate in physical pixels. - final double/*!*/ physicalDeltaY; + final double physicalDeltaY; /// Bit field using the *Button constants (primaryMouseButton, /// secondaryStylusButton, etc). For example, if this has the value 6 and the /// [kind] is [PointerDeviceKind.invertedStylus], then this indicates an /// upside-down stylus with both its primary and secondary buttons pressed. - final int/*!*/ buttons; + final int buttons; /// Set if an application from a different security domain is in any way /// obscuring this application's window. (Aspirational; not currently /// implemented.) - final bool/*!*/ obscured; + final bool obscured; /// Set if this pointer data was synthesized by pointer data packet converter. /// pointer data packet converter will synthesize additional pointer datas if @@ -153,34 +153,34 @@ class PointerData { /// /// For example, a down pointer data will be synthesized if the converter receives /// a move pointer data while the pointer is not previously down. - final bool/*!*/ synthesized; + final bool synthesized; /// The pressure of the touch as a number ranging from 0.0, indicating a touch /// with no discernible pressure, to 1.0, indicating a touch with "normal" /// pressure, and possibly beyond, indicating a stronger touch. For devices /// that do not detect pressure (e.g. mice), returns 1.0. - final double/*!*/ pressure; + final double pressure; /// The minimum value that [pressure] can return for this pointer. For devices /// that do not detect pressure (e.g. mice), returns 1.0. This will always be /// a number less than or equal to 1.0. - final double/*!*/ pressureMin; + final double pressureMin; /// The maximum value that [pressure] can return for this pointer. For devices /// that do not detect pressure (e.g. mice), returns 1.0. This will always be /// a greater than or equal to 1.0. - final double/*!*/ pressureMax; + final double pressureMax; /// The distance of the detected object from the input surface (e.g. the /// distance of a stylus or finger from a touch screen), in arbitrary units on /// an arbitrary (not necessarily linear) scale. If the pointer is down, this /// is 0.0 by definition. - final double/*!*/ distance; + final double distance; /// The maximum value that a distance can return for this pointer. If this /// input device cannot detect "hover touch" input events, then this will be /// 0.0. - final double/*!*/ distanceMax; + final double distanceMax; /// The area of the screen being pressed, scaled to a value between 0 and 1. /// The value of size can be used to determine fat touch events. This value @@ -188,21 +188,21 @@ class PointerData { /// the range of detectable values. So, for example, the value of 0.1 could /// mean a touch with the tip of the finger, 0.2 a touch with full finger, /// and 0.3 the full palm. - final double/*!*/ size; + final double size; /// The radius of the contact ellipse along the major axis, in logical pixels. - final double/*!*/ radiusMajor; + final double radiusMajor; /// The radius of the contact ellipse along the minor axis, in logical pixels. - final double/*!*/ radiusMinor; + final double radiusMinor; /// The minimum value that could be reported for radiusMajor and radiusMinor /// for this pointer, in logical pixels. - final double/*!*/ radiusMin; + final double radiusMin; /// The minimum value that could be reported for radiusMajor and radiusMinor /// for this pointer, in logical pixels. - final double/*!*/ radiusMax; + final double radiusMax; /// For PointerDeviceKind.touch events: /// @@ -229,7 +229,7 @@ class PointerData { /// indicate that the stylus would go down in the negative y-axis direction; /// pi/4 would indicate that the stylus goes up and to the right, -pi/2 would /// indicate that the stylus goes to the left, etc). - final double/*!*/ orientation; + final double orientation; /// For PointerDeviceKind.stylus and PointerDeviceKind.invertedStylus events: /// @@ -241,20 +241,20 @@ class PointerData { /// perpendicular to the input surface (thus 0.0 indicates the stylus is /// orthogonal to the plane of the input surface, while pi/2 indicates that /// the stylus is flat on that surface). - final double/*!*/ tilt; + final double tilt; /// Opaque platform-specific data associated with the event. - final int/*!*/ platformData; + final int platformData; /// For events with signalKind of PointerSignalKind.scroll: /// /// The amount to scroll in the x direction, in physical pixels. - final double/*!*/ scrollDeltaX; + final double scrollDeltaX; /// For events with signalKind of PointerSignalKind.scroll: /// /// The amount to scroll in the y direction, in physical pixels. - final double/*!*/ scrollDeltaY; + final double scrollDeltaY; @override String toString() => '$runtimeType(x: $physicalX, y: $physicalY)'; @@ -296,10 +296,10 @@ class PointerData { /// A sequence of reports about the state of pointers. class PointerDataPacket { /// Creates a packet of pointer data reports. - const PointerDataPacket({this.data = const []}) : assert(data != null); + const PointerDataPacket({this.data = const []}) : assert(data != null); // ignore: unnecessary_null_comparison /// Data about the individual pointers in this packet. /// /// This list might contain multiple pieces of data about the same pointer. - final List/*!*/ data; + final List data; } diff --git a/lib/web_ui/lib/src/ui/semantics.dart b/lib/web_ui/lib/src/ui/semantics.dart index 44b85ea08846b..c6dffe2fc1986 100644 --- a/lib/web_ui/lib/src/ui/semantics.dart +++ b/lib/web_ui/lib/src/ui/semantics.dart @@ -2,13 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.6 +// @dart = 2.9 part of ui; /// The possible actions that can be conveyed from the operating system /// accessibility APIs to a semantics node. class SemanticsAction { - const SemanticsAction._(this.index) : assert(index != null); + const SemanticsAction._(this.index) : assert(index != null); // ignore: unnecessary_null_comparison static const int _kTapIndex = 1 << 0; static const int _kLongPressIndex = 1 << 1; @@ -35,7 +35,7 @@ class SemanticsAction { /// The numerical value for this action. /// /// Each action has one bit set in this bit field. - final int/*!*/ index; + final int index; /// The equivalent of a user briefly tapping the screen with the finger /// without moving it. @@ -298,12 +298,12 @@ class SemanticsFlag { static const int _kIsFocusableIndex = 1 << 21; static const int _kIsLinkIndex = 1 << 22; - const SemanticsFlag._(this.index) : assert(index != null); + const SemanticsFlag._(this.index) : assert(index != null); // ignore: unnecessary_null_comparison /// The numerical value for this flag. /// /// Each flag has one bit set in this bit field. - final int/*!*/ index; + final int index; /// The semantics node has the quality of either being "checked" or "unchecked". /// @@ -667,32 +667,32 @@ class SemanticsUpdateBuilder { /// The `transform` is a matrix that maps this node's coordinate system into /// its parent's coordinate system. void updateNode({ - int/*!*/ id, - int/*!*/ flags, - int/*!*/ actions, - int/*!*/ maxValueLength, - int/*!*/ currentValueLength, - int/*!*/ textSelectionBase, - int/*!*/ textSelectionExtent, - int/*!*/ platformViewId, - int/*!*/ scrollChildren, - int/*!*/ scrollIndex, - double/*!*/ scrollPosition, - double/*!*/ scrollExtentMax, - double/*!*/ scrollExtentMin, - double/*!*/ elevation, - double/*!*/ thickness, - Rect/*!*/ rect, - String/*!*/ label, - String/*!*/ hint, - String/*!*/ value, - String/*!*/ increasedValue, - String/*!*/ decreasedValue, - TextDirection/*?*/ textDirection, - Float64List/*!*/ transform, - Int32List/*!*/ childrenInTraversalOrder, - Int32List/*!*/ childrenInHitTestOrder, - Int32List/*!*/ additionalActions, + required int id, + required int flags, + required int actions, + required int maxValueLength, + required int currentValueLength, + required int textSelectionBase, + required int textSelectionExtent, + required int platformViewId, + required int scrollChildren, + required int scrollIndex, + required double scrollPosition, + required double scrollExtentMax, + required double scrollExtentMin, + required double elevation, + required double thickness, + required Rect rect, + required String label, + required String hint, + required String value, + required String increasedValue, + required String decreasedValue, + TextDirection? textDirection, + required Float64List transform, + required Int32List childrenInTraversalOrder, + required Int32List childrenInHitTestOrder, + required Int32List additionalActions, }) { if (transform.length != 16) throw ArgumentError('transform argument must have 16 entries.'); @@ -727,7 +727,7 @@ class SemanticsUpdateBuilder { } void updateCustomAction( - {int/*!*/ id, String/*?*/ label, String/*?*/ hint, int/*!*/ overrideId = -1}) { + {required int id, String? label, String? hint, int overrideId = -1}) { // TODO(yjbanov): implement. } @@ -736,7 +736,7 @@ class SemanticsUpdateBuilder { /// /// The returned object can be passed to [Window.updateSemantics] to actually /// update the semantics retained by the system. - SemanticsUpdate/*!*/ build() { + SemanticsUpdate build() { return SemanticsUpdate._( nodeUpdates: _nodeUpdates, ); @@ -754,7 +754,7 @@ abstract class SemanticsUpdate { /// or extended directly. /// /// To create a SemanticsUpdate object, use a [SemanticsUpdateBuilder]. - factory SemanticsUpdate._({List nodeUpdates}) = + factory SemanticsUpdate._({List? nodeUpdates}) = engine.SemanticsUpdate; /// Releases the resources used by this semantics update. diff --git a/lib/web_ui/lib/src/ui/test_embedding.dart b/lib/web_ui/lib/src/ui/test_embedding.dart index 8191df5ec0fdc..f72a5c75e9ecc 100644 --- a/lib/web_ui/lib/src/ui/test_embedding.dart +++ b/lib/web_ui/lib/src/ui/test_embedding.dart @@ -4,17 +4,17 @@ // TODO(flutter_web): the Web-only API below need to be cleaned up. -// @dart = 2.6 +// @dart = 2.9 part of ui; /// Used to track when the platform is initialized. This ensures the test fonts /// are available. -Future _testPlatformInitializedFuture; +Future? _testPlatformInitializedFuture; /// If the platform is already initialized (by a previous test), then run the test /// body immediately. Otherwise, initialize the platform then run the test. -Future/*!*/ ensureTestPlatformInitializedThenRunTest( - dynamic Function()/*!*/ body) { +Future ensureTestPlatformInitializedThenRunTest( + dynamic Function() body) { if (_testPlatformInitializedFuture == null) { debugEmulateFlutterTesterEnvironment = true; @@ -22,16 +22,16 @@ Future/*!*/ ensureTestPlatformInitializedThenRunTest( _testPlatformInitializedFuture = webOnlyInitializePlatform( assetManager: engine.WebOnlyMockAssetManager()); } - return _testPlatformInitializedFuture.then((_) => body()); + return _testPlatformInitializedFuture!.then((_) => body()); } /// Used to track when the platform is initialized. This ensures the test fonts /// are available. // TODO(yjbanov): can we make this late non-null? See https://github.com/dart-lang/sdk/issues/42214 -Future/*?*/ _platformInitializedFuture; +Future? _platformInitializedFuture; /// Initializes domRenderer with specific devicePixelRatio and physicalSize. -Future/*!*/ webOnlyInitializeTestDomRenderer({double/*!*/ devicePixelRatio = 3.0}) { +Future webOnlyInitializeTestDomRenderer({double devicePixelRatio = 3.0}) { // Force-initialize DomRenderer so it doesn't overwrite test pixel ratio. engine.domRenderer; @@ -45,7 +45,7 @@ Future/*!*/ webOnlyInitializeTestDomRenderer({double/*!*/ devicePixelRatio debugEmulateFlutterTesterEnvironment = true; if (_platformInitializedFuture != null) { - return _platformInitializedFuture; + return _platformInitializedFuture!; } // Only load the Ahem font once and await the same future in all tests. diff --git a/lib/web_ui/lib/src/ui/text.dart b/lib/web_ui/lib/src/ui/text.dart index fabb54565325c..9fe24e78323ee 100644 --- a/lib/web_ui/lib/src/ui/text.dart +++ b/lib/web_ui/lib/src/ui/text.dart @@ -3,7 +3,7 @@ // found in the LICENSE file. // Synced 2019-05-30T14:20:57.833907. -// @dart = 2.6 +// @dart = 2.9 part of ui; /// Whether to slant the glyphs in the font @@ -63,7 +63,7 @@ class FontWeight { const FontWeight._(this.index); /// The encoded integer value of this font weight. - final int/*!*/ index; + final int index; /// Thin, the least thick static const FontWeight w100 = FontWeight._(0); @@ -99,7 +99,7 @@ class FontWeight { static const FontWeight bold = w700; /// A list of all the font weights. - static const List values = [ + static const List values = [ w100, w200, w300, @@ -131,15 +131,15 @@ class FontWeight { /// /// Values for `t` are usually obtained from an [Animation], such as /// an [AnimationController]. - static FontWeight/*?*/ lerp(FontWeight/*?*/ a, FontWeight/*?*/ b, double/*!*/ t) { - assert(t != null); + static FontWeight? lerp(FontWeight? a, FontWeight? b, double t) { + assert(t != null); // ignore: unnecessary_null_comparison if (a == null && b == null) return null; - return values[_clampInt(lerpDouble(a?.index ?? normal.index, b?.index ?? normal.index, t).round(), 0, 8)]; + return values[_clampInt(lerpDouble(a?.index ?? normal.index, b?.index ?? normal.index, t)!.round(), 0, 8)]; } @override - String/*!*/ toString() { + String toString() { return const { 0: 'FontWeight.w100', 1: 'FontWeight.w200', @@ -150,7 +150,7 @@ class FontWeight { 6: 'FontWeight.w700', 7: 'FontWeight.w800', 8: 'FontWeight.w900', - }[index]; + }[index]!; } } @@ -168,9 +168,9 @@ class FontFeature { /// /// See const FontFeature(this.feature, [this.value = 1]) - : assert(feature != null), + : assert(feature != null), // ignore: unnecessary_null_comparison assert(feature.length == 4), - assert(value != null), + assert(value != null), // ignore: unnecessary_null_comparison assert(value >= 0); /// Create a [FontFeature] object that enables the feature with the given tag. @@ -200,7 +200,7 @@ class FontFeature { /// See also: /// /// * - factory FontFeature.stylisticSet(int/*!*/ value) { + factory FontFeature.stylisticSet(int value) { assert(value >= 1); assert(value <= 20); return FontFeature('ss${value.toString().padLeft(2, "0")}'); @@ -271,16 +271,16 @@ class FontFeature { /// ASCII characters (typically lowercase letters). /// /// See - final String/*!*/ feature; + final String feature; /// The value assigned to this feature. /// /// Must be a positive integer. Many features are Boolean values that accept /// values of either 0 (feature is disabled) or 1 (feature is enabled). - final int/*!*/ value; + final int value; @override - bool/*!*/ operator ==(dynamic other) { + bool operator ==(dynamic other) { if (identical(this, other)) { return true; } @@ -292,10 +292,10 @@ class FontFeature { } @override - int/*!*/ get hashCode => hashValues(feature, value); + int get hashCode => hashValues(feature, value); @override - String/*!*/ toString() => 'FontFeature($feature, $value)'; + String toString() => 'FontFeature($feature, $value)'; } /// Whether and how to align text horizontally. @@ -345,7 +345,7 @@ class TextDecoration { const TextDecoration._(this._mask); /// Creates a decoration that paints the union of all the given decorations. - factory TextDecoration.combine(List/*!*/ decorations) { + factory TextDecoration.combine(List decorations) { int mask = 0; for (TextDecoration decoration in decorations) { mask |= decoration._mask; @@ -353,10 +353,10 @@ class TextDecoration { return TextDecoration._(mask); } - final int/*!*/ _mask; + final int _mask; /// Whether this decoration will paint at least as much decoration as the given decoration. - bool/*!*/ contains(TextDecoration/*!*/ other) { + bool contains(TextDecoration other) { return (_mask | other._mask) == _mask; } @@ -373,7 +373,7 @@ class TextDecoration { static const TextDecoration lineThrough = TextDecoration._(0x4); @override - bool/*!*/ operator ==(dynamic other) { + bool operator ==(dynamic other) { if (other is! TextDecoration) { return false; } @@ -382,10 +382,10 @@ class TextDecoration { } @override - int/*!*/ get hashCode => _mask.hashCode; + int get hashCode => _mask.hashCode; @override - String/*!*/ toString() { + String toString() { if (_mask == 0) { return 'TextDecoration.none'; } @@ -451,7 +451,7 @@ class TextHeightBehavior { /// Creates a new TextHeightBehavior object from an encoded form. /// /// See [encode] for the creation of the encoded form. - const TextHeightBehavior.fromEncoded(int/*!*/ encoded) + const TextHeightBehavior.fromEncoded(int encoded) : applyHeightToFirstAscent = (encoded & 0x1) == 0, applyHeightToLastDescent = (encoded & 0x2) == 0; @@ -466,7 +466,7 @@ class TextHeightBehavior { /// This property only has effect if a non-null [TextStyle.height] is specified. /// /// Defaults to true (height modifications applied as normal). - final bool/*!*/ applyHeightToFirstAscent; + final bool applyHeightToFirstAscent; /// Whether to apply the [TextStyle.height] modifier to the descent of the last /// line in the paragraph. @@ -478,15 +478,15 @@ class TextHeightBehavior { /// This property only has effect if a non-null [TextStyle.height] is specified. /// /// Defaults to true (height modifications applied as normal). - final bool/*!*/ applyHeightToLastDescent; + final bool applyHeightToLastDescent; /// Returns an encoded int representation of this object. - int/*!*/ encode() { + int encode() { return (applyHeightToFirstAscent ? 0 : 1 << 0) | (applyHeightToLastDescent ? 0 : 1 << 1); } @override - bool/*!*/ operator ==(dynamic other) { + bool operator ==(dynamic other) { if (other.runtimeType != runtimeType) return false; return other is TextHeightBehavior @@ -495,7 +495,7 @@ class TextHeightBehavior { } @override - int/*!*/ get hashCode { + int get hashCode { return hashValues( applyHeightToFirstAscent, applyHeightToLastDescent, @@ -503,7 +503,7 @@ class TextHeightBehavior { } @override - String/*!*/ toString() { + String toString() { return 'TextHeightBehavior(' 'applyHeightToFirstAscent: $applyHeightToFirstAscent, ' 'applyHeightToLastDescent: $applyHeightToLastDescent' @@ -539,25 +539,25 @@ abstract class TextStyle { /// * `background`: The paint drawn as a background for the text. /// * `foreground`: The paint used to draw the text. If this is specified, `color` must be null. factory TextStyle({ - Color/*?*/ color, - TextDecoration/*?*/ decoration, - Color/*?*/ decorationColor, - TextDecorationStyle/*?*/ decorationStyle, - double/*?*/ decorationThickness, - FontWeight/*?*/ fontWeight, - FontStyle/*?*/ fontStyle, - TextBaseline/*?*/ textBaseline, - String/*?*/ fontFamily, - List/*?*/ fontFamilyFallback, - double/*?*/ fontSize, - double/*?*/ letterSpacing, - double/*?*/ wordSpacing, - double/*?*/ height, - Locale/*?*/ locale, - Paint/*?*/ background, - Paint/*?*/ foreground, - List/*?*/ shadows, - List/*?*/ fontFeatures, + Color? color, + TextDecoration? decoration, + Color? decorationColor, + TextDecorationStyle? decorationStyle, + double? decorationThickness, + FontWeight? fontWeight, + FontStyle? fontStyle, + TextBaseline? textBaseline, + String? fontFamily, + List? fontFamilyFallback, + double? fontSize, + double? letterSpacing, + double? wordSpacing, + double? height, + Locale? locale, + Paint? background, + Paint? foreground, + List? shadows, + List? fontFeatures, }) { if (engine.experimentalUseSkia) { return engine.SkTextStyle( @@ -576,8 +576,8 @@ abstract class TextStyle { wordSpacing: wordSpacing, height: height, locale: locale, - background: background, - foreground: foreground, + background: background as engine.SkPaint?, + foreground: foreground as engine.SkPaint?, shadows: shadows, fontFeatures: fontFeatures, ); @@ -665,18 +665,18 @@ abstract class ParagraphStyle { /// /// * `locale`: The locale used to select region-specific glyphs. factory ParagraphStyle({ - TextAlign/*?*/ textAlign, - TextDirection/*?*/ textDirection, - int/*?*/ maxLines, - String/*?*/ fontFamily, - double/*?*/ fontSize, - double/*?*/ height, - TextHeightBehavior/*?*/ textHeightBehavior, - FontWeight/*?*/ fontWeight, - FontStyle/*?*/ fontStyle, - StrutStyle/*?*/ strutStyle, - String/*?*/ ellipsis, - Locale/*?*/ locale, + TextAlign? textAlign, + TextDirection? textDirection, + int? maxLines, + String? fontFamily, + double? fontSize, + double? height, + TextHeightBehavior? textHeightBehavior, + FontWeight? fontWeight, + FontStyle? fontStyle, + StrutStyle? strutStyle, + String? ellipsis, + Locale? locale, }) { if (engine.experimentalUseSkia) { return engine.SkParagraphStyle( @@ -749,14 +749,14 @@ abstract class StrutStyle { /// of the [fontFamily] and `(lineHeight + leading) * fontSize`. Otherwise, it /// will be determined by the Ascent + half-leading of the first text. factory StrutStyle({ - String/*?*/ fontFamily, - List/*?*/ fontFamilyFallback, - double/*?*/ fontSize, - double/*?*/ height, - double/*?*/ leading, - FontWeight/*?*/ fontWeight, - FontStyle/*?*/ fontStyle, - bool/*?*/ forceStrutHeight, + String? fontFamily, + List? fontFamilyFallback, + double? fontSize, + double? height, + double? leading, + FontWeight? fontWeight, + FontStyle? fontStyle, + bool? forceStrutHeight, }) = engine.EngineStrutStyle; } @@ -869,31 +869,31 @@ class TextBox { /// The left edge of the text box, irrespective of direction. /// /// To get the leading edge (which may depend on the [direction]), consider [start]. - final double/*!*/ left; + final double left; /// The top edge of the text box. - final double/*!*/ top; + final double top; /// The right edge of the text box, irrespective of direction. /// /// To get the trailing edge (which may depend on the [direction]), consider [end]. - final double/*!*/ right; + final double right; /// The bottom edge of the text box. - final double/*!*/ bottom; + final double bottom; /// The direction in which text inside this box flows. - final TextDirection/*!*/ direction; + final TextDirection direction; /// Returns a rect of the same size as this box. - Rect/*!*/ toRect() => Rect.fromLTRB(left, top, right, bottom); + Rect toRect() => Rect.fromLTRB(left, top, right, bottom); /// The [left] edge of the box for left-to-right text; the [right] edge of the box for right-to-left text. /// /// See also: /// /// * [direction], which specifies the text direction. - double/*!*/ get start { + double get start { return (direction == TextDirection.ltr) ? left : right; } @@ -902,12 +902,12 @@ class TextBox { /// See also: /// /// * [direction], which specifies the text direction. - double/*!*/ get end { + double get end { return (direction == TextDirection.ltr) ? right : left; } @override - bool/*!*/ operator ==(dynamic other) { + bool operator ==(dynamic other) { if (identical(this, other)) { return true; } @@ -923,10 +923,10 @@ class TextBox { } @override - int/*!*/ get hashCode => hashValues(left, top, right, bottom, direction); + int get hashCode => hashValues(left, top, right, bottom, direction); @override - String/*!*/ toString() { + String toString() { return 'TextBox.fromLTRBD(${left.toStringAsFixed(1)}, ${top.toStringAsFixed(1)}, ${right.toStringAsFixed(1)}, ${bottom.toStringAsFixed(1)}, $direction)'; } } @@ -1000,10 +1000,10 @@ class TextPosition { /// /// The arguments must not be null (so the [offset] argument is required). const TextPosition({ - this.offset, + required this.offset, this.affinity = TextAffinity.downstream, - }) : assert(offset != null), - assert(affinity != null); + }) : assert(offset != null), // ignore: unnecessary_null_comparison + assert(affinity != null); // ignore: unnecessary_null_comparison /// The index of the character that immediately follows the position in the /// string representation of the text. @@ -1011,7 +1011,7 @@ class TextPosition { /// For example, given the string `'Hello'`, offset 0 represents the cursor /// being before the `H`, while offset 5 represents the cursor being just /// after the `o`. - final int/*!*/ offset; + final int offset; /// Disambiguates cases where the position in the string given by [offset] /// could represent two different visual positions in the rendered text. For @@ -1020,10 +1020,10 @@ class TextPosition { /// /// See the documentation for [TextAffinity] for more information on how /// TextAffinity disambiguates situations like these. - final TextAffinity/*!*/ affinity; + final TextAffinity affinity; @override - bool/*!*/ operator ==(dynamic other) { + bool operator ==(dynamic other) { if (other.runtimeType != runtimeType) { return false; } @@ -1032,10 +1032,10 @@ class TextPosition { } @override - int/*!*/ get hashCode => hashValues(offset, affinity); + int get hashCode => hashValues(offset, affinity); @override - String/*!*/ toString() { + String toString() { return '$runtimeType(offset: $offset, affinity: $affinity)'; } } @@ -1050,16 +1050,16 @@ class TextRange { /// Instead of creating an empty text range, consider using the [empty] /// constant. const TextRange({ - this.start, - this.end, - }) : assert(start != null && start >= -1), - assert(end != null && end >= -1); + required this.start, + required this.end, + }) : assert(start != null && start >= -1), // ignore: unnecessary_null_comparison + assert(end != null && end >= -1); // ignore: unnecessary_null_comparison /// A text range that starts and ends at offset. /// /// The [offset] argument must be non-null and greater than or equal to -1. const TextRange.collapsed(int offset) - : assert(offset != null && offset >= -1), + : assert(offset != null && offset >= -1), // ignore: unnecessary_null_comparison start = offset, end = offset; @@ -1069,42 +1069,42 @@ class TextRange { /// The index of the first character in the range. /// /// If [start] and [end] are both -1, the text range is empty. - final int/*!*/ start; + final int start; /// The next index after the characters in this range. /// /// If [start] and [end] are both -1, the text range is empty. - final int/*!*/ end; + final int end; /// Whether this range represents a valid position in the text. - bool/*!*/ get isValid => start >= 0 && end >= 0; + bool get isValid => start >= 0 && end >= 0; /// Whether this range is empty (but still potentially placed inside the text). - bool/*!*/ get isCollapsed => start == end; + bool get isCollapsed => start == end; /// Whether the start of this range precedes the end. - bool/*!*/ get isNormalized => end >= start; + bool get isNormalized => end >= start; /// The text before this range. - String/*!*/ textBefore(String/*!*/ text) { + String textBefore(String text) { assert(isNormalized); return text.substring(0, start); } /// The text after this range. - String/*!*/ textAfter(String/*!*/ text) { + String textAfter(String text) { assert(isNormalized); return text.substring(end); } /// The text inside this range. - String/*!*/ textInside(String/*!*/ text) { + String textInside(String text) { assert(isNormalized); return text.substring(start, end); } @override - bool/*!*/ operator ==(dynamic other) { + bool operator ==(dynamic other) { if (identical(this, other)) { return true; } @@ -1116,13 +1116,13 @@ class TextRange { } @override - int/*!*/ get hashCode => hashValues( + int get hashCode => hashValues( start.hashCode, end.hashCode, ); @override - String/*!*/ toString() => 'TextRange(start: $start, end: $end)'; + String toString() => 'TextRange(start: $start, end: $end)'; } /// Layout constraints for [Paragraph] objects. @@ -1136,8 +1136,8 @@ class ParagraphConstraints { /// /// The [width] argument must not be null. const ParagraphConstraints({ - this.width, - }) : assert(width != null); + required this.width, + }) : assert(width != null); // ignore: unnecessary_null_comparison /// The width the paragraph should use whey computing the positions of glyphs. /// @@ -1156,10 +1156,10 @@ class ParagraphConstraints { /// This width is also used to position glyphs according to the [TextAlign] /// alignment described in the [ParagraphStyle] used when building the /// [Paragraph] with a [ParagraphBuilder]. - final double/*!*/ width; + final double width; @override - bool/*!*/ operator ==(dynamic other) { + bool operator ==(dynamic other) { if (other.runtimeType != runtimeType) { return false; } @@ -1168,10 +1168,10 @@ class ParagraphConstraints { } @override - int/*!*/ get hashCode => width.hashCode; + int get hashCode => width.hashCode; @override - String/*!*/ toString() => '$runtimeType(width: $width)'; + String toString() => '$runtimeType(width: $width)'; } /// Defines various ways to vertically bound the boxes returned by @@ -1245,22 +1245,22 @@ enum BoxWidthStyle { abstract class LineMetrics { factory LineMetrics({ - bool hardBreak, - double ascent, - double descent, - double unscaledAscent, - double height, - double width, - double left, - double baseline, - int lineNumber, + required bool hardBreak, + required double ascent, + required double descent, + required double unscaledAscent, + required double height, + required double width, + required double left, + required double baseline, + required int lineNumber, }) = engine.EngineLineMetrics; /// {@template dart.ui.LineMetrics.hardBreak} /// True if this line ends with an explicit line break (e.g. '\n') or is the end /// of the paragraph. False otherwise. /// {@endtemplate} - final bool/*!*/ hardBreak; + bool get hardBreak; /// {@template dart.ui.LineMetrics.ascent} /// The rise from the [baseline] as calculated from the font and style for this line. @@ -1273,7 +1273,7 @@ abstract class LineMetrics { /// metrics directly reflects the intended signage of the value. For example, /// the y coordinate of the top edge of the line is `baseline - ascent`. /// {@endtemplate} - final double/*!*/ ascent; + double get ascent; /// {@template dart.ui.LineMetrics.descent} /// The drop from the [baseline] as calculated from the font and style for this line. @@ -1283,7 +1283,7 @@ abstract class LineMetrics { /// /// The y coordinate of the bottom edge of the line is `baseline + descent`. /// {@endtemplate} - final double/*!*/ descent; + double get descent; /// {@template dart.ui.LineMetrics.unscaledAscent} /// The rise from the [baseline] as calculated from the font and style for this line @@ -1293,7 +1293,7 @@ abstract class LineMetrics { /// defined in fonts as negative. This is to ensure the signage of operations with /// these metrics directly reflects the intended signage of the value. /// {@endtemplate} - final double/*!*/ unscaledAscent; + double get unscaledAscent; /// {@template dart.ui.LineMetrics.height} /// Total height of the line from the top edge to the bottom edge. @@ -1302,7 +1302,7 @@ abstract class LineMetrics { /// separately due to rounding causing sub-pixel differences from the unrounded /// values. /// {@endtemplate} - final double/*!*/ height; + double get height; /// {@template dart.ui.LineMetrics.width} /// Width of the line from the left edge of the leftmost glyph to the right @@ -1315,14 +1315,14 @@ abstract class LineMetrics { /// * [Paragraph.width], the max width passed in during layout. /// * [Paragraph.longestLine], the width of the longest line in the paragraph. /// {@endtemplate} - final double/*!*/ width; + double get width; /// {@template dart.ui.LineMetrics.left} /// The x coordinate of left edge of the line. /// /// The right edge can be obtained with `left + width`. /// {@endtemplate} - final double/*!*/ left; + double get left; /// {@template dart.ui.LineMetrics.baseline} /// The y coordinate of the baseline for this line from the top of the paragraph. @@ -1330,7 +1330,7 @@ abstract class LineMetrics { /// The bottom edge of the paragraph up to and including this line may be obtained /// through `baseline + descent`. /// {@endtemplate} - final double/*!*/ baseline; + double get baseline; /// {@template dart.ui.LineMetrics.lineNumber} /// The number of this line in the overall paragraph, with the first line being @@ -1338,7 +1338,7 @@ abstract class LineMetrics { /// /// For example, the first line is line 0, second line is line 1. /// {@endtemplate} - final int/*!*/ lineNumber; + int get lineNumber; } /// A paragraph of text. @@ -1354,18 +1354,18 @@ abstract class Paragraph { /// The amount of horizontal space this paragraph occupies. /// /// Valid only after [layout] has been called. - double/*!*/ get width; + double get width; /// The amount of vertical space this paragraph occupies. /// /// Valid only after [layout] has been called. - double/*!*/ get height; + double get height; /// The distance from the left edge of the leftmost glyph to the right edge of /// the rightmost glyph in the paragraph. /// /// Valid only after [layout] has been called. - double/*!*/ get longestLine; + double get longestLine; /// {@template dart.ui.paragraph.minIntrinsicWidth} /// The minimum width that this paragraph could be without failing to paint @@ -1373,7 +1373,7 @@ abstract class Paragraph { /// {@endtemplate} /// /// Valid only after [layout] has been called. - double/*!*/ get minIntrinsicWidth; + double get minIntrinsicWidth; /// {@template dart.ui.paragraph.maxIntrinsicWidth} /// Returns the smallest width beyond which increasing the width never @@ -1381,7 +1381,7 @@ abstract class Paragraph { /// {@endtemplate} /// /// Valid only after [layout] has been called. - double/*!*/ get maxIntrinsicWidth; + double get maxIntrinsicWidth; /// {@template dart.ui.paragraph.alphabeticBaseline} /// The distance from the top of the paragraph to the alphabetic @@ -1389,7 +1389,7 @@ abstract class Paragraph { /// {@endtemplate} /// /// Valid only after [layout] has been called. - double/*!*/ get alphabeticBaseline; + double get alphabeticBaseline; /// {@template dart.ui.paragraph.ideographicBaseline} /// The distance from the top of the paragraph to the ideographic @@ -1397,7 +1397,7 @@ abstract class Paragraph { /// {@endtemplate} /// /// Valid only after [layout] has been called. - double/*!*/ get ideographicBaseline; + double get ideographicBaseline; /// True if there is more vertical content, but the text was truncated, either /// because we reached `maxLines` lines of text or because the `maxLines` was @@ -1406,12 +1406,12 @@ abstract class Paragraph { /// /// See the discussion of the `maxLines` and `ellipsis` arguments at [new /// ParagraphStyle]. - bool/*!*/ get didExceedMaxLines; + bool get didExceedMaxLines; /// Computes the size and position of each glyph in the paragraph. /// /// The [ParagraphConstraints] control how wide the text is allowed to be. - void layout(ParagraphConstraints/*!*/ constraints); + void layout(ParagraphConstraints constraints); /// Returns a list of text boxes that enclose the given text range. /// @@ -1423,15 +1423,15 @@ abstract class Paragraph { /// The [boxHeightStyle] and [boxWidthStyle] parameters must not be null. /// /// See [BoxHeightStyle] and [BoxWidthStyle] for full descriptions of each option. - List/*!*/ getBoxesForRange(int/*!*/ start, int/*!*/ end, - {BoxHeightStyle/*!*/ boxHeightStyle = BoxHeightStyle.tight, - BoxWidthStyle/*!*/ boxWidthStyle = BoxWidthStyle.tight}); + List getBoxesForRange(int start, int end, + {BoxHeightStyle boxHeightStyle = BoxHeightStyle.tight, + BoxWidthStyle boxWidthStyle = BoxWidthStyle.tight}); /// Returns the text position closest to the given offset. /// /// It does so by performing a binary search to find where the tap occurred /// within the text. - TextPosition/*!*/ getPositionForOffset(Offset/*!*/ offset); + TextPosition getPositionForOffset(Offset offset); /// Returns the [TextRange] of the word at the given [TextPosition]. /// @@ -1439,7 +1439,7 @@ abstract class Paragraph { /// have word breaks on both sides. In such cases, this method will return /// [offset, offset+1]. Word boundaries are defined more precisely in Unicode /// Standard Annex #29 http://www.unicode.org/reports/tr29/#Word_Boundaries - TextRange/*!*/ getWordBoundary(TextPosition/*!*/ position); + TextRange getWordBoundary(TextPosition position); /// Returns the [TextRange] of the line at the given [TextPosition]. /// @@ -1449,7 +1449,7 @@ abstract class Paragraph { /// /// This can potentially be expensive, since it needs to compute the line /// metrics, so use it sparingly. - TextRange/*!*/ getLineBoundary(TextPosition/*!*/ position); + TextRange getLineBoundary(TextPosition position); /// Returns a list of text boxes that enclose all placeholders in the paragraph. /// @@ -1457,7 +1457,7 @@ abstract class Paragraph { /// /// Coordinates of the [TextBox] are relative to the upper-left corner of the paragraph, /// where positive y values indicate down. - List/*!*/ getBoxesForPlaceholders(); + List getBoxesForPlaceholders(); /// Returns the full list of [LineMetrics] that describe in detail the various /// metrics of each laid out line. @@ -1466,7 +1466,7 @@ abstract class Paragraph { /// /// This can potentially return a large amount of data, so it is not recommended /// to repeatedly call this. Instead, cache the results. - List/*!*/ computeLineMetrics(); + List computeLineMetrics(); } /// Builds a [Paragraph] containing text with the given styling information. @@ -1486,18 +1486,18 @@ abstract class Paragraph { abstract class ParagraphBuilder { /// Creates a [ParagraphBuilder] object, which is used to create a /// [Paragraph]. - factory ParagraphBuilder(ParagraphStyle/*!*/ style) { + factory ParagraphBuilder(ParagraphStyle style) { if (engine.experimentalUseSkia) { return engine.SkParagraphBuilder(style); } else { - return engine.EngineParagraphBuilder(style); + return engine.EngineParagraphBuilder(style as engine.EngineParagraphStyle); } } /// Applies the given style to the added text until [pop] is called. /// /// See [pop] for details. - void pushStyle(TextStyle/*!*/ style); + void pushStyle(TextStyle style); /// Ends the effect of the most recent call to [pushStyle]. /// @@ -1510,20 +1510,20 @@ abstract class ParagraphBuilder { /// Adds the given text to the paragraph. /// /// The text will be styled according to the current stack of text styles. - void addText(String/*!*/ text); + void addText(String text); /// Applies the given paragraph style and returns a [Paragraph] containing the /// added text and associated styling. /// /// After calling this function, the paragraph builder object is invalid and /// cannot be used further. - Paragraph/*!*/ build(); + Paragraph build(); /// The number of placeholders currently in the paragraph. - int/*!*/ get placeholderCount; + int get placeholderCount; /// The scales of the placeholders in the paragraph. - List/*!*/ get placeholderScales; + List get placeholderScales; /// Adds an inline placeholder space to the paragraph. /// @@ -1569,12 +1569,12 @@ abstract class ParagraphBuilder { /// in the text buffer. For each placeholder, one object replacement character is /// added on to the text buffer. void addPlaceholder( - double/*!*/ width, - double/*!*/ height, - PlaceholderAlignment/*!*/ alignment, { - double/*!*/ scale = 1.0, - double/*?*/ baselineOffset, - TextBaseline/*?*/ baseline, + double width, + double height, + PlaceholderAlignment alignment, { + double scale = 1.0, + double? baselineOffset, + TextBaseline? baseline, }); } @@ -1583,13 +1583,13 @@ abstract class ParagraphBuilder { /// * `list`: A list of bytes containing the font file. /// * `fontFamily`: The family name used to identify the font in text styles. /// If this is not provided, then the family name will be extracted from the font file. -Future/*!*/ loadFontFromList(Uint8List/*!*/ list, {String/*?*/ fontFamily}) { +Future loadFontFromList(Uint8List list, {String? fontFamily}) { if (engine.experimentalUseSkia) { return engine.skiaFontCollection.loadFontFromList(list, fontFamily: fontFamily).then( (_) => engine.sendFontChangeMessage() ); } else { - return _fontCollection.loadFontFromList(list, fontFamily: fontFamily).then( + return _fontCollection!.loadFontFromList(list, fontFamily: fontFamily!).then( (_) => engine.sendFontChangeMessage() ); } diff --git a/lib/web_ui/lib/src/ui/tile_mode.dart b/lib/web_ui/lib/src/ui/tile_mode.dart index 7722361fae801..8fd24ae586bc1 100644 --- a/lib/web_ui/lib/src/ui/tile_mode.dart +++ b/lib/web_ui/lib/src/ui/tile_mode.dart @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.6 +// @dart = 2.9 part of ui; /// Defines what happens at the edge of the gradient. diff --git a/lib/web_ui/lib/src/ui/window.dart b/lib/web_ui/lib/src/ui/window.dart index 023a6ebde9b12..ca49014d0c818 100644 --- a/lib/web_ui/lib/src/ui/window.dart +++ b/lib/web_ui/lib/src/ui/window.dart @@ -3,7 +3,7 @@ // found in the LICENSE file. // Synced 2019-05-30T14:20:57.841444. -// @dart = 2.6 +// @dart = 2.9 part of ui; /// Signature of callbacks that have no arguments and return no data. @@ -15,27 +15,27 @@ typedef VoidCallback = void Function(); /// scheduler's epoch. Use timeStamp to determine how far to advance animation /// timelines so that all the animations in the system are synchronized to a /// common time base. -typedef FrameCallback = void Function(Duration/*!*/ duration); +typedef FrameCallback = void Function(Duration duration); /// Signature for [Window.onReportTimings]. -typedef TimingsCallback = void Function(List/*!*/ timings); +typedef TimingsCallback = void Function(List timings); /// Signature for [Window.onPointerDataPacket]. -typedef PointerDataPacketCallback = void Function(PointerDataPacket/*!*/ packet); +typedef PointerDataPacketCallback = void Function(PointerDataPacket packet); /// Signature for [Window.onSemanticsAction]. typedef SemanticsActionCallback = void Function( - int/*!*/ id, SemanticsAction/*!*/ action, ByteData/*?*/ args); + int id, SemanticsAction action, ByteData? args); /// Signature for responses to platform messages. /// /// Used as a parameter to [Window.sendPlatformMessage] and /// [Window.onPlatformMessage]. -typedef PlatformMessageResponseCallback = void Function(ByteData/*?*/ data); +typedef PlatformMessageResponseCallback = void Function(ByteData? data); /// Signature for [Window.onPlatformMessage]. typedef PlatformMessageCallback = void Function( - String/*!*/ name, ByteData/*?*/ data, PlatformMessageResponseCallback/*?*/ callback); + String name, ByteData? data, PlatformMessageResponseCallback? callback); /// States that an application can be in. /// @@ -103,26 +103,26 @@ enum AppLifecycleState { /// applications. abstract class WindowPadding { const factory WindowPadding._( - {double left, - double top, - double right, - double bottom}) = engine.WindowPadding; + {required double left, + required double top, + required double right, + required double bottom}) = engine.WindowPadding; /// The distance from the left edge to the first unpadded pixel, in physical /// pixels. - final double/*!*/ left; + double get left; /// The distance from the top edge to the first unpadded pixel, in physical /// pixels. - final double/*!*/ top; + double get top; /// The distance from the right edge to the first unpadded pixel, in physical /// pixels. - final double/*!*/ right; + double get right; /// The distance from the bottom edge to the first unpadded pixel, in physical /// pixels. - final double/*!*/ bottom; + double get bottom; /// A window padding that has zeros for each edge. static const WindowPadding zero = @@ -187,7 +187,7 @@ class Locale { const Locale( this._languageCode, [ this._countryCode, - ]) : assert(_languageCode != null), + ]) : assert(_languageCode != null), // ignore: unnecessary_null_comparison assert(_languageCode != ''), scriptCode = null; @@ -208,10 +208,10 @@ class Locale { /// Validity is not checked by default, but some methods may throw away /// invalid data. const Locale.fromSubtags({ - String/*!*/ languageCode = 'und', + String languageCode = 'und', this.scriptCode, - String/*?*/ countryCode, - }) : assert(languageCode != null), + String? countryCode, + }) : assert(languageCode != null), // ignore: unnecessary_null_comparison assert(languageCode != ''), _languageCode = languageCode, assert(scriptCode != ''), @@ -241,8 +241,8 @@ class Locale { /// /// * [new Locale.fromSubtags], which describes the conventions for creating /// [Locale] objects. - String/*!*/ get languageCode => _deprecatedLanguageSubtagMap[_languageCode] ?? _languageCode; - final String/*!*/ _languageCode; + String get languageCode => _deprecatedLanguageSubtagMap[_languageCode] ?? _languageCode; + final String _languageCode; // This map is generated by //flutter/tools/gen_locale.dart // Mappings generated for language subtag registry as of 2019-02-27. @@ -339,7 +339,7 @@ class Locale { /// /// * [new Locale.fromSubtags], which describes the conventions for creating /// [Locale] objects. - final String/*?*/ scriptCode; + final String? scriptCode; /// The region subtag for the locale. /// @@ -360,8 +360,8 @@ class Locale { /// /// * [new Locale.fromSubtags], which describes the conventions for creating /// [Locale] objects. - String/*?*/ get countryCode => _deprecatedRegionSubtagMap[_countryCode] ?? _countryCode; - final String/*?*/ _countryCode; + String? get countryCode => _deprecatedRegionSubtagMap[_countryCode] ?? _countryCode; + final String? _countryCode; // This map is generated by //flutter/tools/gen_locale.dart // Mappings generated for language subtag registry as of 2019-02-27. @@ -375,7 +375,7 @@ class Locale { }; @override - bool/*!*/ operator ==(dynamic other) { + bool operator ==(dynamic other) { if (identical(this, other)) { return true; } @@ -389,15 +389,15 @@ class Locale { } @override - int/*!*/ get hashCode => hashValues(languageCode, scriptCode, countryCode); + int get hashCode => hashValues(languageCode, scriptCode, countryCode); @override - String/*!*/ toString() => _rawToString('_'); + String toString() => _rawToString('_'); // TODO(yjbanov): implement to match flutter native. String toLanguageTag() => _rawToString('-'); - String/*!*/ _rawToString(String separator) { + String _rawToString(String separator) { final StringBuffer out = StringBuffer(languageCode); if (scriptCode != null) { out.write('$separator$scriptCode'); @@ -437,7 +437,7 @@ abstract class Window { /// /// * [WidgetsBindingObserver], for a mechanism at the widgets layer to /// observe when this value changes. - double/*!*/ get devicePixelRatio; + double get devicePixelRatio; /// The dimensions of the rectangle into which the application will be drawn, /// in physical pixels. @@ -456,7 +456,7 @@ abstract class Window { /// /// * [WidgetsBindingObserver], for a mechanism at the widgets layer to /// observe when this value changes. - Size/*!*/ get physicalSize; + Size get physicalSize; /// The physical depth is the maximum elevation that the Window allows. /// @@ -469,7 +469,7 @@ abstract class Window { /// The default value is [double.maxFinite], which is used for platforms that /// do not specify a maximum elevation. This property is currently on expected /// to be set to a non-default value on Fuchsia. - double/*!*/ get physicalDepth; + double get physicalDepth; /// The number of physical pixels on each side of the display rectangle into /// which the application can render, but over which the operating system @@ -485,11 +485,11 @@ abstract class Window { /// * [MediaQuery.of], a simpler mechanism for the same. /// * [Scaffold], which automatically applies the view insets in material /// design applications. - WindowPadding/*!*/ get viewInsets => WindowPadding.zero; + WindowPadding get viewInsets => WindowPadding.zero; - WindowPadding/*!*/ get viewPadding => WindowPadding.zero; + WindowPadding get viewPadding => WindowPadding.zero; - WindowPadding/*!*/ get systemGestureInsets => WindowPadding.zero; + WindowPadding get systemGestureInsets => WindowPadding.zero; /// The number of physical pixels on each side of the display rectangle into /// which the application can render, but which may be partially obscured by @@ -506,7 +506,7 @@ abstract class Window { /// * [MediaQuery.of], a simpler mechanism for the same. /// * [Scaffold], which automatically applies the padding in material design /// applications. - WindowPadding/*!*/ get padding => WindowPadding.zero; + WindowPadding get padding => WindowPadding.zero; /// The system-reported text scale. /// @@ -520,15 +520,15 @@ abstract class Window { /// /// * [WidgetsBindingObserver], for a mechanism at the widgets layer to /// observe when this value changes. - double/*!*/ get textScaleFactor => _textScaleFactor; - double/*!*/ _textScaleFactor = 1.0; + double get textScaleFactor => _textScaleFactor; + double _textScaleFactor = 1.0; /// The setting indicating whether time should always be shown in the 24-hour /// format. /// /// This option is used by [showTimePicker]. - bool/*!*/ get alwaysUse24HourFormat => _alwaysUse24HourFormat; - bool/*!*/ _alwaysUse24HourFormat = false; + bool get alwaysUse24HourFormat => _alwaysUse24HourFormat; + bool _alwaysUse24HourFormat = false; /// A callback that is invoked whenever [textScaleFactor] changes value. /// @@ -539,11 +539,11 @@ abstract class Window { /// /// * [WidgetsBindingObserver], for a mechanism at the widgets layer to /// observe when this callback is invoked. - VoidCallback/*?*/ get onTextScaleFactorChanged; - set onTextScaleFactorChanged(VoidCallback/*?*/ callback); + VoidCallback? get onTextScaleFactorChanged; + set onTextScaleFactorChanged(VoidCallback? callback); /// The setting indicating the current brightness mode of the host platform. - Brightness/*!*/ get platformBrightness; + Brightness get platformBrightness; /// A callback that is invoked whenever [platformBrightness] changes value. /// @@ -554,8 +554,8 @@ abstract class Window { /// /// * [WidgetsBindingObserver], for a mechanism at the widgets layer to /// observe when this callback is invoked. - VoidCallback/*?*/ get onPlatformBrightnessChanged; - set onPlatformBrightnessChanged(VoidCallback/*?*/ callback); + VoidCallback? get onPlatformBrightnessChanged; + set onPlatformBrightnessChanged(VoidCallback? callback); /// A callback that is invoked whenever the [devicePixelRatio], /// [physicalSize], [padding], or [viewInsets] values change, for example @@ -573,8 +573,8 @@ abstract class Window { /// * [WidgetsBindingObserver], for a mechanism at the widgets layer to /// register for notifications when this is called. /// * [MediaQuery.of], a simpler mechanism for the same. - VoidCallback/*?*/ get onMetricsChanged; - set onMetricsChanged(VoidCallback/*?*/ callback); + VoidCallback? get onMetricsChanged; + set onMetricsChanged(VoidCallback? callback); /// The system-reported default locale of the device. /// @@ -586,7 +586,7 @@ abstract class Window { /// /// This is equivalent to `locales.first` and will provide an empty non-null locale /// if the [locales] list has not been set or is empty. - Locale/*?*/ get locale; + Locale? get locale; /// The full system-reported supported locales of the device. /// @@ -602,7 +602,7 @@ abstract class Window { /// /// * [WidgetsBindingObserver], for a mechanism at the widgets layer to /// observe when this value changes. - List/*?*/ get locales; + List? get locales; /// The locale that the platform's native locale resolution system resolves to. /// @@ -614,7 +614,7 @@ abstract class Window { /// in order to arrive at the most appropriate locale for the app. /// /// See [locales], which is the list of locales the user/device prefers. - Locale/*?*/ get platformResolvedLocale; + Locale? get platformResolvedLocale; /// Performs the platform-native locale resolution. /// @@ -624,7 +624,7 @@ abstract class Window { /// /// This method returns synchronously and is a direct call to /// platform specific APIs without invoking method channels. - Locale computePlatformResolvedLocale(List supportedLocales) { + Locale? computePlatformResolvedLocale(List supportedLocales) { // TODO(garyq): Implement on web. return null; } @@ -638,8 +638,8 @@ abstract class Window { /// /// * [WidgetsBindingObserver], for a mechanism at the widgets layer to /// observe when this callback is invoked. - VoidCallback/*?*/ get onLocaleChanged; - set onLocaleChanged(VoidCallback/*?*/ callback); + VoidCallback? get onLocaleChanged; + set onLocaleChanged(VoidCallback? callback); /// Requests that, at the next appropriate opportunity, the [onBeginFrame] /// and [onDrawFrame] callbacks be invoked. @@ -669,8 +669,8 @@ abstract class Window { /// scheduling of frames. /// * [RendererBinding], the Flutter framework class which manages layout and /// painting. - FrameCallback/*?*/ get onBeginFrame; - set onBeginFrame(FrameCallback/*?*/ callback); + FrameCallback? get onBeginFrame; + set onBeginFrame(FrameCallback? callback); /// A callback that is invoked to report the [FrameTiming] of recently /// rasterized frames. @@ -688,8 +688,8 @@ abstract class Window { /// decrease the overhead (as this is available in the release mode). The /// timing of any frame will be sent within about 1 second even if there are /// no later frames to batch. - TimingsCallback/*?*/ get onReportTimings; - set onReportTimings(TimingsCallback/*?*/ callback); + TimingsCallback? get onReportTimings; + set onReportTimings(TimingsCallback? callback); /// A callback that is invoked for each frame after [onBeginFrame] has /// completed and after the microtask queue has been drained. This can be @@ -705,8 +705,8 @@ abstract class Window { /// scheduling of frames. /// * [RendererBinding], the Flutter framework class which manages layout and /// painting. - VoidCallback/*?*/ get onDrawFrame; - set onDrawFrame(VoidCallback/*?*/ callback); + VoidCallback? get onDrawFrame; + set onDrawFrame(VoidCallback? callback); /// A callback that is invoked when pointer data is available. /// @@ -717,8 +717,8 @@ abstract class Window { /// /// * [GestureBinding], the Flutter framework class which manages pointer /// events. - PointerDataPacketCallback/*?*/ get onPointerDataPacket; - set onPointerDataPacket(PointerDataPacketCallback/*?*/ callback); + PointerDataPacketCallback? get onPointerDataPacket; + set onPointerDataPacket(PointerDataPacketCallback? callback); /// The route or path that the embedder requested when the application was /// launched. @@ -750,7 +750,7 @@ abstract class Window { /// * [Navigator], a widget that handles routing. /// * [SystemChannels.navigation], which handles subsequent navigation /// requests from the embedder. - String/*!*/ get defaultRouteName; + String get defaultRouteName; /// Whether the user has requested that [updateSemantics] be called when /// the semantic contents of window changes. @@ -760,15 +760,15 @@ abstract class Window { /// /// This defaults to `true` on the Web because we may never receive a signal /// that an assistive technology is turned on. - bool/*!*/ get semanticsEnabled => + bool get semanticsEnabled => engine.EngineSemanticsOwner.instance.semanticsEnabled; /// A callback that is invoked when the value of [semanticsEnabled] changes. /// /// The framework invokes this callback in the same zone in which the /// callback was set. - VoidCallback/*?*/ get onSemanticsEnabledChanged; - set onSemanticsEnabledChanged(VoidCallback/*?*/ callback); + VoidCallback? get onSemanticsEnabledChanged; + set onSemanticsEnabledChanged(VoidCallback? callback); /// A callback that is invoked whenever the user requests an action to be /// performed. @@ -778,15 +778,15 @@ abstract class Window { /// /// The framework invokes this callback in the same zone in which the /// callback was set. - SemanticsActionCallback/*?*/ get onSemanticsAction; - set onSemanticsAction(SemanticsActionCallback/*?*/ callback); + SemanticsActionCallback? get onSemanticsAction; + set onSemanticsAction(SemanticsActionCallback? callback); /// A callback that is invoked when the value of [accessibilityFlags] changes. /// /// The framework invokes this callback in the same zone in which the /// callback was set. - VoidCallback/*?*/ get onAccessibilityFeaturesChanged; - set onAccessibilityFeaturesChanged(VoidCallback/*?*/ callback); + VoidCallback? get onAccessibilityFeaturesChanged; + set onAccessibilityFeaturesChanged(VoidCallback? callback); /// Called whenever this window receives a message from a platform-specific /// plugin. @@ -801,8 +801,8 @@ abstract class Window { /// /// The framework invokes this callback in the same zone in which the /// callback was set. - PlatformMessageCallback/*?*/ get onPlatformMessage; - set onPlatformMessage(PlatformMessageCallback/*?*/ callback); + PlatformMessageCallback? get onPlatformMessage; + set onPlatformMessage(PlatformMessageCallback? callback); /// Change the retained semantics data about this window. /// @@ -811,7 +811,7 @@ abstract class Window { /// /// In either case, this function disposes the given update, which means the /// semantics update cannot be used further. - void updateSemantics(SemanticsUpdate/*!*/ update) { + void updateSemantics(SemanticsUpdate update) { engine.EngineSemanticsOwner.instance.updateSemantics(update); } @@ -825,14 +825,14 @@ abstract class Window { /// The framework invokes [callback] in the same zone in which this method /// was called. void sendPlatformMessage( - String/*!*/ name, - ByteData/*?*/ data, - PlatformMessageResponseCallback/*?*/ callback, + String name, + ByteData? data, + PlatformMessageResponseCallback? callback, ); /// Additional accessibility features that may be enabled by the platform. - AccessibilityFeatures/*!*/ get accessibilityFeatures => _accessibilityFeatures; - AccessibilityFeatures/*!*/ _accessibilityFeatures = AccessibilityFeatures._(0); + AccessibilityFeatures get accessibilityFeatures => _accessibilityFeatures; + AccessibilityFeatures _accessibilityFeatures = AccessibilityFeatures._(0); /// Updates the application's rendering on the GPU with the newly provided /// [Scene]. This function must be called within the scope of the @@ -858,13 +858,13 @@ abstract class Window { /// scheduling of frames. /// * [RendererBinding], the Flutter framework class which manages layout and /// painting. - void render(Scene/*!*/ scene); + void render(Scene scene); - String/*!*/ get initialLifecycleState => 'AppLifecycleState.resumed'; + String get initialLifecycleState => 'AppLifecycleState.resumed'; - void setIsolateDebugName(String/*!*/ name) {} + void setIsolateDebugName(String name) {} - ByteData/*?*/ getPersistentIsolateData() => null; + ByteData? getPersistentIsolateData() => null; } /// Additional accessibility features that may be enabled by the platform. @@ -883,38 +883,38 @@ class AccessibilityFeatures { static const int _kHighContrastIndex = 1 << 5; // A bitfield which represents each enabled feature. - final int/*!*/ _index; + final int _index; /// Whether there is a running accessibility service which is changing the /// interaction model of the device. /// /// For example, TalkBack on Android and VoiceOver on iOS enable this flag. - bool/*!*/ get accessibleNavigation => _kAccessibleNavigation & _index != 0; + bool get accessibleNavigation => _kAccessibleNavigation & _index != 0; /// The platform is inverting the colors of the application. - bool/*!*/ get invertColors => _kInvertColorsIndex & _index != 0; + bool get invertColors => _kInvertColorsIndex & _index != 0; /// The platform is requesting that animations be disabled or simplified. - bool/*!*/ get disableAnimations => _kDisableAnimationsIndex & _index != 0; + bool get disableAnimations => _kDisableAnimationsIndex & _index != 0; /// The platform is requesting that text be rendered at a bold font weight. /// /// Only supported on iOS. - bool/*!*/ get boldText => _kBoldTextIndex & _index != 0; + bool get boldText => _kBoldTextIndex & _index != 0; /// The platform is requesting that certain animations be simplified and /// parallax effects removed. /// /// Only supported on iOS. - bool/*!*/ get reduceMotion => _kReduceMotionIndex & _index != 0; + bool get reduceMotion => _kReduceMotionIndex & _index != 0; /// The platform is requesting that UI be rendered with darker colors. /// /// Only supported on iOS. - bool/*!*/ get highContrast => _kHighContrastIndex & _index != 0; + bool get highContrast => _kHighContrastIndex & _index != 0; @override - String/*!*/ toString() { + String toString() { final List features = []; if (accessibleNavigation) { features.add('accessibleNavigation'); @@ -938,7 +938,7 @@ class AccessibilityFeatures { } @override - bool/*!*/ operator ==(dynamic other) { + bool operator ==(dynamic other) { if (other.runtimeType != runtimeType) { return false; } @@ -947,7 +947,7 @@ class AccessibilityFeatures { } @override - int/*!*/ get hashCode => _index.hashCode; + int get hashCode => _index.hashCode; } /// Describes the contrast of a theme or color palette. @@ -969,17 +969,17 @@ enum Brightness { // TODO(flutter_web): see https://github.com/flutter/flutter/issues/33614. class CallbackHandle { CallbackHandle.fromRawHandle(this._handle) - : assert(_handle != null, "'_handle' must not be null."); + : assert(_handle != null, "'_handle' must not be null."); // ignore: unnecessary_null_comparison - final int/*!*/ _handle; + final int _handle; - int/*!*/ toRawHandle() => _handle; + int toRawHandle() => _handle; @override - bool/*!*/ operator ==(Object other) => identical(this, other); + bool operator ==(Object other) => identical(this, other); @override - int/*!*/ get hashCode => super.hashCode; + int get hashCode => super.hashCode; } // TODO(flutter_web): see https://github.com/flutter/flutter/issues/33615. @@ -988,11 +988,11 @@ class PluginUtilities { // extended directly. factory PluginUtilities._() => throw UnsupportedError('Namespace'); - static CallbackHandle/*?*/ getCallbackHandle(Function callback) { + static CallbackHandle? getCallbackHandle(Function callback) { throw UnimplementedError(); } - static Function/*?*/ getCallbackFromHandle(CallbackHandle handle) { + static Function? getCallbackFromHandle(CallbackHandle handle) { throw UnimplementedError(); } } @@ -1004,18 +1004,14 @@ class IsolateNameServer { factory IsolateNameServer._() => throw UnsupportedError('Namespace'); static dynamic lookupPortByName(String name) { - assert(name != null, "'name' cannot be null."); throw UnimplementedError(); } - static bool/*!*/ registerPortWithName(dynamic port, String name) { - assert(port != null, "'port' cannot be null."); - assert(name != null, "'name' cannot be null."); + static bool registerPortWithName(dynamic port, String name) { throw UnimplementedError(); } - static bool/*!*/ removePortNameMapping(String name) { - assert(name != null, "'name' cannot be null."); + static bool removePortNameMapping(String name) { throw UnimplementedError(); } } @@ -1061,15 +1057,15 @@ class FrameTiming { /// /// This constructor is usually only called by the Flutter engine, or a test. /// To get the [FrameTiming] of your app, see [Window.onReportTimings]. - FrameTiming(List/*!*/ timestamps) + FrameTiming(List timestamps) : assert(timestamps.length == FramePhase.values.length), _timestamps = timestamps; /// This is a raw timestamp in microseconds from some epoch. The epoch in all /// [FrameTiming] is the same, but it may not match [DateTime]'s epoch. - int/*!*/ timestampInMicroseconds(FramePhase phase) => _timestamps[phase.index]; + int timestampInMicroseconds(FramePhase phase) => _timestamps[phase.index]; - Duration/*!*/ _rawDuration(FramePhase phase) => + Duration _rawDuration(FramePhase phase) => Duration(microseconds: _timestamps[phase.index]); /// The duration to build the frame on the UI thread. @@ -1087,7 +1083,7 @@ class FrameTiming { /// {@template dart.ui.FrameTiming.fps_milliseconds} /// That's about 16ms for 60fps, and 8ms for 120fps. /// {@endtemplate} - Duration/*!*/ get buildDuration => + Duration get buildDuration => _rawDuration(FramePhase.buildFinish) - _rawDuration(FramePhase.buildStart); @@ -1095,7 +1091,7 @@ class FrameTiming { /// /// {@macro dart.ui.FrameTiming.fps_smoothness_milliseconds} /// {@macro dart.ui.FrameTiming.fps_milliseconds} - Duration/*!*/ get rasterDuration => + Duration get rasterDuration => _rawDuration(FramePhase.rasterFinish) - _rawDuration(FramePhase.rasterStart); @@ -1106,11 +1102,11 @@ class FrameTiming { /// {@macro dart.ui.FrameTiming.fps_milliseconds} /// /// See also [buildDuration] and [rasterDuration]. - Duration/*!*/ get totalSpan => + Duration get totalSpan => _rawDuration(FramePhase.rasterFinish) - _rawDuration(FramePhase.buildStart); - final List/*!*/ _timestamps; // in microseconds + final List _timestamps; // in microseconds String _formatMS(Duration duration) => '${duration.inMicroseconds * 0.001}ms'; @@ -1123,4 +1119,4 @@ class FrameTiming { /// The [Window] singleton. This object exposes the size of the display, the /// core scheduler API, the input event callback, the graphics drawing API, and /// other such core services. -Window/*!*/ get window => engine.window; +Window get window => engine.window; diff --git a/lib/web_ui/lib/ui.dart b/lib/web_ui/lib/ui.dart index 8565c42d034e3..bfedc844f9ae4 100644 --- a/lib/web_ui/lib/ui.dart +++ b/lib/web_ui/lib/ui.dart @@ -5,7 +5,7 @@ /// This library defines the web equivalent of the native dart:ui. /// /// All types in this library are public. -// @dart = 2.6 +// @dart = 2.9 library ui; import 'dart:async'; @@ -16,13 +16,6 @@ import 'dart:math' as math; import 'dart:typed_data'; import 'src/engine.dart' as engine; -export 'src/engine.dart' - show - persistedPictureFactory, - houdiniPictureFactory, - platformViewRegistry, - webOnlySetPluginHandler, - webOnlyInitializeEngine; part 'src/ui/annotations.dart'; part 'src/ui/canvas.dart'; @@ -50,3 +43,124 @@ const bool isWeb = true; /// Web specific SMI. Used by bitfield. The 0x3FFFFFFFFFFFFFFF used on VM /// is not supported on Web platform. const int kMaxUnsignedSMI = -1; + +void webOnlyInitializeEngine() { + engine.initializeEngine(); +} + +void webOnlySetPluginHandler(Future Function(String, ByteData, PlatformMessageResponseCallback) handler) { + engine.pluginMessageCallHandler = handler; +} + +// TODO(yjbanov): The code below was temporarily moved from lib/web_ui/lib/src/engine/platform_views.dart +// during the NNBD migration so that `dart:ui` does not have to export `dart:_engine`. NNBD +// does not allow exported non-migrated libraries from migrated libraries. When `dart:_engine` +// is migrated, we can move it back. + +/// A registry for factories that create platform views. +class PlatformViewRegistry { + final Map registeredFactories = + {}; + + final Map _createdViews = {}; + + /// Private constructor so this class can be a singleton. + PlatformViewRegistry._(); + + /// Register [viewTypeId] as being creating by the given [factory]. + bool registerViewFactory(String viewTypeId, PlatformViewFactory factory) { + if (registeredFactories.containsKey(viewTypeId)) { + return false; + } + registeredFactories[viewTypeId] = factory; + return true; + } + + /// Returns the view that has been created with the given [id], or `null` if + /// no such view exists. + html.Element? getCreatedView(int id) { + return _createdViews[id]; + } +} + +/// A function which takes a unique [id] and creates an HTML element. +typedef PlatformViewFactory = html.Element Function(int viewId); + +/// The platform view registry for this app. +final PlatformViewRegistry platformViewRegistry = PlatformViewRegistry._(); + +/// Handles a platform call to `flutter/platform_views`. +/// +/// Used to create platform views. +void handlePlatformViewCall( + ByteData data, + PlatformMessageResponseCallback callback, +) { + const engine.MethodCodec codec = engine.StandardMethodCodec(); + final engine.MethodCall decoded = codec.decodeMethodCall(data); + + switch (decoded.method) { + case 'create': + _createPlatformView(decoded, callback); + return; + case 'dispose': + _disposePlatformView(decoded, callback); + return; + } + callback(null); +} + +void _createPlatformView( + engine.MethodCall methodCall, PlatformMessageResponseCallback callback) { + final Map args = methodCall.arguments; + final int id = args['id']; + final String viewType = args['viewType']; + const engine.MethodCodec codec = engine.StandardMethodCodec(); + + // TODO(het): Use 'direction', 'width', and 'height'. + final PlatformViewFactory? platformViewFactory = platformViewRegistry.registeredFactories[viewType]; + if (platformViewFactory == null) { + callback(codec.encodeErrorEnvelope( + code: 'Unregistered factory', + message: "No factory registered for viewtype '$viewType'", + )); + return; + } + // TODO(het): Use creation parameters. + final html.Element element = platformViewFactory(id); + + platformViewRegistry._createdViews[id] = element; + callback(codec.encodeSuccessEnvelope(null)); +} + +void _disposePlatformView( + engine.MethodCall methodCall, PlatformMessageResponseCallback callback) { + final int id = methodCall.arguments; + const engine.MethodCodec codec = engine.StandardMethodCodec(); + + // Remove the root element of the view from the DOM. + platformViewRegistry._createdViews[id]?.remove(); + platformViewRegistry._createdViews.remove(id); + + callback(codec.encodeSuccessEnvelope(null)); +} + +// TODO(yjbanov): remove _Callback, _Callbacker, and _futurize. They are here only +// because the analyzer wasn't able to infer the correct types during +// NNBD migration. +typedef _Callback = void Function(T result); +typedef _Callbacker = String? Function(_Callback callback); +Future _futurize(_Callbacker callbacker) { + final Completer completer = Completer.sync(); + final String? error = callbacker((T t) { + if (t == null) { + completer.completeError(Exception('operation failed')); + } else { + completer.complete(t); + } + }); + if (error != null) { + throw Exception(error); + } + return completer.future; +} diff --git a/lib/web_ui/pubspec.yaml b/lib/web_ui/pubspec.yaml index 4fc67c35a1908..b46cc7df0c5a8 100644 --- a/lib/web_ui/pubspec.yaml +++ b/lib/web_ui/pubspec.yaml @@ -2,25 +2,25 @@ name: ui publish_to: none environment: - sdk: ">=2.2.2 <3.0.0" + sdk: ">=2.9.0-0 <3.0.0" dependencies: - meta: 1.1.8 + meta: ^1.1.8 dev_dependencies: # Pin the analyzer version as a temporary workaround for https://github.com/dart-lang/sdk/issues/42163 - analyzer: 0.39.8 - http: 0.12.0+4 - image: 2.1.4 + analyzer: 0.39.10 + http: 0.12.1 + image: 2.1.13 mockito: 4.1.1 - path: 1.6.4 + path: 1.7.0 test: 1.14.3 - quiver: 2.0.5 - build_runner: 1.7.2 + quiver: 2.1.3 + build_runner: 1.10.0 build_test: 1.0.0 - build_web_compilers: 2.7.1 - yaml: 2.2.0 - watcher: 0.9.7+12 + build_web_compilers: 2.11.0 + yaml: 2.2.1 + watcher: 0.9.7+15 web_engine_tester: path: ../../web_sdk/web_engine_tester simulators: diff --git a/lib/web_ui/test/engine/semantics/semantics_test.dart b/lib/web_ui/test/engine/semantics/semantics_test.dart index 66a337cce2e4e..186b7b71ac877 100644 --- a/lib/web_ui/test/engine/semantics/semantics_test.dart +++ b/lib/web_ui/test/engine/semantics/semantics_test.dart @@ -100,7 +100,7 @@ void _testEngineSemanticsOwner() { void renderLabel(String label) { final ui.SemanticsUpdateBuilder builder = ui.SemanticsUpdateBuilder(); - builder.updateNode( + updateNode(builder, id: 0, actions: 0, flags: 0, @@ -109,7 +109,7 @@ void _testEngineSemanticsOwner() { childrenInHitTestOrder: Int32List.fromList([1]), childrenInTraversalOrder: Int32List.fromList([1]), ); - builder.updateNode( + updateNode(builder, id: 1, actions: 0, flags: 0, @@ -130,6 +130,8 @@ void _testEngineSemanticsOwner() { expect(tree.length, 2); expect(tree[0].id, 0); expect(tree[0].element.tagName.toLowerCase(), 'flt-semantics'); + expect(tree[1].id, 1); + expect(tree[1].label, 'Hello'); expectSemanticsTree(''' @@ -228,7 +230,7 @@ void _testHeader() { ..semanticsEnabled = true; final ui.SemanticsUpdateBuilder builder = ui.SemanticsUpdateBuilder(); - builder.updateNode( + updateNode(builder, id: 0, actions: 0, flags: 0 | ui.SemanticsFlag.isHeader.index, @@ -304,7 +306,7 @@ void _testContainer() { final ui.SemanticsUpdateBuilder builder = ui.SemanticsUpdateBuilder(); const ui.Rect zeroOffsetRect = ui.Rect.fromLTRB(0, 0, 20, 20); - builder.updateNode( + updateNode(builder, id: 0, actions: 0, flags: 0, @@ -343,7 +345,7 @@ void _testContainer() { ..semanticsEnabled = true; final ui.SemanticsUpdateBuilder builder = ui.SemanticsUpdateBuilder(); - builder.updateNode( + updateNode(builder, id: 0, actions: 0, flags: 0, @@ -384,7 +386,7 @@ void _testVerticalScrolling() { ..semanticsEnabled = true; final ui.SemanticsUpdateBuilder builder = ui.SemanticsUpdateBuilder(); - builder.updateNode( + updateNode(builder, id: 0, actions: 0 | ui.SemanticsAction.scrollUp.index, flags: 0, @@ -410,7 +412,7 @@ void _testVerticalScrolling() { ..semanticsEnabled = true; final ui.SemanticsUpdateBuilder builder = ui.SemanticsUpdateBuilder(); - builder.updateNode( + updateNode(builder, id: 0, actions: 0 | ui.SemanticsAction.scrollUp.index, flags: 0, @@ -468,7 +470,7 @@ void _testVerticalScrolling() { ..semanticsEnabled = true; final ui.SemanticsUpdateBuilder builder = ui.SemanticsUpdateBuilder(); - builder.updateNode( + updateNode(builder, id: 0, actions: 0 | ui.SemanticsAction.scrollUp.index | @@ -481,7 +483,7 @@ void _testVerticalScrolling() { ); for (int id = 1; id <= 3; id++) { - builder.updateNode( + updateNode(builder, id: id, actions: 0, flags: 0, @@ -536,7 +538,7 @@ void _testHorizontalScrolling() { ..semanticsEnabled = true; final ui.SemanticsUpdateBuilder builder = ui.SemanticsUpdateBuilder(); - builder.updateNode( + updateNode(builder, id: 0, actions: 0 | ui.SemanticsAction.scrollLeft.index, flags: 0, @@ -562,7 +564,7 @@ void _testHorizontalScrolling() { ..semanticsEnabled = true; final ui.SemanticsUpdateBuilder builder = ui.SemanticsUpdateBuilder(); - builder.updateNode( + updateNode(builder, id: 0, actions: 0 | ui.SemanticsAction.scrollLeft.index, flags: 0, @@ -601,7 +603,7 @@ void _testHorizontalScrolling() { ..semanticsEnabled = true; final ui.SemanticsUpdateBuilder builder = ui.SemanticsUpdateBuilder(); - builder.updateNode( + updateNode(builder, id: 0, actions: 0 | ui.SemanticsAction.scrollLeft.index | @@ -614,7 +616,7 @@ void _testHorizontalScrolling() { ); for (int id = 1; id <= 3; id++) { - builder.updateNode( + updateNode(builder, id: id, actions: 0, flags: 0, @@ -669,7 +671,7 @@ void _testIncrementables() { ..semanticsEnabled = true; final ui.SemanticsUpdateBuilder builder = ui.SemanticsUpdateBuilder(); - builder.updateNode( + updateNode(builder, id: 0, actions: 0 | ui.SemanticsAction.increase.index, flags: 0, @@ -696,7 +698,7 @@ void _testIncrementables() { ..semanticsEnabled = true; final ui.SemanticsUpdateBuilder builder = ui.SemanticsUpdateBuilder(); - builder.updateNode( + updateNode(builder, id: 0, actions: 0 | ui.SemanticsAction.increase.index, flags: 0, @@ -732,7 +734,7 @@ void _testIncrementables() { ..semanticsEnabled = true; final ui.SemanticsUpdateBuilder builder = ui.SemanticsUpdateBuilder(); - builder.updateNode( + updateNode(builder, id: 0, actions: 0 | ui.SemanticsAction.decrease.index, flags: 0, @@ -767,7 +769,7 @@ void _testIncrementables() { ..semanticsEnabled = true; final ui.SemanticsUpdateBuilder builder = ui.SemanticsUpdateBuilder(); - builder.updateNode( + updateNode(builder, id: 0, actions: 0 | ui.SemanticsAction.decrease.index | @@ -799,7 +801,7 @@ void _testTextField() { ..semanticsEnabled = true; final ui.SemanticsUpdateBuilder builder = ui.SemanticsUpdateBuilder(); - builder.updateNode( + updateNode(builder, id: 0, actions: 0 | ui.SemanticsAction.tap.index, flags: 0 | ui.SemanticsFlag.isTextField.index, @@ -828,7 +830,7 @@ void _testTextField() { ..semanticsEnabled = true; final ui.SemanticsUpdateBuilder builder = ui.SemanticsUpdateBuilder(); - builder.updateNode( + updateNode(builder, id: 0, actions: 0 | ui.SemanticsAction.tap.index, flags: 0 | ui.SemanticsFlag.isTextField.index, @@ -865,7 +867,7 @@ void _testCheckables() { ..semanticsEnabled = true; final ui.SemanticsUpdateBuilder builder = ui.SemanticsUpdateBuilder(); - builder.updateNode( + updateNode(builder, id: 0, actions: 0 | ui.SemanticsAction.tap.index, flags: 0 | @@ -892,7 +894,7 @@ void _testCheckables() { ..semanticsEnabled = true; final ui.SemanticsUpdateBuilder builder = ui.SemanticsUpdateBuilder(); - builder.updateNode( + updateNode(builder, id: 0, actions: 0 | ui.SemanticsAction.tap.index, flags: 0 | @@ -918,7 +920,7 @@ void _testCheckables() { ..semanticsEnabled = true; final ui.SemanticsUpdateBuilder builder = ui.SemanticsUpdateBuilder(); - builder.updateNode( + updateNode(builder, id: 0, actions: 0 | ui.SemanticsAction.tap.index, flags: 0 | @@ -944,7 +946,7 @@ void _testCheckables() { ..semanticsEnabled = true; final ui.SemanticsUpdateBuilder builder = ui.SemanticsUpdateBuilder(); - builder.updateNode( + updateNode(builder, id: 0, actions: 0 | ui.SemanticsAction.tap.index, flags: 0 | @@ -971,7 +973,7 @@ void _testCheckables() { ..semanticsEnabled = true; final ui.SemanticsUpdateBuilder builder = ui.SemanticsUpdateBuilder(); - builder.updateNode( + updateNode(builder, id: 0, actions: 0 | ui.SemanticsAction.tap.index, flags: 0 | @@ -997,7 +999,7 @@ void _testCheckables() { ..semanticsEnabled = true; final ui.SemanticsUpdateBuilder builder = ui.SemanticsUpdateBuilder(); - builder.updateNode( + updateNode(builder, id: 0, actions: 0 | ui.SemanticsAction.tap.index, flags: 0 | @@ -1023,7 +1025,7 @@ void _testCheckables() { ..semanticsEnabled = true; final ui.SemanticsUpdateBuilder builder = ui.SemanticsUpdateBuilder(); - builder.updateNode( + updateNode(builder, id: 0, actions: 0 | ui.SemanticsAction.tap.index, flags: 0 | @@ -1051,7 +1053,7 @@ void _testCheckables() { ..semanticsEnabled = true; final ui.SemanticsUpdateBuilder builder = ui.SemanticsUpdateBuilder(); - builder.updateNode( + updateNode(builder, id: 0, actions: 0 | ui.SemanticsAction.tap.index, flags: 0 | @@ -1078,7 +1080,7 @@ void _testCheckables() { ..semanticsEnabled = true; final ui.SemanticsUpdateBuilder builder = ui.SemanticsUpdateBuilder(); - builder.updateNode( + updateNode(builder, id: 0, actions: 0 | ui.SemanticsAction.tap.index, flags: 0 | @@ -1107,7 +1109,7 @@ void _testTappable() { ..semanticsEnabled = true; final ui.SemanticsUpdateBuilder builder = ui.SemanticsUpdateBuilder(); - builder.updateNode( + updateNode(builder, id: 0, actions: 0 | ui.SemanticsAction.tap.index, flags: 0 | @@ -1134,7 +1136,7 @@ void _testTappable() { ..semanticsEnabled = true; final ui.SemanticsUpdateBuilder builder = ui.SemanticsUpdateBuilder(); - builder.updateNode( + updateNode(builder, id: 0, actions: 0 | ui.SemanticsAction.tap.index, flags: 0 | @@ -1164,7 +1166,7 @@ void _testImage() { ..semanticsEnabled = true; final ui.SemanticsUpdateBuilder builder = ui.SemanticsUpdateBuilder(); - builder.updateNode( + updateNode(builder, id: 0, actions: 0, flags: 0 | ui.SemanticsFlag.isImage.index, @@ -1189,7 +1191,7 @@ void _testImage() { ..semanticsEnabled = true; final ui.SemanticsUpdateBuilder builder = ui.SemanticsUpdateBuilder(); - builder.updateNode( + updateNode(builder, id: 0, actions: 0, flags: 0 | ui.SemanticsFlag.isImage.index, @@ -1221,7 +1223,7 @@ void _testImage() { ..semanticsEnabled = true; final ui.SemanticsUpdateBuilder builder = ui.SemanticsUpdateBuilder(); - builder.updateNode( + updateNode(builder, id: 0, actions: 0, flags: 0 | ui.SemanticsFlag.isImage.index, @@ -1244,7 +1246,7 @@ void _testImage() { ..semanticsEnabled = true; final ui.SemanticsUpdateBuilder builder = ui.SemanticsUpdateBuilder(); - builder.updateNode( + updateNode(builder, id: 0, actions: 0, flags: 0 | ui.SemanticsFlag.isImage.index, @@ -1277,7 +1279,7 @@ void _testLiveRegion() { ..semanticsEnabled = true; final ui.SemanticsUpdateBuilder builder = ui.SemanticsUpdateBuilder(); - builder.updateNode( + updateNode(builder, id: 0, actions: 0, label: 'This is a snackbar', @@ -1302,10 +1304,11 @@ void _testLiveRegion() { ..semanticsEnabled = true; final ui.SemanticsUpdateBuilder builder = ui.SemanticsUpdateBuilder(); - builder.updateNode( + updateNode( + builder, id: 0, - actions: 0, flags: 0 | ui.SemanticsFlag.isLiveRegion.index, + actions: 0, transform: Matrix4.identity().toFloat64(), rect: const ui.Rect.fromLTRB(0, 0, 100, 50), ); @@ -1365,3 +1368,68 @@ class SemanticsActionLogger { }; } } + +/// A facade in front of [ui.SemanticsUpdateBuilder.updateNode] that +/// supplies default values for semantics attributes. +void updateNode( + ui.SemanticsUpdateBuilder builder, { + int id = 0, + int flags = 0, + int actions = 0, + int maxValueLength = 0, + int currentValueLength = 0, + int textSelectionBase = 0, + int textSelectionExtent = 0, + int platformViewId = 0, + int scrollChildren = 0, + int scrollIndex = 0, + double scrollPosition = 0.0, + double scrollExtentMax = 0.0, + double scrollExtentMin = 0.0, + double elevation = 0.0, + double thickness = 0.0, + ui.Rect rect = ui.Rect.zero, + String label = '', + String hint = '', + String value = '', + String increasedValue = '', + String decreasedValue = '', + ui.TextDirection textDirection = ui.TextDirection.ltr, + Float64List transform, + Int32List childrenInTraversalOrder, + Int32List childrenInHitTestOrder, + Int32List additionalActions, +}) { + transform ??= Float64List.fromList(Matrix4.identity().storage); + childrenInTraversalOrder ??= Int32List(0); + childrenInHitTestOrder ??= Int32List(0); + additionalActions ??= Int32List(0); + builder.updateNode( + id: id, + flags: flags, + actions: actions, + maxValueLength: maxValueLength, + currentValueLength: currentValueLength, + textSelectionBase: textSelectionBase, + textSelectionExtent: textSelectionExtent, + platformViewId: platformViewId, + scrollChildren: scrollChildren, + scrollIndex: scrollIndex, + scrollPosition: scrollPosition, + scrollExtentMax: scrollExtentMax, + scrollExtentMin: scrollExtentMin, + elevation: elevation, + thickness: thickness, + rect: rect, + label: label, + hint: hint, + value: value, + increasedValue: increasedValue, + decreasedValue: decreasedValue, + textDirection: textDirection, + transform: transform, + childrenInTraversalOrder: childrenInTraversalOrder, + childrenInHitTestOrder: childrenInHitTestOrder, + additionalActions: additionalActions, + ); +} diff --git a/lib/web_ui/test/golden_tests/engine/shadow_golden_test.dart b/lib/web_ui/test/golden_tests/engine/shadow_golden_test.dart index 0374b33d21bfc..c6f98e4e5d91b 100644 --- a/lib/web_ui/test/golden_tests/engine/shadow_golden_test.dart +++ b/lib/web_ui/test/golden_tests/engine/shadow_golden_test.dart @@ -2,6 +2,7 @@ // 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'; @@ -41,7 +42,7 @@ void main() async { void _paintShadowBounds(SurfacePath path, double elevation) { final Rect shadowBounds = computePenumbraBounds(path.getBounds(), elevation); - final EnginePictureRecorder recorder = PictureRecorder(); + final EnginePictureRecorder recorder = EnginePictureRecorder(); final RecordingCanvas canvas = recorder.beginRecording(Rect.largest); canvas.drawRect( shadowBounds, diff --git a/web_sdk/pubspec.yaml b/web_sdk/pubspec.yaml index 46234190eea08..733f50e8f46bf 100644 --- a/web_sdk/pubspec.yaml +++ b/web_sdk/pubspec.yaml @@ -2,5 +2,5 @@ name: web_sdk_tests author: Flutter Authors dev_dependencies: - analyzer: any + analyzer: ^0.39.10 test: any diff --git a/web_sdk/test/api_conform_test.dart b/web_sdk/test/api_conform_test.dart index e97cccd043423..8b7aee91fd562 100644 --- a/web_sdk/test/api_conform_test.dart +++ b/web_sdk/test/api_conform_test.dart @@ -2,10 +2,14 @@ // 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:analyzer/analyzer.dart'; +import 'package:analyzer/dart/analysis/results.dart'; +import 'package:analyzer/dart/analysis/utilities.dart'; import 'package:analyzer/dart/analysis/features.dart'; +import 'package:analyzer/dart/ast/ast.dart'; // Ignore members defined on Object. const Set _kObjectMembers = { @@ -14,23 +18,30 @@ const Set _kObjectMembers = { 'hashCode', }; -void main() { - // TODO(yjbanov): fix and re-enable API conform test. - if (!Platform.environment.containsKey('REALLY_DO_RUN_API_CONFORM_TEST')) { - return; +CompilationUnit _parseAndCheckDart(String path) { + final FeatureSet analyzerFeatures = FeatureSet.fromEnableFlags(['non-nullable']); + if (!analyzerFeatures.isEnabled(Feature.non_nullable)) { + throw Exception('non-nullable feature is disabled.'); + } + final ParseStringResult result = parseFile(path: path, featureSet: analyzerFeatures, throwIfDiagnostics: false); + if (result.errors.isNotEmpty) { + result.errors.forEach(stderr.writeln); + stderr.writeln('Failure!'); + exit(1); } + return result.unit; +} + +void main() { // These files just contain imports to the part files; - final FeatureSet analyzerFeatures = FeatureSet.fromEnableFlags(['non-nullable']); - final CompilationUnit uiUnit = parseDartFile('lib/ui/ui.dart', - parseFunctionBodies: false, suppressErrors: false, featureSet: analyzerFeatures); - final CompilationUnit webUnit = parseDartFile('lib/web_ui/lib/ui.dart', - parseFunctionBodies: false, suppressErrors: false); + final CompilationUnit uiUnit = _parseAndCheckDart('lib/ui/ui.dart'); + final CompilationUnit webUnit = _parseAndCheckDart('lib/web_ui/lib/ui.dart'); final Map uiClasses = {}; final Map webClasses = {}; // Gather all public classes from each library. For now we are skiping // other top level members. - _collectPublicClasses(uiUnit, uiClasses, 'lib/ui/', analyzerFeatures: analyzerFeatures); + _collectPublicClasses(uiUnit, uiClasses, 'lib/ui/'); _collectPublicClasses(webUnit, webClasses, 'lib/web_ui/lib/'); if (uiClasses.isEmpty || webClasses.isEmpty) { @@ -169,8 +180,10 @@ void main() { // allow dynamic in web implementation. if (webMethod.returnType?.toString() != 'dynamic') { failed = true; - print('Warning: lib/ui/ui.dart $className.$methodName return type' - '${uiMethod.returnType?.toString()} is not the same as in lib/web_ui/ui.dart.'); + print( + 'Warning: $className.$methodName return type mismatch:\n' + ' lib/ui/ui.dart : ${uiMethod.returnType?.toSource()}\n' + ' lib/web_ui/ui.dart : ${webMethod.returnType?.toSource()}'); } } } @@ -185,24 +198,19 @@ void main() { // Collects all public classes defined by the part files of [unit]. void _collectPublicClasses(CompilationUnit unit, - Map destination, String root, {FeatureSet analyzerFeatures}) { + Map destination, String root) { for (Directive directive in unit.directives) { if (directive is! PartDirective) { continue; } - final PartDirective partDirective = directive; + final PartDirective partDirective = directive as PartDirective; final String literalUri = partDirective.uri.toString(); - final CompilationUnit subUnit = parseDartFile( - '$root${literalUri.substring(1, literalUri.length - 1)}', - parseFunctionBodies: false, - suppressErrors: false, - featureSet: analyzerFeatures, - ); + final CompilationUnit subUnit = _parseAndCheckDart('$root${literalUri.substring(1, literalUri.length - 1)}'); for (CompilationUnitMember member in subUnit.declarations) { if (member is! ClassDeclaration) { continue; } - final ClassDeclaration classDeclaration = member; + final ClassDeclaration classDeclaration = member as ClassDeclaration; if (classDeclaration.name.name.startsWith('_')) { continue; } @@ -217,7 +225,7 @@ void _collectPublicConstructors(ClassDeclaration classDeclaration, if (member is! ConstructorDeclaration) { continue; } - final ConstructorDeclaration method = member; + final ConstructorDeclaration method = member as ConstructorDeclaration; if (method?.name?.name == null) { destination['Unnamed Constructor'] = method; continue; @@ -235,7 +243,7 @@ void _collectPublicMethods(ClassDeclaration classDeclaration, if (member is! MethodDeclaration) { continue; } - final MethodDeclaration method = member; + final MethodDeclaration method = member as MethodDeclaration; if (method.name.name.startsWith('_')) { continue; }