take web_ui to null safety (flutter/engine#19027)

move web_ui to NNBD syntax
This commit is contained in:
Yegor
2020-06-16 15:28:06 -07:00
committed by GitHub
parent 0b5b38c8b4
commit 30879c3f50
41 changed files with 1297 additions and 1183 deletions

View File

@@ -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: |

View File

@@ -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

View File

@@ -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:

View File

@@ -10,6 +10,8 @@ targets:
dart2js_args:
- --no-minify
- --enable-asserts
- --enable-experiment=non-nullable
- --no-sound-null-safety
generate_for:
include:
- test/**.dart

View File

@@ -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<void> _startDriver(String workingDirectory) async {
await startProcess('./chromedriver/chromedriver', ['--port=4444'],
workingDirectory: workingDirectory);
print('INFO: Driver started');
}
void _prepareDriver() async {
Future<void> _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<void>
// 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<io.File>()
.toList();
final List<String> e2eTestsToRun = List<String>();
final List<String> e2eTestsToRun = <String>[];
final List<String> blockedTests =
blockedTestsListsMap[getBlockedTestsListMapKey(_browser)] ?? <String>[];
@@ -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.

View File

@@ -446,6 +446,7 @@ class TestCommand extends Command<bool> with ArgUtils {
'run',
'build_runner',
'build',
'--enable-experiment=non-nullable',
'test',
'-o',
forCanvasKit ? canvasKitOutputRelativePath : 'build',

View File

@@ -67,7 +67,7 @@ Future<int> runProcess(
}
/// Runs [executable]. Do not follow the exit code or the output.
void startProcess(
Future<void> startProcess(
String executable,
List<String> arguments, {
String workingDirectory,

View File

@@ -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;
}

View File

@@ -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',

View File

@@ -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;

View File

@@ -5,90 +5,7 @@
// @dart = 2.6
part of engine;
/// A registry for factories that create platform views.
class PlatformViewRegistry {
final Map<String, PlatformViewFactory> registeredFactories =
<String, PlatformViewFactory>{};
final Map<int, html.Element> _createdViews = <int, html.Element>{};
/// 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<dynamic, dynamic> 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.

View File

@@ -6,7 +6,3 @@
part of engine;
Future<void> Function(String, ByteData, ui.PlatformMessageResponseCallback) pluginMessageCallHandler;
void webOnlySetPluginHandler(Future<void> Function(String, ByteData, ui.PlatformMessageResponseCallback) handler) {
pluginMessageCallHandler = handler;
}

View File

@@ -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;

View File

@@ -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);

View File

@@ -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'

View File

@@ -12,7 +12,7 @@ typedef Callback<T> = void Function(T result);
///
/// Return value should be null on success, and a string error message on
/// failure.
typedef Callbacker<T> = String Function(Callback<T> callback);
typedef Callbacker<T> = String/*?*/ Function(Callback<T> callback);
/// Converts a method that receives a value-returning callback to a method that
/// returns a Future.

View File

@@ -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;

View File

@@ -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();

View File

@@ -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<Offset/*!*/>/*!*/ positions, {
List<Offset/*!*/>/*?*/ textureCoordinates,
List<Color/*!*/>/*?*/ colors,
List<int/*!*/>/*?*/ indices,
VertexMode mode,
List<Offset> positions, {
List<Offset>? textureCoordinates,
List<Color>? colors,
List<int>? 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<Offset>].
void drawPoints(PointMode/*!*/ pointMode, List<Offset/*!*/>/*!*/ points, Paint/*!*/ paint);
void drawPoints(PointMode pointMode, List<Offset> 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<Offset>] rather than a
/// [List<Float32List>].
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<RSTransform/*!*/>/*!*/ transforms,
List<Rect/*!*/>/*!*/ rects,
List<Color/*!*/>/*!*/ colors,
BlendMode/*!*/ blendMode,
Rect/*?*/ cullRect,
Paint/*!*/ paint,
Image atlas,
List<RSTransform> transforms,
List<Rect> rects,
List<Color> 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<Image/*!*/>/*!*/ toImage(int/*!*/ width, int/*!*/ height);
Future<Image> 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

View File

@@ -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<T> {
/// 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<T> {
}
/// Returns null when empty.
T pop() {
T? pop() {
return _queue.isEmpty ? null : _queue.removeFirst();
}
@@ -70,9 +70,7 @@ class _RingBuffer<T> {
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<T> {
}
/// Signature for [ChannelBuffers.drain].
typedef DrainChannelCallback = Future<void>/*!*/ Function(ByteData/*?*/, PlatformMessageResponseCallback/*!*/);
typedef DrainChannelCallback = Future<void> 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<String, _RingBuffer<_StoredMessage>> _messages =
<String, _RingBuffer<_StoredMessage>>{};
final Map<String, _RingBuffer<_StoredMessage>?> _messages =
<String, _RingBuffer<_StoredMessage>?>{};
_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<void>/*!*/ drain(String/*!*/ channel, DrainChannelCallback/*!*/ callback) async {
Future<void> 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<channel name>\r<new size>`
/// Description: Allows you to set the size of a channel's buffer.
void handleMessage(ByteData/*!*/ data) {
void handleMessage(ByteData data) {
final List<String> 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();

View File

@@ -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<Image/*!*/>/*!*/ toImage(int width, int height);
Future<Image> 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();
}

File diff suppressed because it is too large Load Diff

View File

@@ -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<Object/*?*/>/*?*/ arguments) {
int hashList(Iterable<Object?>? 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);

View File

@@ -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<void>/*!*/ webOnlyInitializePlatform({
engine.AssetManager/*?*/ assetManager,
Future<void> webOnlyInitializePlatform({
engine.AssetManager? assetManager,
}) {
final Future<void> initializationFuture = _initializePlatform(assetManager: assetManager);
scheduleMicrotask(() {
@@ -20,13 +20,13 @@ Future<void>/*!*/ webOnlyInitializePlatform({
}
Future<void> _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<void> _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<void>/*!*/ webOnlySetAssetManager(engine.AssetManager/*!*/ assetManager) async {
assert(assetManager != null, 'Cannot set assetManager to null');
Future<void> 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<void>/*!*/ 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<void>/*!*/ 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!;

View File

@@ -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 as double;
}
double _lerpDouble(double a, double b, double t) {
return a + (b - a) * 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;

View File

@@ -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<int/*!*/>/*!*/ saveCompilationTrace() {
List<int> saveCompilationTrace() {
throw UnimplementedError();
}

View File

@@ -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<Color> colors, List<double> colorStops) {
void _validateColorStops(List<Color> colors, List<double>? 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 <https://en.wikipedia.org/wiki/Relative_luminance>.
double/*!*/ computeLuminance() {
double computeLuminance() {
// See <https://www.w3.org/TR/WCAG20/#relativeluminancedef>
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<double>], 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<Color/*!*/>/*!*/ colors, [
List<double/*!*/>/*?*/ colorStops,
TileMode/*!*/ tileMode = TileMode.clamp,
Float64List/*?*/ matrix4,
Offset from,
Offset to,
List<Color> colors, [
List<double>? 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<Color/*!*/>/*!*/ colors, [
List<double/*!*/>/*?*/ colorStops,
TileMode/*!*/ tileMode = TileMode.clamp,
Float64List/*?*/ matrix4,
Offset/*?*/ focal,
double/*!*/ focalRadius = 0.0,
Offset center,
double radius,
List<Color> colors, [
List<double>? 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<Color/*!*/>/*!*/ colors, [
List<double/*!*/>/*?*/ colorStops,
Offset center,
List<Color> colors, [
List<double>? 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<ByteData/*?*/>/*!*/ toByteData(
Future<ByteData?> 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<double/*!*/>/*!*/ matrix) =
const factory ColorFilter.matrix(List<double> 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<dynamic>/*!*/ webOnlySerializeToCssPaint() {
return <dynamic>[_style?.index, _sigma];
List<dynamic> webOnlySerializeToCssPaint() {
return <dynamic>[_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<FrameInfo/*!*/>/*!*/ getNextFrame() {
return engine.futurize<FrameInfo/*!*/>(_getNextFrame);
Future<FrameInfo> getNextFrame() {
return engine.futurize<FrameInfo>(_getNextFrame);
}
/// Returns an error message on failure, null on success.
String _getNextFrame(engine.Callback<FrameInfo> callback) => null;
String? _getNextFrame(engine.Callback<FrameInfo> 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<Codec/*!*/>/*!*/ instantiateImageCodec(
Uint8List/*!*/ list, {
int/*?*/ targetWidth,
int/*?*/ targetHeight,
Future<Codec> instantiateImageCodec(
Uint8List list, {
int? targetWidth,
int? targetHeight,
}) {
return engine.futurize<Codec/*!*/>((engine.Callback<Codec> callback) =>
return _futurize<Codec>((engine.Callback<Codec> callback) =>
// TODO: Implement targetWidth and targetHeight support.
_instantiateImageCodec(list, callback, null));
}
@@ -1591,8 +1590,8 @@ Future<Codec/*!*/>/*!*/ 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<Codec/*!*/> callback, _ImageInfo/*?*/ imageInfo) {
String? _instantiateImageCodec(
Uint8List list, engine.Callback<Codec> callback, _ImageInfo? imageInfo) {
if (engine.experimentalUseSkia) {
if (imageInfo == null) {
engine.skiaInstantiateImageCodec(list, callback);
@@ -1607,15 +1606,15 @@ String/*?*/ _instantiateImageCodec(
return null;
}
Future<Codec/*?*/>/*!*/ webOnlyInstantiateImageCodecFromUrl(Uri/*!*/ uri,
{engine.WebOnlyImageCodecChunkCallback/*?*/ chunkCallback}) {
return engine.futurize<Codec/*?*/>((engine.Callback<Codec> callback) =>
Future<Codec?> webOnlyInstantiateImageCodecFromUrl(Uri uri,
{engine.WebOnlyImageCodecChunkCallback? chunkCallback}) {
return _futurize<Codec?>((engine.Callback<Codec> callback) =>
_instantiateImageCodecFromUrl(uri, chunkCallback, callback));
}
String/*?*/ _instantiateImageCodecFromUrl(
String? _instantiateImageCodecFromUrl(
Uri uri,
engine.WebOnlyImageCodecChunkCallback chunkCallback,
engine.WebOnlyImageCodecChunkCallback? chunkCallback,
engine.Callback<Codec> 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<void> _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<void> _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<Codec> codecFuture = engine.futurize(
final Future<Codec> codecFuture = _futurize(
(engine.Callback<Codec> 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().
// <https://github.com/google/skia/blob/bb5b77db51d2e149ee66db284903572a5aac09be/src/effects/SkBlurMask.cpp#L23>
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<double>], 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<Shadow/*!*/>/*?*/ lerpList(List<Shadow/*!*/>/*?*/ a, List<Shadow/*!*/>/*?*/ b, double/*!*/ t) {
assert(t != null);
static List<Shadow>? lerpList(List<Shadow>? a, List<Shadow>? b, double t) {
assert(t != null); // ignore: unnecessary_null_comparison
if (a == null && b == null) {
return null;
}
a ??= <Shadow>[];
b ??= <Shadow>[];
final List<Shadow/*!*/> result = <Shadow/*!*/>[];
final List<Shadow> result = <Shadow>[];
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);
}

View File

@@ -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<Offset/*!*/>/*!*/ points, bool/*!*/ close);
void addPolygon(List<Offset> 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});
}

View File

@@ -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<PathMetric> {
@override
Iterator<PathMetric/*!*/>/*!*/ get iterator;
Iterator<PathMetric> get iterator;
}
/// Used by [PathMetrics] to track iteration from one segment of a path to the
/// next for measurement.
abstract class PathMetricIterator implements Iterator<PathMetric> {
@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<PathMetric> {
/// 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);
}

View File

@@ -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 <PointerData>[]}) : assert(data != null);
const PointerDataPacket({this.data = const <PointerData>[]}) : 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<PointerData/*!*/>/*!*/ data;
final List<PointerData> data;
}

View File

@@ -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<engine.SemanticsNodeUpdate> nodeUpdates}) =
factory SemanticsUpdate._({List<engine.SemanticsNodeUpdate>? nodeUpdates}) =
engine.SemanticsUpdate;
/// Releases the resources used by this semantics update.

View File

@@ -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<void> _testPlatformInitializedFuture;
Future<void>? _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<dynamic>/*!*/ ensureTestPlatformInitializedThenRunTest(
dynamic Function()/*!*/ body) {
Future<dynamic> ensureTestPlatformInitializedThenRunTest(
dynamic Function() body) {
if (_testPlatformInitializedFuture == null) {
debugEmulateFlutterTesterEnvironment = true;
@@ -22,16 +22,16 @@ Future<dynamic>/*!*/ ensureTestPlatformInitializedThenRunTest(
_testPlatformInitializedFuture = webOnlyInitializePlatform(
assetManager: engine.WebOnlyMockAssetManager());
}
return _testPlatformInitializedFuture.then<dynamic>((_) => body());
return _testPlatformInitializedFuture!.then<dynamic>((_) => 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<void>/*?*/ _platformInitializedFuture;
Future<void>? _platformInitializedFuture;
/// Initializes domRenderer with specific devicePixelRatio and physicalSize.
Future<void>/*!*/ webOnlyInitializeTestDomRenderer({double/*!*/ devicePixelRatio = 3.0}) {
Future<void> webOnlyInitializeTestDomRenderer({double devicePixelRatio = 3.0}) {
// Force-initialize DomRenderer so it doesn't overwrite test pixel ratio.
engine.domRenderer;
@@ -45,7 +45,7 @@ Future<void>/*!*/ 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.

View File

@@ -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<FontWeight/*!*/> values = <FontWeight/*!*/>[
static const List<FontWeight> values = <FontWeight>[
w100,
w200,
w300,
@@ -131,15 +131,15 @@ class FontWeight {
///
/// Values for `t` are usually obtained from an [Animation<double>], 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 <int, String>{
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 <https://docs.microsoft.com/en-us/typography/opentype/spec/featuretags>
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:
///
/// * <https://docs.microsoft.com/en-us/typography/opentype/spec/features_pt#ssxx>
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 <https://docs.microsoft.com/en-us/typography/opentype/spec/featuretags>
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<TextDecoration/*!*/>/*!*/ decorations) {
factory TextDecoration.combine(List<TextDecoration> 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<String/*!*/>/*?*/ fontFamilyFallback,
double/*?*/ fontSize,
double/*?*/ letterSpacing,
double/*?*/ wordSpacing,
double/*?*/ height,
Locale/*?*/ locale,
Paint/*?*/ background,
Paint/*?*/ foreground,
List<Shadow/*!*/>/*?*/ shadows,
List<FontFeature/*!*/>/*?*/ fontFeatures,
Color? color,
TextDecoration? decoration,
Color? decorationColor,
TextDecorationStyle? decorationStyle,
double? decorationThickness,
FontWeight? fontWeight,
FontStyle? fontStyle,
TextBaseline? textBaseline,
String? fontFamily,
List<String>? fontFamilyFallback,
double? fontSize,
double? letterSpacing,
double? wordSpacing,
double? height,
Locale? locale,
Paint? background,
Paint? foreground,
List<Shadow>? shadows,
List<FontFeature>? 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<String/*!*/>/*?*/ fontFamilyFallback,
double/*?*/ fontSize,
double/*?*/ height,
double/*?*/ leading,
FontWeight/*?*/ fontWeight,
FontStyle/*?*/ fontStyle,
bool/*?*/ forceStrutHeight,
String? fontFamily,
List<String>? 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<TextBox/*!*/>/*!*/ getBoxesForRange(int/*!*/ start, int/*!*/ end,
{BoxHeightStyle/*!*/ boxHeightStyle = BoxHeightStyle.tight,
BoxWidthStyle/*!*/ boxWidthStyle = BoxWidthStyle.tight});
List<TextBox> 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<TextBox/*!*/>/*!*/ getBoxesForPlaceholders();
List<TextBox> 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<LineMetrics/*!*/>/*!*/ computeLineMetrics();
List<LineMetrics> 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<double/*!*/>/*!*/ get placeholderScales;
List<double> 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<void>/*!*/ loadFontFromList(Uint8List/*!*/ list, {String/*?*/ fontFamily}) {
Future<void> 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()
);
}

View File

@@ -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.

View File

@@ -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<FrameTiming/*!*/>/*!*/ timings);
typedef TimingsCallback = void Function(List<FrameTiming> 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<Locale/*!*/>/*?*/ get locales;
List<Locale>? 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<Locale> supportedLocales) {
Locale? computePlatformResolvedLocale(List<Locale> 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<String> features = <String>[];
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<int/*!*/>/*!*/ timestamps)
FrameTiming(List<int> 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<int/*!*/>/*!*/ _timestamps; // in microseconds
final List<int> _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;

View File

@@ -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<void> 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<String, PlatformViewFactory> registeredFactories =
<String, PlatformViewFactory>{};
final Map<int, html.Element> _createdViews = <int, html.Element>{};
/// 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<dynamic, dynamic> 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<T> = void Function(T result);
typedef _Callbacker<T> = String? Function(_Callback<T> callback);
Future<T> _futurize<T>(_Callbacker<T> callbacker) {
final Completer<T> completer = Completer<T>.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;
}

View File

@@ -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:

View File

@@ -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(<int>[1]),
childrenInTraversalOrder: Int32List.fromList(<int>[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('''
<sem style="filter: opacity(0%); color: rgba(0, 0, 0, 0)">
@@ -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,
);
}

View File

@@ -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,

View File

@@ -2,5 +2,5 @@ name: web_sdk_tests
author: Flutter Authors <flutter-dev@googlegroups.com>
dev_dependencies:
analyzer: any
analyzer: ^0.39.10
test: any

View File

@@ -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<String> _kObjectMembers = <String>{
@@ -14,23 +18,30 @@ const Set<String> _kObjectMembers = <String>{
'hashCode',
};
void main() {
// TODO(yjbanov): fix and re-enable API conform test.
if (!Platform.environment.containsKey('REALLY_DO_RUN_API_CONFORM_TEST')) {
return;
}
// These files just contain imports to the part files;
CompilationUnit _parseAndCheckDart(String path) {
final FeatureSet analyzerFeatures = FeatureSet.fromEnableFlags(<String>['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);
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 CompilationUnit uiUnit = _parseAndCheckDart('lib/ui/ui.dart');
final CompilationUnit webUnit = _parseAndCheckDart('lib/web_ui/lib/ui.dart');
final Map<String, ClassDeclaration> uiClasses = <String, ClassDeclaration>{};
final Map<String, ClassDeclaration> webClasses = <String, ClassDeclaration>{};
// 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<String, ClassDeclaration> destination, String root, {FeatureSet analyzerFeatures}) {
Map<String, ClassDeclaration> 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;
}