null-annotate remaining engine code (#18852)

* null-annotate remaining engine code
This commit is contained in:
Yegor 2020-06-05 21:00:07 -07:00 committed by GitHub
parent 5741134bc0
commit ff6462e457
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 205 additions and 194 deletions

View File

@ -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.
@ -86,7 +86,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.
@ -130,7 +130,7 @@ class ChannelBuffers {
}
/// Returns true on overflow.
bool push(String/*!*/ channel, ByteData/*!*/ data, PlatformMessageResponseCallback/*!*/ callback) {
bool/*!*/ push(String/*!*/ channel, ByteData/*?*/ data, PlatformMessageResponseCallback/*!*/ callback) {
_RingBuffer<_StoredMessage> queue = _messages[channel];
if (queue == null) {
queue = _makeRingBuffer(kDefaultBufferSize);
@ -182,7 +182,7 @@ 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);
await callback(message.data, message.callback);

View File

@ -1914,7 +1914,7 @@ class Path extends NativeFieldWrapperClass2 {
///
/// Defaults to the non-zero winding rule, [PathFillType.nonZero].
PathFillType/*!*/ get fillType => PathFillType.values[_getFillType()];
set fillType(PathFillType value) => _setFillType(value.index);
set fillType(PathFillType/*!*/ value) => _setFillType(value.index);
int _getFillType() native 'Path_getFillType';
void _setFillType(int/*!*/ fillType) native 'Path_setFillType';
@ -2346,7 +2346,7 @@ class PathMetricIterator implements Iterator<PathMetric> {
PathMetric/*?*/ get current => _pathMetric;
@override
bool moveNext() {
bool/*!*/ moveNext() {
if (_pathMeasure._nextContour()) {
_pathMetric = PathMetric._(_pathMeasure);
return true;
@ -3537,7 +3537,7 @@ class Canvas extends NativeFieldWrapperClass2 {
/// each matching call to [restore] decrements it.
///
/// This number cannot go below 1.
int getSaveCount() native 'Canvas_getSaveCount';
int/*!*/ getSaveCount() native 'Canvas_getSaveCount';
/// Add a translation to the current transform, shifting the coordinate space
/// horizontally by the first argument and vertically by the second argument.
@ -4171,8 +4171,6 @@ class PictureRecorder extends NativeFieldWrapperClass2 {
/// 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.
///
/// Returns null if the PictureRecorder is not associated with a canvas.
Picture/*!*/ endRecording() {
final Picture picture = Picture._();
_endRecording(picture);

View File

@ -37,7 +37,7 @@ class SurfacePath implements ui.Path {
double get _currentY => _currentSubpath?.currentY ?? 0.0;
/// Recorder used for hit testing paths.
static ui.RawRecordingCanvas _rawRecorder;
static RawRecordingCanvas _rawRecorder;
SurfacePath() : subpaths = <Subpath>[];
@ -595,7 +595,7 @@ class SurfacePath implements ui.Path {
///
/// Note: Not very efficient, it creates a canvas, plays path and calls
/// Context2D isPointInPath. If performance becomes issue, retaining
/// RawRecordingCanvas can remove create/remove rootElement cost.
/// [RawRecordingCanvas] can remove create/remove rootElement cost.
@override
bool contains(ui.Offset point) {
assert(offsetIsValid(point));
@ -674,7 +674,7 @@ class SurfacePath implements ui.Path {
}
final double dpr = window.devicePixelRatio;
_rawRecorder ??=
ui.RawRecordingCanvas(ui.Size(size.width / dpr, size.height / dpr));
RawRecordingCanvas(ui.Size(size.width / dpr, size.height / dpr));
// Account for the shift due to padding.
_rawRecorder.translate(-BitmapCanvas.kPaddingPixels.toDouble(),
-BitmapCanvas.kPaddingPixels.toDouble());

View File

@ -19,6 +19,31 @@ double _measureBorderRadius(double x, double y) {
return clampedX * clampedX + clampedY * clampedY;
}
class RawRecordingCanvas extends BitmapCanvas
implements ui.PictureRecorder {
RawRecordingCanvas(ui.Size size) : super(ui.Offset.zero & size);
@override
void dispose() {
clear();
}
RecordingCanvas beginRecording(ui.Rect bounds) =>
throw UnsupportedError('');
@override
ui.Picture endRecording() => throw UnsupportedError('');
RecordingCanvas _canvas; // ignore: unused_field
bool _isRecording = true; // ignore: unused_field
@override
bool get isRecording => true;
ui.Rect cullRect;
}
/// Records canvas commands to be applied to a [EngineCanvas].
///
/// See [Canvas] for docs for these methods.

View File

@ -59,6 +59,7 @@ enum VertexMode {
}
/// A set of vertex data used by [Canvas.drawVertices].
// TODO(yjbanov): move this to dart:_engine, https://github.com/flutter/flutter/issues/58813
class Vertices {
final VertexMode _mode;
final Float32List _positions;
@ -93,11 +94,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,
@ -154,11 +155,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,
@ -172,11 +173,11 @@ class Vertices {
indices: indices);
}
VertexMode get mode => _mode;
Int32List get colors => _colors;
Float32List get positions => _positions;
Float32List get textureCoordinates => _textureCoordinates;
Uint16List get indices => _indices;
VertexMode/*!*/ get mode => _mode;
Float32List/*!*/ get positions => _positions;
Int32List/*?*/ get colors => _colors;
Float32List/*?*/ get textureCoordinates => _textureCoordinates;
Uint16List/*?*/ get indices => _indices;
}
/// Records a [Picture] containing a sequence of graphical operations.
@ -202,16 +203,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.
///
/// Returns null if the PictureRecorder is not associated with a canvas.
Picture endRecording();
Picture/*!*/ endRecording();
}
/// An interface for recording graphical operations.
@ -234,7 +233,7 @@ abstract class PictureRecorder {
class Canvas {
engine.RecordingCanvas _canvas;
factory Canvas(PictureRecorder recorder, [Rect cullRect]) {
factory Canvas(PictureRecorder/*!*/ recorder, [Rect/*?*/ cullRect]) {
if (engine.experimentalUseSkia) {
return engine.CanvasKitCanvas(recorder, cullRect);
} else {
@ -385,7 +384,7 @@ 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) {
assert(paint != null);
if (bounds == null) {
_saveLayerWithoutBounds(paint);
@ -420,11 +419,11 @@ class Canvas {
/// each matching call to [restore] decrements it.
///
/// This number cannot go below 1.
int getSaveCount() => _canvas.saveCount;
int/*!*/ getSaveCount() => _canvas.saveCount;
/// 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) {
_canvas.translate(dx, dy);
}
@ -434,14 +433,14 @@ class Canvas {
///
/// If [sy] is unspecified, [sx] will be used for the scale in both
/// directions.
void scale(double sx, [double sy]) => _scale(sx, sy ?? sx);
void scale(double/*!*/ sx, [double/*?*/ sy]) => _scale(sx, sy ?? sx);
void _scale(double sx, double sy) {
_canvas.scale(sx, sy);
}
/// Add a rotation to the current transform. The argument is in radians clockwise.
void rotate(double radians) {
void rotate(double/*!*/ radians) {
_canvas.rotate(radians);
}
@ -449,13 +448,13 @@ class Canvas {
/// 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) {
_canvas.skew(sx, sy);
}
/// Multiply the current transform by the specified 44 transformation matrix
/// specified as a list of values in column-major order.
void transform(Float64List matrix4) {
void transform(Float64List/*!*/ matrix4) {
assert(matrix4 != null);
if (matrix4.length != 16) {
throw ArgumentError('"matrix4" must have 16 entries.');
@ -478,8 +477,8 @@ 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}) {
assert(engine.rectIsValid(rect));
assert(clipOp != null);
assert(doAntiAlias != null);
@ -498,7 +497,7 @@ 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}) {
assert(engine.rrectIsValid(rrect));
assert(doAntiAlias != null);
_clipRRect(rrect, doAntiAlias);
@ -517,7 +516,7 @@ 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}) {
assert(path != null); // path is checked on the engine side
assert(doAntiAlias != null);
_clipPath(path, doAntiAlias);
@ -530,7 +529,7 @@ class Canvas {
/// 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) {
assert(color != null);
assert(blendMode != null);
_drawColor(color, blendMode);
@ -544,7 +543,7 @@ class Canvas {
/// 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) {
assert(engine.offsetIsValid(p1));
assert(engine.offsetIsValid(p2));
assert(paint != null);
@ -559,7 +558,7 @@ class Canvas {
///
/// To fill the canvas with a solid color and blend mode, consider
/// [drawColor] instead.
void drawPaint(Paint paint) {
void drawPaint(Paint/*!*/ paint) {
assert(paint != null);
_drawPaint(paint);
}
@ -570,7 +569,7 @@ class Canvas {
/// 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) {
assert(engine.rectIsValid(rect));
assert(paint != null);
_drawRect(rect, paint);
@ -582,7 +581,7 @@ class Canvas {
/// 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) {
assert(engine.rrectIsValid(rrect));
assert(paint != null);
_drawRRect(rrect, paint);
@ -597,7 +596,7 @@ class Canvas {
/// 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) {
assert(engine.rrectIsValid(outer));
assert(engine.rrectIsValid(inner));
assert(paint != null);
@ -611,7 +610,7 @@ class Canvas {
/// 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) {
assert(engine.rectIsValid(rect));
assert(paint != null);
_drawOval(rect, paint);
@ -625,7 +624,7 @@ class Canvas {
/// 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) {
assert(engine.offsetIsValid(c));
assert(paint != null);
_drawCircle(c, radius, paint);
@ -645,8 +644,8 @@ 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) {
assert(engine.rectIsValid(rect));
assert(paint != null);
const double pi = math.pi;
@ -684,7 +683,7 @@ class Canvas {
/// 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) {
assert(path != null); // path is checked on the engine side
assert(paint != null);
_drawPath(path, paint);
@ -696,7 +695,7 @@ class Canvas {
/// 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) {
assert(image != null); // image is checked on the engine side
assert(engine.offsetIsValid(offset));
assert(paint != null);
@ -716,7 +715,7 @@ 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) {
assert(image != null); // image is checked on the engine side
assert(engine.rectIsValid(src));
assert(engine.rectIsValid(dst));
@ -741,7 +740,7 @@ 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) {
assert(image != null); // image is checked on the engine side
assert(engine.rectIsValid(center));
assert(engine.rectIsValid(dst));
@ -892,7 +891,7 @@ class Canvas {
/// Draw the given picture onto the canvas. To create a picture, see
/// [PictureRecorder].
void drawPicture(Picture picture) {
void drawPicture(Picture/*!*/ picture) {
assert(picture != null); // picture is checked on the engine side
// TODO(het): Support this
throw UnimplementedError();
@ -918,7 +917,7 @@ 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) {
assert(paragraph != null);
assert(engine.offsetIsValid(offset));
_drawParagraph(paragraph, offset);
@ -936,7 +935,7 @@ 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) {
assert(pointMode != null);
assert(points != null);
assert(paint != null);
@ -953,7 +952,7 @@ 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) {
assert(pointMode != null);
assert(points != null);
assert(paint != null);
@ -963,7 +962,7 @@ class Canvas {
_canvas.drawRawPoints(pointMode, points, paint);
}
void drawVertices(Vertices vertices, BlendMode blendMode, Paint paint) {
void drawVertices(Vertices/*!*/ vertices, BlendMode/*!*/ blendMode, Paint/*!*/ paint) {
if (vertices == null) {
return;
}
@ -985,8 +984,15 @@ 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) {
void drawAtlas(
Image/*!*/ atlas,
List<RSTransform/*!*/>/*!*/ transforms,
List<Rect/*!*/>/*!*/ rects,
List<Color/*!*/>/*!*/ colors,
BlendMode/*!*/ blendMode,
Rect/*?*/ cullRect,
Paint/*!*/ paint,
) {
assert(atlas != null); // atlas is checked on the engine side
assert(transforms != null);
assert(rects != null);
@ -1027,8 +1033,15 @@ 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) {
void drawRawAtlas(
Image/*!*/ atlas,
Float32List/*!*/ rstTransforms,
Float32List/*!*/ rects,
Int32List/*!*/ colors,
BlendMode/*!*/ blendMode,
Rect/*?*/ cullRect,
Paint/*!*/ paint,
) {
assert(atlas != null); // atlas is checked on the engine side
assert(rstTransforms != null);
assert(rects != null);
@ -1060,7 +1073,11 @@ 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,
) {
assert(path != null); // path is checked on the engine side
assert(color != null);
assert(transparentOccluder != null);
@ -1084,7 +1101,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.
@ -1094,7 +1111,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
@ -1181,28 +1198,3 @@ enum PathOperation {
/// from the first.
reverseDifference,
}
class RawRecordingCanvas extends engine.BitmapCanvas
implements PictureRecorder {
RawRecordingCanvas(Size size) : super(Offset.zero & size);
@override
void dispose() {
clear();
}
engine.RecordingCanvas beginRecording(Rect bounds) =>
throw UnsupportedError('');
@override
Picture endRecording() => throw UnsupportedError('');
engine.RecordingCanvas _canvas; // ignore: unused_field
bool _isRecording = true; // ignore: unused_field
@override
bool get isRecording => true;
Rect cullRect;
}

View File

@ -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.
@ -86,7 +86,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.
@ -130,7 +130,7 @@ class ChannelBuffers {
}
/// Returns true on overflow.
bool push(String/*!*/ channel, ByteData/*!*/ data, PlatformMessageResponseCallback/*!*/ callback) {
bool/*!*/ push(String/*!*/ channel, ByteData/*?*/ data, PlatformMessageResponseCallback/*!*/ callback) {
_RingBuffer<_StoredMessage> queue = _messages[channel];
if (queue == null) {
queue = _makeRingBuffer(kDefaultBufferSize);
@ -182,7 +182,7 @@ 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);
await callback(message.data, message.callback);

View File

@ -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(
OffsetEngineLayer/*?*/ pushOffset(
double/*!*/ dx,
double/*!*/ dy, {
OffsetEngineLayer oldLayer,
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(
TransformEngineLayer/*?*/ pushTransform(
Float64List/*!*/ matrix4, {
TransformEngineLayer oldLayer,
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(
ClipRectEngineLayer/*?*/ pushClipRect(
Rect/*!*/ rect, {
Clip/*!*/ clipBehavior = Clip.antiAlias,
ClipRectEngineLayer oldLayer,
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(
ClipRRectEngineLayer/*?*/ pushClipRRect(
RRect/*!*/ rrect, {
Clip/*!*/ clipBehavior,
ClipRRectEngineLayer oldLayer,
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(
ClipPathEngineLayer/*?*/ pushClipPath(
Path/*!*/ path, {
Clip/*!*/ clipBehavior = Clip.antiAlias,
ClipPathEngineLayer oldLayer,
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(
OpacityEngineLayer/*?*/ pushOpacity(
int/*!*/ alpha, {
Offset/*!*/ offset = Offset.zero,
OpacityEngineLayer oldLayer,
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(
ColorFilterEngineLayer/*?*/ pushColorFilter(
ColorFilter/*!*/ filter, {
ColorFilterEngineLayer oldLayer,
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(
ImageFilterEngineLayer/*?*/ pushImageFilter(
ImageFilter/*!*/ filter, {
ImageFilterEngineLayer oldLayer,
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(
BackdropFilterEngineLayer/*?*/ pushBackdropFilter(
ImageFilter/*!*/ filter, {
BackdropFilterEngineLayer oldLayer,
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(
ShaderMaskEngineLayer/*?*/ pushShaderMask(
Shader/*!*/ shader,
Rect/*!*/ maskRect,
BlendMode/*!*/ blendMode, {
ShaderMaskEngineLayer oldLayer,
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({
PhysicalShapeEngineLayer/*?*/ pushPhysicalShape({
Path/*!*/ path,
double/*!*/ elevation,
Color/*!*/ color,
Color/*?*/ shadowColor,
Clip/*!*/ clipBehavior = Clip.none,
PhysicalShapeEngineLayer oldLayer,
PhysicalShapeEngineLayer/*?*/ oldLayer,
});
/// Add a retained engine layer subtree from previous frames.

View File

@ -6,8 +6,8 @@
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(() {
@ -45,17 +45,17 @@ Future<void> _initializePlatform({
_webOnlyIsInitialized = true;
}
engine.AssetManager _assetManager;
/*late*/ 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 {
Future<void>/*!*/ webOnlySetAssetManager(engine.AssetManager/*!*/ assetManager) async {
assert(assetManager != null, 'Cannot set assetManager to null');
if (assetManager == _assetManager) {
return;
@ -91,10 +91,10 @@ Future<void> webOnlySetAssetManager(engine.AssetManager assetManager) async {
///
/// 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);

View File

@ -1830,10 +1830,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

@ -36,7 +36,7 @@ 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);
} else {
@ -47,53 +47,53 @@ abstract class Path {
/// 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,19 +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.
///
/// Note: Not very efficient, it creates a canvas, plays path and calls
/// Context2D isPointInPath. If performance becomes issue, retaining
/// RawRecordingCanvas can remove create/remove rootElement cost.
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.
///
@ -264,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`.
@ -272,7 +268,7 @@ 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) {
static Path/*!*/ combine(PathOperation/*!*/ operation, Path/*!*/ path1, Path/*!*/ path2) {
assert(path1 != null);
assert(path2 != null);
if (engine.experimentalUseSkia) {
@ -285,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

@ -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.
@ -115,7 +115,7 @@ class Tangent {
///
/// 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

@ -13,8 +13,8 @@ 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;
@ -27,10 +27,10 @@ Future<dynamic> ensureTestPlatformInitializedThenRunTest(
/// Used to track when the platform is initialized. This ensures the test fonts
/// are available.
Future<void> _platformInitializedFuture;
/*late*/ 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;