forked from firka/flutter
implicit casts and add missing docs (flutter/engine#15698)
This commit is contained in:
@@ -14,6 +14,7 @@ analyzer:
|
||||
# positives.
|
||||
exclude: [ testing/dart/window_hooks_integration_test.dart ]
|
||||
strong-mode:
|
||||
implicit-casts: false
|
||||
implicit-dynamic: false
|
||||
errors:
|
||||
# treat missing required parameters as a warning (not a hint)
|
||||
@@ -39,7 +40,7 @@ linter:
|
||||
- always_specify_types
|
||||
- annotate_overrides
|
||||
# - avoid_annotating_with_dynamic # conflicts with always_specify_types
|
||||
- avoid_as
|
||||
# - avoid_as # required for implicit-casts: false
|
||||
# - avoid_bool_literals_in_conditional_expressions # not yet tested
|
||||
# - avoid_catches_without_on_clauses # we do this commonly
|
||||
# - avoid_catching_errors # we do this commonly
|
||||
|
||||
@@ -101,13 +101,13 @@ Future<int> starter(
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (options['train']) {
|
||||
if (options['train'] as bool) {
|
||||
if (!options.rest.isNotEmpty) {
|
||||
throw Exception('Must specify input.dart');
|
||||
}
|
||||
|
||||
final String input = options.rest[0];
|
||||
final String sdkRoot = options['sdk-root'];
|
||||
final String sdkRoot = options['sdk-root'] as String;
|
||||
final Directory temp =
|
||||
Directory.systemTemp.createTempSync('train_frontend_server');
|
||||
try {
|
||||
@@ -143,7 +143,7 @@ Future<int> starter(
|
||||
|
||||
compiler ??= _FlutterFrontendCompiler(output,
|
||||
transformer: transformer,
|
||||
unsafePackageSerialization: options['unsafe-package-serialization']);
|
||||
unsafePackageSerialization: options['unsafe-package-serialization'] as bool);
|
||||
|
||||
if (options.rest.isNotEmpty) {
|
||||
return await compiler.compile(options.rest[0], options) ? 0 : 254;
|
||||
|
||||
@@ -582,7 +582,7 @@ class SceneBuilder extends NativeFieldWrapperClass2 {
|
||||
void addRetained(EngineLayer retainedLayer) {
|
||||
assert(retainedLayer is _EngineLayerWrapper);
|
||||
assert(() {
|
||||
final _EngineLayerWrapper layer = retainedLayer;
|
||||
final _EngineLayerWrapper layer = retainedLayer as _EngineLayerWrapper;
|
||||
|
||||
void recursivelyCheckChildrenUsedOnce(_EngineLayerWrapper parentLayer) {
|
||||
_debugCheckUsedOnce(parentLayer, 'retained layer');
|
||||
@@ -600,7 +600,7 @@ class SceneBuilder extends NativeFieldWrapperClass2 {
|
||||
return true;
|
||||
}());
|
||||
|
||||
final _EngineLayerWrapper wrapper = retainedLayer;
|
||||
final _EngineLayerWrapper wrapper = retainedLayer as _EngineLayerWrapper;
|
||||
_addRetained(wrapper._nativeLayer);
|
||||
}
|
||||
|
||||
|
||||
@@ -81,11 +81,9 @@ abstract class OffsetBase {
|
||||
/// the right-hand-side operand respectively. Returns false otherwise.
|
||||
@override
|
||||
bool operator ==(dynamic other) {
|
||||
if (other is! OffsetBase)
|
||||
return false;
|
||||
final OffsetBase typedOther = other;
|
||||
return _dx == typedOther._dx &&
|
||||
_dy == typedOther._dy;
|
||||
return other is OffsetBase
|
||||
&& other._dx == _dx
|
||||
&& other._dy == _dy;
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -327,11 +325,9 @@ class Offset extends OffsetBase {
|
||||
/// Compares two Offsets for equality.
|
||||
@override
|
||||
bool operator ==(dynamic other) {
|
||||
if (other is! Offset)
|
||||
return false;
|
||||
final Offset typedOther = other;
|
||||
return dx == typedOther.dx &&
|
||||
dy == typedOther.dy;
|
||||
return other is Offset
|
||||
&& other.dx == dx
|
||||
&& other.dy == dy;
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -595,11 +591,9 @@ class Size extends OffsetBase {
|
||||
// We don't compare the runtimeType because of _DebugSize in the framework.
|
||||
@override
|
||||
bool operator ==(dynamic other) {
|
||||
if (other is! Size)
|
||||
return false;
|
||||
final Size typedOther = other;
|
||||
return _dx == typedOther._dx &&
|
||||
_dy == typedOther._dy;
|
||||
return other is Size
|
||||
&& other._dx == _dx
|
||||
&& other._dy == _dy;
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -877,11 +871,11 @@ class Rect {
|
||||
return true;
|
||||
if (runtimeType != other.runtimeType)
|
||||
return false;
|
||||
final Rect typedOther = other;
|
||||
return left == typedOther.left &&
|
||||
top == typedOther.top &&
|
||||
right == typedOther.right &&
|
||||
bottom == typedOther.bottom;
|
||||
return other is Rect
|
||||
&& other.left == left
|
||||
&& other.top == top
|
||||
&& other.right == right
|
||||
&& other.bottom == bottom;
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -999,8 +993,10 @@ class Radius {
|
||||
return true;
|
||||
if (runtimeType != other.runtimeType)
|
||||
return false;
|
||||
final Radius typedOther = other;
|
||||
return typedOther.x == x && typedOther.y == y;
|
||||
|
||||
return other is Radius
|
||||
&& other.x == x
|
||||
&& other.y == y;
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -1594,19 +1590,19 @@ class RRect {
|
||||
return true;
|
||||
if (runtimeType != other.runtimeType)
|
||||
return false;
|
||||
final RRect typedOther = other;
|
||||
return left == typedOther.left &&
|
||||
top == typedOther.top &&
|
||||
right == typedOther.right &&
|
||||
bottom == typedOther.bottom &&
|
||||
tlRadiusX == typedOther.tlRadiusX &&
|
||||
tlRadiusY == typedOther.tlRadiusY &&
|
||||
trRadiusX == typedOther.trRadiusX &&
|
||||
trRadiusY == typedOther.trRadiusY &&
|
||||
blRadiusX == typedOther.blRadiusX &&
|
||||
blRadiusY == typedOther.blRadiusY &&
|
||||
brRadiusX == typedOther.brRadiusX &&
|
||||
brRadiusY == typedOther.brRadiusY;
|
||||
return other is RRect
|
||||
&& other.left == left
|
||||
&& other.top == top
|
||||
&& other.right == right
|
||||
&& other.bottom == bottom
|
||||
&& other.tlRadiusX == tlRadiusX
|
||||
&& other.tlRadiusY == tlRadiusY
|
||||
&& other.trRadiusX == trRadiusX
|
||||
&& other.trRadiusY == trRadiusY
|
||||
&& other.blRadiusX == blRadiusX
|
||||
&& other.blRadiusY == blRadiusY
|
||||
&& other.brRadiusX == brRadiusX
|
||||
&& other.brRadiusY == brRadiusY;
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -98,13 +98,13 @@ void _updateLocales(List<String> locales) {
|
||||
@pragma('vm:entry-point')
|
||||
// ignore: unused_element
|
||||
void _updateUserSettingsData(String jsonData) {
|
||||
final Map<String, dynamic> data = json.decode(jsonData);
|
||||
final Map<String, dynamic> data = json.decode(jsonData) as Map<String, dynamic>;
|
||||
if (data.isEmpty) {
|
||||
return;
|
||||
}
|
||||
_updateTextScaleFactor(data['textScaleFactor'].toDouble());
|
||||
_updateAlwaysUse24HourFormat(data['alwaysUse24HourFormat']);
|
||||
_updatePlatformBrightness(data['platformBrightness']);
|
||||
_updateTextScaleFactor((data['textScaleFactor'] as num).toDouble());
|
||||
_updateAlwaysUse24HourFormat(data['alwaysUse24HourFormat'] as bool);
|
||||
_updatePlatformBrightness(data['platformBrightness'] as String);
|
||||
}
|
||||
|
||||
@pragma('vm:entry-point')
|
||||
@@ -149,6 +149,7 @@ void _updateAccessibilityFeatures(int values) {
|
||||
}
|
||||
|
||||
@pragma('vm:entry-point')
|
||||
// ignore: unused_element
|
||||
void _dispatchPlatformMessage(String name, ByteData data, int responseId) {
|
||||
if (name == ChannelBuffers.kControlChannelName) {
|
||||
try {
|
||||
|
||||
@@ -10,5 +10,5 @@ double lerpDouble(num a, num b, double t) {
|
||||
return null;
|
||||
a ??= 0.0;
|
||||
b ??= 0.0;
|
||||
return a + (b - a) * t;
|
||||
return a + (b - a) * t as double;
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ List<int> saveCompilationTrace() {
|
||||
final dynamic result = _saveCompilationTrace();
|
||||
if (result is Error)
|
||||
throw result;
|
||||
return result;
|
||||
return result as List<int>;
|
||||
}
|
||||
|
||||
dynamic _saveCompilationTrace() native 'SaveCompilationTrace';
|
||||
|
||||
@@ -53,7 +53,7 @@ bool _radiusIsValid(Radius radius) {
|
||||
}
|
||||
|
||||
Color _scaleAlpha(Color a, double factor) {
|
||||
return a.withAlpha((a.alpha * factor).round().clamp(0, 255));
|
||||
return a.withAlpha((a.alpha * factor).round().clamp(0, 255) as int);
|
||||
}
|
||||
|
||||
/// An immutable 32 bit color value in ARGB format.
|
||||
@@ -217,7 +217,7 @@ class Color {
|
||||
static double _linearizeColorComponent(double component) {
|
||||
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.
|
||||
@@ -265,10 +265,10 @@ class Color {
|
||||
if (b == null)
|
||||
return _scaleAlpha(a, 1.0 - t);
|
||||
return Color.fromARGB(
|
||||
lerpDouble(a.alpha, b.alpha, t).toInt().clamp(0, 255),
|
||||
lerpDouble(a.red, b.red, t).toInt().clamp(0, 255),
|
||||
lerpDouble(a.green, b.green, t).toInt().clamp(0, 255),
|
||||
lerpDouble(a.blue, b.blue, t).toInt().clamp(0, 255),
|
||||
lerpDouble(a.alpha, b.alpha, t).toInt().clamp(0, 255) as int,
|
||||
lerpDouble(a.red, b.red, t).toInt().clamp(0, 255) as int,
|
||||
lerpDouble(a.green, b.green, t).toInt().clamp(0, 255) as int,
|
||||
lerpDouble(a.blue, b.blue, t).toInt().clamp(0, 255) as int,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -321,8 +321,8 @@ class Color {
|
||||
return true;
|
||||
if (other.runtimeType != runtimeType)
|
||||
return false;
|
||||
final Color typedOther = other;
|
||||
return value == typedOther.value;
|
||||
return other is Color
|
||||
&& other.value == value;
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -1338,7 +1338,7 @@ class Paint {
|
||||
Shader get shader {
|
||||
if (_objects == null)
|
||||
return null;
|
||||
return _objects[_kShaderIndex];
|
||||
return _objects[_kShaderIndex] as Shader;
|
||||
}
|
||||
set shader(Shader value) {
|
||||
_objects ??= List<dynamic>(_kObjectCount);
|
||||
@@ -1355,7 +1355,7 @@ class Paint {
|
||||
if (_objects == null || _objects[_kColorFilterIndex] == null) {
|
||||
return null;
|
||||
}
|
||||
return _objects[_kColorFilterIndex].creator;
|
||||
return _objects[_kColorFilterIndex].creator as ColorFilter;
|
||||
}
|
||||
|
||||
set colorFilter(ColorFilter value) {
|
||||
@@ -1399,7 +1399,7 @@ class Paint {
|
||||
ImageFilter get imageFilter {
|
||||
if (_objects == null || _objects[_kImageFilterIndex] == null)
|
||||
return null;
|
||||
return _objects[_kImageFilterIndex].creator;
|
||||
return _objects[_kImageFilterIndex].creator as ImageFilter;
|
||||
}
|
||||
|
||||
set imageFilter(ImageFilter value) {
|
||||
@@ -2508,11 +2508,9 @@ class MaskFilter {
|
||||
|
||||
@override
|
||||
bool operator ==(dynamic other) {
|
||||
if (other is! MaskFilter)
|
||||
return false;
|
||||
final MaskFilter typedOther = other;
|
||||
return _style == typedOther._style &&
|
||||
_sigma == typedOther._sigma;
|
||||
return other is MaskFilter
|
||||
&& other._style == _style
|
||||
&& other._sigma == _sigma;
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -2639,19 +2637,11 @@ class ColorFilter {
|
||||
|
||||
@override
|
||||
bool operator ==(dynamic other) {
|
||||
if (other is! ColorFilter) {
|
||||
return false;
|
||||
}
|
||||
final ColorFilter typedOther = other;
|
||||
|
||||
if (_type != typedOther._type) {
|
||||
return false;
|
||||
}
|
||||
if (!_listEquals<double>(_matrix, typedOther._matrix)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return _color == typedOther._color && _blendMode == typedOther._blendMode;
|
||||
return other is ColorFilter
|
||||
&& other._type == _type
|
||||
&& _listEquals<double>(other._matrix, _matrix)
|
||||
&& other._color == _color
|
||||
&& other._blendMode == _blendMode;
|
||||
}
|
||||
|
||||
_ColorFilter _toNativeColorFilter() {
|
||||
@@ -2791,19 +2781,10 @@ class ImageFilter {
|
||||
|
||||
@override
|
||||
bool operator ==(dynamic other) {
|
||||
if (other is! ImageFilter) {
|
||||
return false;
|
||||
}
|
||||
final ImageFilter typedOther = other;
|
||||
|
||||
if (_type != typedOther._type) {
|
||||
return false;
|
||||
}
|
||||
if (!_listEquals<double>(_data, typedOther._data)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return _filterQuality == typedOther._filterQuality;
|
||||
return other is ImageFilter
|
||||
&& other._type == _type
|
||||
&& _listEquals<double>(other._data, _data)
|
||||
&& other._filterQuality == _filterQuality;
|
||||
}
|
||||
|
||||
_ImageFilter _toNativeImageFilter() => _nativeFilter ??= _makeNativeImageFilter();
|
||||
@@ -3187,6 +3168,15 @@ enum VertexMode {
|
||||
|
||||
/// A set of vertex data used by [Canvas.drawVertices].
|
||||
class Vertices extends NativeFieldWrapperClass2 {
|
||||
/// Creates a set of vertex data for use with [Canvas.drawVertices].
|
||||
///
|
||||
/// The [mode] and [positions] parameters must not be null.
|
||||
///
|
||||
/// If the [textureCoordinates] or [colors] parameters are provided, they must
|
||||
/// be the same length as [positions].
|
||||
///
|
||||
/// If the [indices] parameter is provided, all values in the list must be
|
||||
/// valid index values for [positions].
|
||||
Vertices(
|
||||
VertexMode mode,
|
||||
List<Offset> positions, {
|
||||
@@ -3218,6 +3208,24 @@ class Vertices extends NativeFieldWrapperClass2 {
|
||||
throw ArgumentError('Invalid configuration for vertices.');
|
||||
}
|
||||
|
||||
/// Creates a set of vertex data for use with [Canvas.drawVertices], directly
|
||||
/// using the encoding methods of [new Vertices].
|
||||
///
|
||||
/// The [mode] parameter must not be null.
|
||||
///
|
||||
/// The [positions] list is interpreted as a list of repeated pairs of x,y
|
||||
/// coordinates. It must not be null.
|
||||
///
|
||||
/// The [textureCoordinates] list is interpreted as a list of repeated pairs
|
||||
/// of x,y coordinates, and must be the same length of [positions] if it
|
||||
/// is not null.
|
||||
///
|
||||
/// The [colors] list is interpreted as a list of RGBA encoded colors, similar
|
||||
/// to [Color.value]. It must be half length of [positions] if it is not
|
||||
/// null.
|
||||
///
|
||||
/// If the [indices] list is provided, all values in the list must be
|
||||
/// valid index values for [positions].
|
||||
Vertices.raw(
|
||||
VertexMode mode,
|
||||
Float32List positions, {
|
||||
@@ -3891,6 +3899,14 @@ class Canvas extends NativeFieldWrapperClass2 {
|
||||
int pointMode,
|
||||
Float32List points) native 'Canvas_drawPoints';
|
||||
|
||||
/// Draws the set of [Vertices] onto the canvas.
|
||||
///
|
||||
/// All parameters must not be null.
|
||||
///
|
||||
/// See also:
|
||||
/// * [new Vertices], which creates a set of vertices to draw on the canvas.
|
||||
/// * [Vertices.raw], which creates the vertices using typed data lists
|
||||
/// rather than unencoded lists.
|
||||
void drawVertices(Vertices vertices, BlendMode blendMode, Paint paint) {
|
||||
assert(vertices != null); // vertices is checked on the engine side
|
||||
assert(paint != null);
|
||||
@@ -3902,11 +3918,18 @@ class Canvas extends NativeFieldWrapperClass2 {
|
||||
List<dynamic> paintObjects,
|
||||
ByteData paintData) native 'Canvas_drawVertices';
|
||||
|
||||
//
|
||||
// See also:
|
||||
//
|
||||
// * [drawRawAtlas], which takes its arguments as typed data lists rather
|
||||
// than objects.
|
||||
/// Draws part of an image - the [atlas] - onto the canvas.
|
||||
///
|
||||
/// This method allows for optimization when you only want to draw part of an
|
||||
/// image on the canvas, such as when using sprites or zooming. It is more
|
||||
/// efficient than using clips or masks directly.
|
||||
///
|
||||
/// All parameters mmust not be null.
|
||||
///
|
||||
/// See also:
|
||||
///
|
||||
/// * [drawRawAtlas], which takes its arguments as typed data lists rather
|
||||
/// than objects.
|
||||
void drawAtlas(Image atlas,
|
||||
List<RSTransform> transforms,
|
||||
List<Rect> rects,
|
||||
@@ -3957,21 +3980,26 @@ class Canvas extends NativeFieldWrapperClass2 {
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// The `rstTransforms` argument is interpreted as a list of four-tuples, with
|
||||
// each tuple being ([RSTransform.scos], [RSTransform.ssin],
|
||||
// [RSTransform.tx], [RSTransform.ty]).
|
||||
//
|
||||
// The `rects` argument is interpreted as a list of four-tuples, with each
|
||||
// tuple being ([Rect.left], [Rect.top], [Rect.right], [Rect.bottom]).
|
||||
//
|
||||
// The `colors` argument, which can be null, is interpreted as a list of
|
||||
// 32-bit colors, with the same packing as [Color.value].
|
||||
//
|
||||
// See also:
|
||||
//
|
||||
// * [drawAtlas], which takes its arguments as objects rather than typed
|
||||
// data lists.
|
||||
/// Draws part of an image - the [atlas] - onto the canvas.
|
||||
///
|
||||
/// This method allows for optimization when you only want to draw part of an
|
||||
/// image on the canvas, such as when using sprites or zooming. It is more
|
||||
/// efficient than using clips or masks directly.
|
||||
///
|
||||
/// The [rstTransforms] argument is interpreted as a list of four-tuples, with
|
||||
/// each tuple being ([RSTransform.scos], [RSTransform.ssin],
|
||||
/// [RSTransform.tx], [RSTransform.ty]).
|
||||
///
|
||||
/// The [rects] argument is interpreted as a list of four-tuples, with each
|
||||
/// tuple being ([Rect.left], [Rect.top], [Rect.right], [Rect.bottom]).
|
||||
///
|
||||
/// The [colors] argument, which can be null, is interpreted as a list of
|
||||
/// 32-bit colors, with the same packing as [Color.value].
|
||||
///
|
||||
/// See also:
|
||||
///
|
||||
/// * [drawAtlas], which takes its arguments as objects rather than typed
|
||||
/// data lists.
|
||||
void drawRawAtlas(Image atlas,
|
||||
Float32List rstTransforms,
|
||||
Float32List rects,
|
||||
@@ -4250,12 +4278,10 @@ class Shadow {
|
||||
bool operator ==(dynamic other) {
|
||||
if (identical(this, other))
|
||||
return true;
|
||||
if (other is! Shadow)
|
||||
return false;
|
||||
final Shadow typedOther = other;
|
||||
return color == typedOther.color &&
|
||||
offset == typedOther.offset &&
|
||||
blurRadius == typedOther.blurRadius;
|
||||
return other is Shadow
|
||||
&& other.color == color
|
||||
&& other.offset == offset
|
||||
&& other.blurRadius == blurRadius;
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -25,8 +25,8 @@ class CallbackHandle {
|
||||
bool operator ==(dynamic other) {
|
||||
if (runtimeType != other.runtimeType)
|
||||
return false;
|
||||
final CallbackHandle typedOther = other;
|
||||
return _handle == typedOther._handle;
|
||||
return other is CallbackHandle
|
||||
&& other._handle == _handle;
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -83,7 +83,7 @@ class FontWeight {
|
||||
assert(t != null);
|
||||
if (a == null && b == null)
|
||||
return null;
|
||||
return values[lerpDouble(a?.index ?? normal.index, b?.index ?? normal.index, t).round().clamp(0, 8)];
|
||||
return values[lerpDouble(a?.index ?? normal.index, b?.index ?? normal.index, t).round().clamp(0, 8) as int];
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -300,9 +300,9 @@ class FontFeature {
|
||||
return true;
|
||||
if (other.runtimeType != runtimeType)
|
||||
return false;
|
||||
final FontFeature typedOther = other;
|
||||
return feature == typedOther.feature
|
||||
&& value == typedOther.value;
|
||||
return other is FontFeature
|
||||
&& other.feature == feature
|
||||
&& other.value == value;
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -387,10 +387,8 @@ class TextDecoration {
|
||||
|
||||
@override
|
||||
bool operator ==(dynamic other) {
|
||||
if (other is! TextDecoration)
|
||||
return false;
|
||||
final TextDecoration typedOther = other;
|
||||
return _mask == typedOther._mask;
|
||||
return other is TextDecoration
|
||||
&& other._mask == _mask;
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -680,30 +678,20 @@ class TextStyle {
|
||||
bool operator ==(dynamic other) {
|
||||
if (identical(this, other))
|
||||
return true;
|
||||
if (other is! TextStyle)
|
||||
return false;
|
||||
final TextStyle typedOther = other;
|
||||
if (_fontFamily != typedOther._fontFamily ||
|
||||
_fontSize != typedOther._fontSize ||
|
||||
_letterSpacing != typedOther._letterSpacing ||
|
||||
_wordSpacing != typedOther._wordSpacing ||
|
||||
_height != typedOther._height ||
|
||||
_decorationThickness != typedOther._decorationThickness ||
|
||||
_locale != typedOther._locale ||
|
||||
_background != typedOther._background ||
|
||||
_foreground != typedOther._foreground)
|
||||
return false;
|
||||
for (int index = 0; index < _encoded.length; index += 1) {
|
||||
if (_encoded[index] != typedOther._encoded[index])
|
||||
return false;
|
||||
}
|
||||
if (!_listEquals<Shadow>(_shadows, typedOther._shadows))
|
||||
return false;
|
||||
if (!_listEquals<String>(_fontFamilyFallback, typedOther._fontFamilyFallback))
|
||||
return false;
|
||||
if (!_listEquals<FontFeature>(_fontFeatures, typedOther._fontFeatures))
|
||||
return false;
|
||||
return true;
|
||||
return other is TextStyle
|
||||
&& other._fontFamily == _fontFamily
|
||||
&& other._fontSize == _fontSize
|
||||
&& other._letterSpacing == _letterSpacing
|
||||
&& other._wordSpacing == _wordSpacing
|
||||
&& other._height == _height
|
||||
&& other._decorationThickness == _decorationThickness
|
||||
&& other._locale == _locale
|
||||
&& other._background == _background
|
||||
&& other._foreground == _foreground
|
||||
&& _listEquals<int>(other._encoded, _encoded)
|
||||
&& _listEquals<Shadow>(other._shadows, _shadows)
|
||||
&& _listEquals<String>(other._fontFamilyFallback, _fontFamilyFallback)
|
||||
&& _listEquals<FontFeature>(other._fontFeatures, _fontFeatures);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -920,19 +908,14 @@ class ParagraphStyle {
|
||||
return true;
|
||||
if (other.runtimeType != runtimeType)
|
||||
return false;
|
||||
final ParagraphStyle typedOther = other;
|
||||
if (_fontFamily != typedOther._fontFamily ||
|
||||
_fontSize != typedOther._fontSize ||
|
||||
_height != typedOther._height ||
|
||||
_strutStyle != typedOther._strutStyle ||
|
||||
_ellipsis != typedOther._ellipsis ||
|
||||
_locale != typedOther._locale)
|
||||
return false;
|
||||
for (int index = 0; index < _encoded.length; index += 1) {
|
||||
if (_encoded[index] != typedOther._encoded[index])
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return other is ParagraphStyle
|
||||
&& other._fontFamily == _fontFamily
|
||||
&& other._fontSize == _fontSize
|
||||
&& other._height == _height
|
||||
&& other._strutStyle == _strutStyle
|
||||
&& other._ellipsis == _ellipsis
|
||||
&& other._locale == _locale
|
||||
&& _listEquals<int>(other._encoded, _encoded);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -1101,18 +1084,10 @@ class StrutStyle {
|
||||
return true;
|
||||
if (other.runtimeType != runtimeType)
|
||||
return false;
|
||||
final StrutStyle typedOther = other;
|
||||
if (_fontFamily != typedOther._fontFamily)
|
||||
return false;
|
||||
final Int8List encodedList = _encoded.buffer.asInt8List();
|
||||
final Int8List otherEncodedList = typedOther._encoded.buffer.asInt8List();
|
||||
for (int index = 0; index < _encoded.lengthInBytes; index += 1) {
|
||||
if (encodedList[index] != otherEncodedList[index])
|
||||
return false;
|
||||
}
|
||||
if (!_listEquals<String>(_fontFamilyFallback, typedOther._fontFamilyFallback))
|
||||
return false;
|
||||
return true;
|
||||
return other is StrutStyle
|
||||
&& other._fontFamily == _fontFamily
|
||||
&& _listEquals<String>(other._fontFamilyFallback, _fontFamilyFallback)
|
||||
&& _listEquals<int>(other._encoded.buffer.asInt8List(), _encoded.buffer.asInt8List());
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -1228,6 +1203,7 @@ class TextBox {
|
||||
);
|
||||
|
||||
@pragma('vm:entry-point')
|
||||
// ignore: unused_element
|
||||
TextBox._(
|
||||
this.left,
|
||||
this.top,
|
||||
@@ -1282,12 +1258,12 @@ class TextBox {
|
||||
return true;
|
||||
if (other.runtimeType != runtimeType)
|
||||
return false;
|
||||
final TextBox typedOther = other;
|
||||
return typedOther.left == left
|
||||
&& typedOther.top == top
|
||||
&& typedOther.right == right
|
||||
&& typedOther.bottom == bottom
|
||||
&& typedOther.direction == direction;
|
||||
return other is TextBox
|
||||
&& other.left == left
|
||||
&& other.top == top
|
||||
&& other.right == right
|
||||
&& other.bottom == bottom
|
||||
&& other.direction == direction;
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -1392,9 +1368,9 @@ class TextPosition {
|
||||
bool operator ==(dynamic other) {
|
||||
if (other.runtimeType != runtimeType)
|
||||
return false;
|
||||
final TextPosition typedOther = other;
|
||||
return typedOther.offset == offset
|
||||
&& typedOther.affinity == affinity;
|
||||
return other is TextPosition
|
||||
&& other.offset == offset
|
||||
&& other.affinity == affinity;
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -1476,11 +1452,9 @@ class TextRange {
|
||||
bool operator ==(dynamic other) {
|
||||
if (identical(this, other))
|
||||
return true;
|
||||
if (other is! TextRange)
|
||||
return false;
|
||||
final TextRange typedOther = other;
|
||||
return typedOther.start == start
|
||||
&& typedOther.end == end;
|
||||
return other is TextRange
|
||||
&& other.start == start
|
||||
&& other.end == end;
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -1530,8 +1504,8 @@ class ParagraphConstraints {
|
||||
bool operator ==(dynamic other) {
|
||||
if (other.runtimeType != runtimeType)
|
||||
return false;
|
||||
final ParagraphConstraints typedOther = other;
|
||||
return typedOther.width == width;
|
||||
return other is ParagraphConstraints
|
||||
&& other.width == width;
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -1683,6 +1657,7 @@ class LineMetrics {
|
||||
});
|
||||
|
||||
@pragma('vm:entry-point')
|
||||
// ignore: unused_element
|
||||
LineMetrics._(
|
||||
this.hardBreak,
|
||||
this.ascent,
|
||||
|
||||
@@ -472,12 +472,10 @@ class Locale {
|
||||
bool operator ==(dynamic other) {
|
||||
if (identical(this, other))
|
||||
return true;
|
||||
if (other is! Locale)
|
||||
return false;
|
||||
final Locale typedOther = other;
|
||||
return languageCode == typedOther.languageCode
|
||||
&& scriptCode == typedOther.scriptCode
|
||||
&& countryCode == typedOther.countryCode;
|
||||
return other is Locale
|
||||
&& other.languageCode == languageCode
|
||||
&& other.scriptCode == scriptCode
|
||||
&& other.countryCode == countryCode;
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -1260,8 +1258,8 @@ class AccessibilityFeatures {
|
||||
bool operator ==(dynamic other) {
|
||||
if (other.runtimeType != runtimeType)
|
||||
return false;
|
||||
final AccessibilityFeatures typedOther = other;
|
||||
return _index == typedOther._index;
|
||||
return other is AccessibilityFeatures
|
||||
&& other._index == _index;
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -81,6 +81,15 @@ class Vertices {
|
||||
engine.initWebGl();
|
||||
}
|
||||
|
||||
/// Creates a set of vertex data for use with [Canvas.drawVertices].
|
||||
///
|
||||
/// The [mode] and [positions] parameters must not be null.
|
||||
///
|
||||
/// If the [textureCoordinates] or [colors] parameters are provided, they must
|
||||
/// be the same length as [positions].
|
||||
///
|
||||
/// 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, {
|
||||
@@ -137,6 +146,24 @@ class Vertices {
|
||||
return list;
|
||||
}
|
||||
|
||||
/// Creates a set of vertex data for use with [Canvas.drawVertices], directly
|
||||
/// using the encoding methods of [new Vertices].
|
||||
///
|
||||
/// The [mode] parameter must not be null.
|
||||
///
|
||||
/// The [positions] list is interpreted as a list of repeated pairs of x,y
|
||||
/// coordinates. It must not be null.
|
||||
///
|
||||
/// The [textureCoordinates] list is interpreted as a list of repeated pairs
|
||||
/// of x,y coordinates, and must be the same length of [positions] if it
|
||||
/// is not null.
|
||||
///
|
||||
/// The [colors] list is interpreted as a list of RGBA encoded colors, similar
|
||||
/// to [Color.value]. It must be half length of [positions] if it is not
|
||||
/// null.
|
||||
///
|
||||
/// 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, {
|
||||
@@ -953,11 +980,18 @@ class Canvas {
|
||||
_canvas.drawVertices(vertices, blendMode, paint);
|
||||
}
|
||||
|
||||
//
|
||||
// See also:
|
||||
//
|
||||
// * [drawRawAtlas], which takes its arguments as typed data lists rather
|
||||
// than objects.
|
||||
/// Draws part of an image - the [atlas] - onto the canvas.
|
||||
///
|
||||
/// This method allows for optimization when you only want to draw part of an
|
||||
/// image on the canvas, such as when using sprites or zooming. It is more
|
||||
/// efficient than using clips or masks directly.
|
||||
///
|
||||
/// All parameters must not be null.
|
||||
///
|
||||
/// See also:
|
||||
///
|
||||
/// * [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) {
|
||||
assert(atlas != null); // atlas is checked on the engine side
|
||||
@@ -980,21 +1014,26 @@ class Canvas {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
//
|
||||
// The `rstTransforms` argument is interpreted as a list of four-tuples, with
|
||||
// each tuple being ([RSTransform.scos], [RSTransform.ssin],
|
||||
// [RSTransform.tx], [RSTransform.ty]).
|
||||
//
|
||||
// The `rects` argument is interpreted as a list of four-tuples, with each
|
||||
// tuple being ([Rect.left], [Rect.top], [Rect.right], [Rect.bottom]).
|
||||
//
|
||||
// The `colors` argument, which can be null, is interpreted as a list of
|
||||
// 32-bit colors, with the same packing as [Color.value].
|
||||
//
|
||||
// See also:
|
||||
//
|
||||
// * [drawAtlas], which takes its arguments as objects rather than typed
|
||||
// data lists.
|
||||
/// Draws part of an image - the [atlas] - onto the canvas.
|
||||
///
|
||||
/// This method allows for optimization when you only want to draw part of an
|
||||
/// image on the canvas, such as when using sprites or zooming. It is more
|
||||
/// efficient than using clips or masks directly.
|
||||
///
|
||||
/// The [rstTransforms] argument is interpreted as a list of four-tuples, with
|
||||
/// each tuple being ([RSTransform.scos], [RSTransform.ssin],
|
||||
/// [RSTransform.tx], [RSTransform.ty]).
|
||||
///
|
||||
/// The [rects] argument is interpreted as a list of four-tuples, with each
|
||||
/// tuple being ([Rect.left], [Rect.top], [Rect.right], [Rect.bottom]).
|
||||
///
|
||||
/// The [colors] argument, which can be null, is interpreted as a list of
|
||||
/// 32-bit colors, with the same packing as [Color.value].
|
||||
///
|
||||
/// See also:
|
||||
///
|
||||
/// * [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) {
|
||||
assert(atlas != null); // atlas is checked on the engine side
|
||||
|
||||
@@ -7,7 +7,7 @@ import 'package:test/test.dart';
|
||||
void main() {
|
||||
|
||||
ByteData _makeByteData(String str) {
|
||||
final Uint8List list = utf8.encode(str);
|
||||
final Uint8List list = utf8.encode(str) as Uint8List;
|
||||
final ByteBuffer buffer = list is Uint8List ? list.buffer : Uint8List.fromList(list).buffer;
|
||||
return ByteData.view(buffer);
|
||||
}
|
||||
|
||||
@@ -164,7 +164,7 @@ void main() {
|
||||
void testPushChildLayerOfRetainedLayer(_TestNoSharingFunction pushFunction) {
|
||||
final SceneBuilder builder1 = SceneBuilder();
|
||||
final EngineLayer layer = pushFunction(builder1, null);
|
||||
final EngineLayer childLayer = builder1.pushOpacity(123);
|
||||
final OpacityEngineLayer childLayer = builder1.pushOpacity(123);
|
||||
builder1.pop();
|
||||
builder1.pop();
|
||||
builder1.build();
|
||||
@@ -187,7 +187,7 @@ void main() {
|
||||
void testRetainParentLayerOfPushedChild(_TestNoSharingFunction pushFunction) {
|
||||
final SceneBuilder builder1 = SceneBuilder();
|
||||
final EngineLayer layer = pushFunction(builder1, null);
|
||||
final EngineLayer childLayer = builder1.pushOpacity(123);
|
||||
final OpacityEngineLayer childLayer = builder1.pushOpacity(123);
|
||||
builder1.pop();
|
||||
builder1.pop();
|
||||
builder1.build();
|
||||
@@ -292,25 +292,25 @@ void main() {
|
||||
|
||||
test('SceneBuilder does not share a layer between addRetained and push*', () {
|
||||
testNoSharing((SceneBuilder builder, EngineLayer oldLayer) {
|
||||
return builder.pushOffset(0, 0, oldLayer: oldLayer);
|
||||
return builder.pushOffset(0, 0, oldLayer: oldLayer as OffsetEngineLayer);
|
||||
});
|
||||
testNoSharing((SceneBuilder builder, EngineLayer oldLayer) {
|
||||
return builder.pushTransform(Float64List(16), oldLayer: oldLayer);
|
||||
return builder.pushTransform(Float64List(16), oldLayer: oldLayer as TransformEngineLayer);
|
||||
});
|
||||
testNoSharing((SceneBuilder builder, EngineLayer oldLayer) {
|
||||
return builder.pushClipRect(Rect.zero, oldLayer: oldLayer);
|
||||
return builder.pushClipRect(Rect.zero, oldLayer: oldLayer as ClipRectEngineLayer);
|
||||
});
|
||||
testNoSharing((SceneBuilder builder, EngineLayer oldLayer) {
|
||||
return builder.pushClipRRect(RRect.zero, oldLayer: oldLayer);
|
||||
return builder.pushClipRRect(RRect.zero, oldLayer: oldLayer as ClipRRectEngineLayer);
|
||||
});
|
||||
testNoSharing((SceneBuilder builder, EngineLayer oldLayer) {
|
||||
return builder.pushClipPath(Path(), oldLayer: oldLayer);
|
||||
return builder.pushClipPath(Path(), oldLayer: oldLayer as ClipPathEngineLayer);
|
||||
});
|
||||
testNoSharing((SceneBuilder builder, EngineLayer oldLayer) {
|
||||
return builder.pushOpacity(100, oldLayer: oldLayer);
|
||||
return builder.pushOpacity(100, oldLayer: oldLayer as OpacityEngineLayer);
|
||||
});
|
||||
testNoSharing((SceneBuilder builder, EngineLayer oldLayer) {
|
||||
return builder.pushBackdropFilter(ImageFilter.blur(), oldLayer: oldLayer);
|
||||
return builder.pushBackdropFilter(ImageFilter.blur(), oldLayer: oldLayer as BackdropFilterEngineLayer);
|
||||
});
|
||||
testNoSharing((SceneBuilder builder, EngineLayer oldLayer) {
|
||||
return builder.pushShaderMask(
|
||||
@@ -321,11 +321,11 @@ void main() {
|
||||
),
|
||||
Rect.zero,
|
||||
BlendMode.color,
|
||||
oldLayer: oldLayer,
|
||||
oldLayer: oldLayer as ShaderMaskEngineLayer,
|
||||
);
|
||||
});
|
||||
testNoSharing((SceneBuilder builder, EngineLayer oldLayer) {
|
||||
return builder.pushPhysicalShape(path: Path(), color: const Color.fromARGB(0, 0, 0, 0), oldLayer: oldLayer);
|
||||
return builder.pushPhysicalShape(path: Path(), color: const Color.fromARGB(0, 0, 0, 0), oldLayer: oldLayer as PhysicalShapeEngineLayer);
|
||||
});
|
||||
testNoSharing((SceneBuilder builder, EngineLayer oldLayer) {
|
||||
return builder.pushColorFilter(
|
||||
@@ -333,7 +333,7 @@ void main() {
|
||||
Color.fromARGB(0, 0, 0, 0),
|
||||
BlendMode.color,
|
||||
),
|
||||
oldLayer: oldLayer,
|
||||
oldLayer: oldLayer as ColorFilterEngineLayer,
|
||||
);
|
||||
});
|
||||
testNoSharing((SceneBuilder builder, EngineLayer oldLayer) {
|
||||
@@ -344,25 +344,25 @@ void main() {
|
||||
0, 0, 1, 0, 0,
|
||||
0, 0, 0, 1, 0,
|
||||
]),
|
||||
oldLayer: oldLayer,
|
||||
oldLayer: oldLayer as ColorFilterEngineLayer,
|
||||
);
|
||||
});
|
||||
testNoSharing((SceneBuilder builder, EngineLayer oldLayer) {
|
||||
return builder.pushColorFilter(
|
||||
const ColorFilter.linearToSrgbGamma(),
|
||||
oldLayer: oldLayer,
|
||||
oldLayer: oldLayer as ColorFilterEngineLayer,
|
||||
);
|
||||
});
|
||||
testNoSharing((SceneBuilder builder, EngineLayer oldLayer) {
|
||||
return builder.pushColorFilter(
|
||||
const ColorFilter.srgbToLinearGamma(),
|
||||
oldLayer: oldLayer,
|
||||
oldLayer: oldLayer as ColorFilterEngineLayer,
|
||||
);
|
||||
});
|
||||
testNoSharing((SceneBuilder builder, EngineLayer oldLayer) {
|
||||
return builder.pushImageFilter(
|
||||
ImageFilter.blur(sigmaX: 10.0, sigmaY: 10.0),
|
||||
oldLayer: oldLayer,
|
||||
oldLayer: oldLayer as ImageFilterEngineLayer,
|
||||
);
|
||||
});
|
||||
testNoSharing((SceneBuilder builder, EngineLayer oldLayer) {
|
||||
@@ -373,7 +373,7 @@ void main() {
|
||||
0, 0, 1, 0,
|
||||
0, 0, 0, 1,
|
||||
])),
|
||||
oldLayer: oldLayer,
|
||||
oldLayer: oldLayer as ImageFilterEngineLayer,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -89,8 +89,8 @@ void main() {
|
||||
// Test driver.
|
||||
final ReceivePort testReceivePort = ReceivePort();
|
||||
testReceivePort.listen(expectAsync1<void, dynamic>((dynamic response) {
|
||||
final int code = response[0];
|
||||
final String message = response[1];
|
||||
final int code = response[0] as int;
|
||||
final String message = response[1] as String;
|
||||
switch (code) {
|
||||
case kStartCode:
|
||||
break;
|
||||
|
||||
@@ -76,13 +76,15 @@ Future<String> _getTimelineData() async {
|
||||
final Uri vmServiceTimelineUri = info.serverUri.resolve('getVMTimeline');
|
||||
final Map<String, dynamic> cpuTimelineJson = await _getJson(cpuProfileTimelineUri);
|
||||
final Map<String, dynamic> vmServiceTimelineJson = await _getJson(vmServiceTimelineUri);
|
||||
final Map<String, dynamic> cpuResult = cpuTimelineJson['result'].cast<String, dynamic>();
|
||||
final Map<String, dynamic> vmServiceResult =
|
||||
vmServiceTimelineJson['result'].cast<String, dynamic>();
|
||||
final Map<String, dynamic> cpuResult = cpuTimelineJson['result'] as Map<String, dynamic>;
|
||||
final Map<String, dynamic> vmServiceResult = vmServiceTimelineJson['result'] as Map<String, dynamic>;
|
||||
|
||||
return json.encode(<String, dynamic>{
|
||||
'stackFrames': cpuResult['stackFrames'],
|
||||
'traceEvents': <dynamic>[...cpuResult['traceEvents'], ...vmServiceResult['traceEvents']],
|
||||
'traceEvents': <dynamic>[
|
||||
...cpuResult['traceEvents'] as List<dynamic>,
|
||||
...vmServiceResult['traceEvents'] as List<dynamic>,
|
||||
],
|
||||
});
|
||||
}
|
||||
|
||||
@@ -94,7 +96,7 @@ Future<Map<String, dynamic>> _getJson(Uri uri) async {
|
||||
return null;
|
||||
}
|
||||
final String data = await utf8.decodeStream(response);
|
||||
return json.decode(data);
|
||||
return json.decode(data) as Map<String, dynamic>;
|
||||
}
|
||||
|
||||
void _onBeginFrame(Duration duration) {
|
||||
|
||||
@@ -35,7 +35,7 @@ void main(List<String> arguments) {
|
||||
throw UnimplementedError('Script only support running on Linux or MacOS.');
|
||||
}
|
||||
final String nmPath = p.join(buildToolsPath, platform, 'clang', 'bin', 'llvm-nm');
|
||||
assert(new Directory(outPath).existsSync());
|
||||
assert(Directory(outPath).existsSync());
|
||||
|
||||
final Iterable<String> releaseBuilds = Directory(outPath).listSync()
|
||||
.where((FileSystemEntity entity) => entity is Directory)
|
||||
@@ -58,7 +58,7 @@ int _checkIos(String outPath, String nmPath, Iterable<String> builds) {
|
||||
int failures = 0;
|
||||
for (String build in builds) {
|
||||
final String libFlutter = p.join(outPath, build, 'Flutter.framework', 'Flutter');
|
||||
if (!new File(libFlutter).existsSync()) {
|
||||
if (!File(libFlutter).existsSync()) {
|
||||
print('SKIPPING: $libFlutter does not exist.');
|
||||
continue;
|
||||
}
|
||||
@@ -90,7 +90,7 @@ int _checkAndroid(String outPath, String nmPath, Iterable<String> builds) {
|
||||
int failures = 0;
|
||||
for (String build in builds) {
|
||||
final String libFlutter = p.join(outPath, build, 'libflutter.so');
|
||||
if (!new File(libFlutter).existsSync()) {
|
||||
if (!File(libFlutter).existsSync()) {
|
||||
print('SKIPPING: $libFlutter does not exist.');
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user