new lints (flutter/engine#8849)
Dart lints added: * Avoid optional new * Avoid optional const * Prefer single quotes * Prefer default assignment `=`
This commit is contained in:
@@ -100,7 +100,7 @@ linter:
|
||||
- prefer_const_literals_to_create_immutables
|
||||
# - prefer_constructors_over_static_methods # not yet tested
|
||||
- prefer_contains
|
||||
# - prefer_equal_for_default_values # not yet tested
|
||||
- prefer_equal_for_default_values
|
||||
# - prefer_expression_function_bodies # conflicts with https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#consider-using--for-short-functions-and-methods
|
||||
# - prefer_final_fields # DIFFERENT FROM FLUTTER/FLUTTER
|
||||
- prefer_final_locals
|
||||
@@ -118,15 +118,16 @@ linter:
|
||||
- slash_for_doc_comments
|
||||
# - sort_constructors_first # DIFFERENT FROM FLUTTER/FLUTTER
|
||||
- sort_unnamed_constructors_first
|
||||
- super_goes_last
|
||||
- test_types_in_equals
|
||||
- throw_in_finally
|
||||
# - type_annotate_public_apis # subset of always_specify_types
|
||||
- type_init_formals
|
||||
# - unawaited_futures # https://github.com/flutter/flutter/issues/5793
|
||||
- unnecessary_brace_in_string_interps
|
||||
- unnecessary_const
|
||||
- unnecessary_getters_setters
|
||||
# - unnecessary_lambdas # https://github.com/dart-lang/linter/issues/498
|
||||
- unnecessary_new
|
||||
- unnecessary_null_aware_assignments
|
||||
- unnecessary_null_in_if_null_operators
|
||||
- unnecessary_overrides
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
#!/bin/bash
|
||||
echo "Analyzing dart:ui library..."
|
||||
|
||||
echo "Using analyzer from `which dartanalyzer`"
|
||||
|
||||
dartanalyzer --version
|
||||
|
||||
RESULTS=`dartanalyzer \
|
||||
--options flutter/analysis_options.yaml \
|
||||
"$1out/host_debug_unopt/gen/sky/bindings/dart_ui/ui.dart" \
|
||||
2>&1 \
|
||||
| grep -Ev "No issues found!" \
|
||||
| grep -Ev "No issues found!" \
|
||||
| grep -Ev "Analyzing.+out/host_debug_unopt/gen/sky/bindings/dart_ui/ui\.dart"`
|
||||
|
||||
echo "$RESULTS"
|
||||
|
||||
@@ -2,9 +2,10 @@
|
||||
set -ex
|
||||
|
||||
PATH="$HOME/depot_tools:$PATH"
|
||||
|
||||
cd ..
|
||||
|
||||
PATH=$(pwd)/third_party/dart/tools/sdks/dart-sdk/bin:$PATH
|
||||
|
||||
# Build the dart UI files
|
||||
flutter/tools/gn --unoptimized
|
||||
ninja -C out/host_debug_unopt generate_dart_ui
|
||||
|
||||
@@ -3,6 +3,10 @@ set -e
|
||||
shopt -s nullglob
|
||||
|
||||
echo "Verifying license script is still happy..."
|
||||
echo "Using pub from `which pub`, dart from `which dart`"
|
||||
|
||||
dart --version
|
||||
|
||||
(cd flutter/tools/licenses; pub get; dart --enable-asserts lib/main.dart --src ../../.. --out ../../../out/license_script_output --golden ../../ci/licenses_golden)
|
||||
|
||||
for f in out/license_script_output/licenses_*; do
|
||||
|
||||
@@ -76,7 +76,7 @@ void _maybeAddCreationLocationArgument(
|
||||
}
|
||||
|
||||
final NamedExpression namedArgument =
|
||||
new NamedExpression(_creationLocationParameterName, creationLocation);
|
||||
NamedExpression(_creationLocationParameterName, creationLocation);
|
||||
namedArgument.parent = arguments;
|
||||
arguments.named.add(namedArgument);
|
||||
}
|
||||
@@ -149,26 +149,26 @@ class _WidgetCallSiteTransformer extends Transformer {
|
||||
Location location, {
|
||||
String name,
|
||||
ListLiteral parameterLocations,
|
||||
bool showFile: true,
|
||||
bool showFile = true,
|
||||
}) {
|
||||
final List<NamedExpression> arguments = <NamedExpression>[
|
||||
new NamedExpression('line', new IntLiteral(location.line)),
|
||||
new NamedExpression('column', new IntLiteral(location.column)),
|
||||
NamedExpression('line', IntLiteral(location.line)),
|
||||
NamedExpression('column', IntLiteral(location.column)),
|
||||
];
|
||||
if (showFile) {
|
||||
arguments.add(new NamedExpression(
|
||||
'file', new StringLiteral(location.file.toString())));
|
||||
arguments.add(NamedExpression(
|
||||
'file', StringLiteral(location.file.toString())));
|
||||
}
|
||||
if (name != null) {
|
||||
arguments.add(new NamedExpression('name', new StringLiteral(name)));
|
||||
arguments.add(NamedExpression('name', StringLiteral(name)));
|
||||
}
|
||||
if (parameterLocations != null) {
|
||||
arguments
|
||||
.add(new NamedExpression('parameterLocations', parameterLocations));
|
||||
.add(NamedExpression('parameterLocations', parameterLocations));
|
||||
}
|
||||
return new ConstructorInvocation(
|
||||
return ConstructorInvocation(
|
||||
_locationClass.constructors.first,
|
||||
new Arguments(<Expression>[], named: arguments),
|
||||
Arguments(<Expression>[], named: arguments),
|
||||
isConst: true,
|
||||
);
|
||||
}
|
||||
@@ -243,7 +243,7 @@ class _WidgetCallSiteTransformer extends Transformer {
|
||||
_creationLocationParameterName,
|
||||
);
|
||||
if (creationLocationParameter != null) {
|
||||
return new VariableGet(creationLocationParameter);
|
||||
return VariableGet(creationLocationParameter);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -270,7 +270,7 @@ class _WidgetCallSiteTransformer extends Transformer {
|
||||
}
|
||||
return _constructLocation(
|
||||
location,
|
||||
parameterLocations: new ListLiteral(
|
||||
parameterLocations: ListLiteral(
|
||||
parameterLocations,
|
||||
typeArgument: _locationClass.thisType,
|
||||
isConst: true,
|
||||
@@ -342,12 +342,12 @@ class WidgetCreatorTracker implements ProgramTransformer {
|
||||
return;
|
||||
}
|
||||
clazz.implementedTypes
|
||||
.add(new Supertype(_hasCreationLocationClass, <DartType>[]));
|
||||
.add(Supertype(_hasCreationLocationClass, <DartType>[]));
|
||||
// We intentionally use the library context of the _HasCreationLocation
|
||||
// class for the private field even if [clazz] is in a different library
|
||||
// so that all classes implementing Widget behave consistently.
|
||||
final Field locationField = new Field(
|
||||
new Name(
|
||||
final Field locationField = Field(
|
||||
Name(
|
||||
_locationFieldName,
|
||||
_hasCreationLocationClass.enclosingLibrary,
|
||||
),
|
||||
@@ -356,7 +356,7 @@ class WidgetCreatorTracker implements ProgramTransformer {
|
||||
clazz.addMember(locationField);
|
||||
|
||||
final Set<Constructor> _handledConstructors =
|
||||
new Set<Constructor>.identity();
|
||||
Set<Constructor>.identity();
|
||||
|
||||
void handleConstructor(Constructor constructor) {
|
||||
if (!_handledConstructors.add(constructor)) {
|
||||
@@ -366,7 +366,7 @@ class WidgetCreatorTracker implements ProgramTransformer {
|
||||
constructor.function,
|
||||
_creationLocationParameterName,
|
||||
));
|
||||
final VariableDeclaration variable = new VariableDeclaration(
|
||||
final VariableDeclaration variable = VariableDeclaration(
|
||||
_creationLocationParameterName,
|
||||
type: _locationClass.thisType,
|
||||
);
|
||||
@@ -386,7 +386,7 @@ class WidgetCreatorTracker implements ProgramTransformer {
|
||||
_maybeAddCreationLocationArgument(
|
||||
initializer.arguments,
|
||||
initializer.target.function,
|
||||
new VariableGet(variable),
|
||||
VariableGet(variable),
|
||||
_locationClass,
|
||||
);
|
||||
hasRedirectingInitializer = true;
|
||||
@@ -394,9 +394,9 @@ class WidgetCreatorTracker implements ProgramTransformer {
|
||||
}
|
||||
}
|
||||
if (!hasRedirectingInitializer) {
|
||||
constructor.initializers.add(new FieldInitializer(
|
||||
constructor.initializers.add(FieldInitializer(
|
||||
locationField,
|
||||
new VariableGet(variable),
|
||||
VariableGet(variable),
|
||||
));
|
||||
// TODO(jacobr): add an assert verifying the locationField is not
|
||||
// null. Currently, we cannot safely add this assert because we do not
|
||||
@@ -405,9 +405,9 @@ class WidgetCreatorTracker implements ProgramTransformer {
|
||||
// arguments but it is possible users could add classes with optional
|
||||
// positional arguments.
|
||||
//
|
||||
// constructor.initializers.add(new AssertInitializer(new AssertStatement(
|
||||
// new IsExpression(
|
||||
// new VariableGet(variable), _locationClass.thisType),
|
||||
// constructor.initializers.add(AssertInitializer(AssertStatement(
|
||||
// IsExpression(
|
||||
// VariableGet(variable), _locationClass.thisType),
|
||||
// conditionStartOffset: constructor.fileOffset,
|
||||
// conditionEndOffset: constructor.fileOffset,
|
||||
// )));
|
||||
@@ -434,7 +434,7 @@ class WidgetCreatorTracker implements ProgramTransformer {
|
||||
}
|
||||
}
|
||||
}
|
||||
return new Component()..libraries.addAll(libraries);
|
||||
return Component()..libraries.addAll(libraries);
|
||||
}
|
||||
|
||||
/// Transform the given [program].
|
||||
@@ -459,13 +459,13 @@ class WidgetCreatorTracker implements ProgramTransformer {
|
||||
// TODO(jacobr): once there is a working incremental ClassHierarchy
|
||||
// constructor switch to using it instead of building a ClassHierarchy off
|
||||
// the full program.
|
||||
hierarchy = new ClassHierarchy(
|
||||
hierarchy = ClassHierarchy(
|
||||
_computeFullProgram(program),
|
||||
onAmbiguousSupertypes: (Class cls, Supertype a, Supertype b) { },
|
||||
);
|
||||
|
||||
final Set<Class> transformedClasses = new Set<Class>.identity();
|
||||
final Set<Library> librariesToTransform = new Set<Library>.identity()
|
||||
final Set<Class> transformedClasses = Set<Class>.identity();
|
||||
final Set<Library> librariesToTransform = Set<Library>.identity()
|
||||
..addAll(libraries);
|
||||
|
||||
for (Library library in libraries) {
|
||||
@@ -483,7 +483,7 @@ class WidgetCreatorTracker implements ProgramTransformer {
|
||||
|
||||
// Transform call sites to pass the location parameter.
|
||||
final _WidgetCallSiteTransformer callsiteTransformer =
|
||||
new _WidgetCallSiteTransformer(
|
||||
_WidgetCallSiteTransformer(
|
||||
hierarchy,
|
||||
widgetClass: _widgetClass,
|
||||
locationClass: _locationClass,
|
||||
@@ -528,7 +528,7 @@ class WidgetCreatorTracker implements ProgramTransformer {
|
||||
if (procedure.isFactory) {
|
||||
_maybeAddNamedParameter(
|
||||
procedure.function,
|
||||
new VariableDeclaration(
|
||||
VariableDeclaration(
|
||||
_creationLocationParameterName,
|
||||
type: _locationClass.thisType,
|
||||
),
|
||||
@@ -544,14 +544,14 @@ class WidgetCreatorTracker implements ProgramTransformer {
|
||||
}
|
||||
|
||||
final Set<Constructor> _handledConstructors =
|
||||
new Set<Constructor>.identity();
|
||||
Set<Constructor>.identity();
|
||||
|
||||
void handleConstructor(Constructor constructor) {
|
||||
if (!_handledConstructors.add(constructor)) {
|
||||
return;
|
||||
}
|
||||
|
||||
final VariableDeclaration variable = new VariableDeclaration(
|
||||
final VariableDeclaration variable = VariableDeclaration(
|
||||
_creationLocationParameterName,
|
||||
type: _locationClass.thisType,
|
||||
);
|
||||
@@ -575,7 +575,7 @@ class WidgetCreatorTracker implements ProgramTransformer {
|
||||
_maybeAddCreationLocationArgument(
|
||||
initializer.arguments,
|
||||
initializer.target.function,
|
||||
new VariableGet(variable),
|
||||
VariableGet(variable),
|
||||
_locationClass,
|
||||
);
|
||||
} else if (initializer is SuperInitializer &&
|
||||
@@ -583,7 +583,7 @@ class WidgetCreatorTracker implements ProgramTransformer {
|
||||
_maybeAddCreationLocationArgument(
|
||||
initializer.arguments,
|
||||
initializer.target.function,
|
||||
new VariableGet(variable),
|
||||
VariableGet(variable),
|
||||
_locationClass,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -21,9 +21,9 @@ class _FlutterFrontendCompiler implements frontend.CompilerInterface{
|
||||
final frontend.CompilerInterface _compiler;
|
||||
|
||||
_FlutterFrontendCompiler(StringSink output,
|
||||
{bool trackWidgetCreation: false, bool unsafePackageSerialization}) :
|
||||
_compiler = new frontend.FrontendCompiler(output,
|
||||
transformer: trackWidgetCreation ? new WidgetCreatorTracker() : null,
|
||||
{bool trackWidgetCreation = false, bool unsafePackageSerialization}) :
|
||||
_compiler = frontend.FrontendCompiler(output,
|
||||
transformer: trackWidgetCreation ? WidgetCreatorTracker() : null,
|
||||
unsafePackageSerialization: unsafePackageSerialization);
|
||||
|
||||
@override
|
||||
@@ -108,7 +108,7 @@ Future<int> starter(
|
||||
'--sdk-root=$sdkRoot',
|
||||
'--output-dill=$outputTrainingDill',
|
||||
'--target=flutter']);
|
||||
compiler ??= new _FlutterFrontendCompiler(output, trackWidgetCreation: true);
|
||||
compiler ??= _FlutterFrontendCompiler(output, trackWidgetCreation: true);
|
||||
|
||||
await compiler.compile(Platform.script.toFilePath(), options);
|
||||
compiler.acceptLastDelta();
|
||||
@@ -125,7 +125,7 @@ Future<int> starter(
|
||||
}
|
||||
}
|
||||
|
||||
compiler ??= new _FlutterFrontendCompiler(output,
|
||||
compiler ??= _FlutterFrontendCompiler(output,
|
||||
trackWidgetCreation: options['track-widget-creation'],
|
||||
unsafePackageSerialization: options['unsafe-package-serialization']);
|
||||
|
||||
@@ -133,7 +133,7 @@ Future<int> starter(
|
||||
return await compiler.compile(options.rest[0], options) ? 0 : 254;
|
||||
}
|
||||
|
||||
final Completer<int> completer = new Completer<int>();
|
||||
final Completer<int> completer = Completer<int>();
|
||||
frontend.listenAndCompile(compiler, input ?? stdin, options, completer);
|
||||
return completer.future;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ class _MockedCompiler extends Mock implements frontend.CompilerInterface {}
|
||||
|
||||
Future<int> main() async {
|
||||
group('basic', () {
|
||||
final frontend.CompilerInterface compiler = new _MockedCompiler();
|
||||
final frontend.CompilerInterface compiler = _MockedCompiler();
|
||||
|
||||
test('train with mocked compiler completes', () async {
|
||||
expect(await starter(<String>['--train'], compiler: compiler), equals(0));
|
||||
|
||||
@@ -24,7 +24,7 @@ class Scene extends NativeFieldWrapperClass2 {
|
||||
/// This is a slow operation that is performed on a background thread.
|
||||
Future<Image> toImage(int width, int height) {
|
||||
if (width <= 0 || height <= 0)
|
||||
throw new Exception('Invalid image dimensions.');
|
||||
throw Exception('Invalid image dimensions.');
|
||||
return _futurize(
|
||||
(_Callback<Image> callback) => _toImage(width, height, callback)
|
||||
);
|
||||
@@ -242,7 +242,7 @@ class SceneBuilder extends NativeFieldWrapperClass2 {
|
||||
/// 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 }) {
|
||||
void addPicture(Offset offset, Picture picture, { bool isComplexHint = false, bool willChangeHint = false }) {
|
||||
int hints = 0;
|
||||
if (isComplexHint)
|
||||
hints |= 1;
|
||||
@@ -263,7 +263,7 @@ class SceneBuilder extends NativeFieldWrapperClass2 {
|
||||
/// previous or new size, to workaround this the framework "freezes" the
|
||||
/// texture just before resizing the Android view and un-freezes it when it is
|
||||
/// certain that a frame with the new size is ready.
|
||||
void addTexture(int textureId, { Offset offset: Offset.zero, double width: 0.0, double height: 0.0 , bool freeze: false}) {
|
||||
void addTexture(int textureId, { Offset offset = Offset.zero, double width = 0.0, double height = 0.0 , bool freeze = false}) {
|
||||
assert(offset != null, 'Offset argument was null');
|
||||
_addTexture(offset.dx, offset.dy, width, height, textureId, freeze);
|
||||
}
|
||||
@@ -285,7 +285,7 @@ class SceneBuilder extends NativeFieldWrapperClass2 {
|
||||
/// With a platform view in the scene, Quartz has to composite the two Flutter surfaces and the
|
||||
/// 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}) {
|
||||
void addPlatformView(int viewId, { Offset offset = Offset.zero, double width = 0.0, double height = 0.0}) {
|
||||
assert(offset != null, 'Offset argument was null');
|
||||
_addPlatformView(offset.dx, offset.dy, width, height, viewId);
|
||||
}
|
||||
@@ -294,11 +294,11 @@ class SceneBuilder extends NativeFieldWrapperClass2 {
|
||||
/// (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,
|
||||
Offset offset = Offset.zero,
|
||||
double width = 0.0,
|
||||
double height = 0.0,
|
||||
SceneHost sceneHost,
|
||||
bool hitTestable: true
|
||||
bool hitTestable = true
|
||||
}) {
|
||||
_addChildScene(offset.dx,
|
||||
offset.dy,
|
||||
|
||||
@@ -127,7 +127,7 @@ class Offset extends OffsetBase {
|
||||
///
|
||||
/// The distance can be omitted, to create a unit vector (distance = 1.0).
|
||||
factory Offset.fromDirection(double direction, [ double distance = 1.0 ]) {
|
||||
return new Offset(distance * math.cos(direction), distance * math.sin(direction));
|
||||
return Offset(distance * math.cos(direction), distance * math.sin(direction));
|
||||
}
|
||||
|
||||
/// The x component of the offset.
|
||||
@@ -183,7 +183,7 @@ class Offset extends OffsetBase {
|
||||
/// An offset with zero magnitude.
|
||||
///
|
||||
/// This can be used to represent the origin of a coordinate space.
|
||||
static const Offset zero = const Offset(0.0, 0.0);
|
||||
static const Offset zero = Offset(0.0, 0.0);
|
||||
|
||||
/// An offset with infinite x and y components.
|
||||
///
|
||||
@@ -192,7 +192,7 @@ class Offset extends OffsetBase {
|
||||
/// * [isInfinite], which checks whether either component is infinite.
|
||||
/// * [isFinite], which checks whether both components are finite.
|
||||
// This is included for completeness, because [Size.infinite] exists.
|
||||
static const Offset infinite = const Offset(double.infinity, double.infinity);
|
||||
static const Offset infinite = Offset(double.infinity, double.infinity);
|
||||
|
||||
/// Returns a new offset with the x component scaled by `scaleX` and the y
|
||||
/// component scaled by `scaleY`.
|
||||
@@ -212,7 +212,7 @@ class Offset extends OffsetBase {
|
||||
/// Offset a = const Offset(10.0, 10.0);
|
||||
/// Offset b = -a; // same as: a.scale(-1.0, -1.0)
|
||||
/// ```
|
||||
Offset scale(double scaleX, double scaleY) => new Offset(dx * scaleX, dy * scaleY);
|
||||
Offset scale(double scaleX, double scaleY) => Offset(dx * scaleX, dy * scaleY);
|
||||
|
||||
/// Returns a new offset with translateX added to the x component and
|
||||
/// translateY added to the y component.
|
||||
@@ -226,7 +226,7 @@ class Offset extends OffsetBase {
|
||||
/// Offset c = a + b; // same as: a.translate(b.dx, b.dy)
|
||||
/// Offset d = a - b; // same as: a.translate(-b.dx, -b.dy)
|
||||
/// ```
|
||||
Offset translate(double translateX, double translateY) => new Offset(dx + translateX, dy + translateY);
|
||||
Offset translate(double translateX, double translateY) => Offset(dx + translateX, dy + translateY);
|
||||
|
||||
/// Unary negation operator.
|
||||
///
|
||||
@@ -234,7 +234,7 @@ class Offset extends OffsetBase {
|
||||
///
|
||||
/// If the [Offset] represents an arrow on a plane, this operator returns the
|
||||
/// same arrow but pointing in the reverse direction.
|
||||
Offset operator -() => new Offset(-dx, -dy);
|
||||
Offset operator -() => Offset(-dx, -dy);
|
||||
|
||||
/// Binary subtraction operator.
|
||||
///
|
||||
@@ -243,7 +243,7 @@ class Offset extends OffsetBase {
|
||||
/// left-hand-side operand's [dy] minus the right-hand-side operand's [dy].
|
||||
///
|
||||
/// See also [translate].
|
||||
Offset operator -(Offset other) => new Offset(dx - other.dx, dy - other.dy);
|
||||
Offset operator -(Offset other) => Offset(dx - other.dx, dy - other.dy);
|
||||
|
||||
/// Binary addition operator.
|
||||
///
|
||||
@@ -252,7 +252,7 @@ class Offset extends OffsetBase {
|
||||
/// two operands.
|
||||
///
|
||||
/// See also [translate].
|
||||
Offset operator +(Offset other) => new Offset(dx + other.dx, dy + other.dy);
|
||||
Offset operator +(Offset other) => Offset(dx + other.dx, dy + other.dy);
|
||||
|
||||
/// Multiplication operator.
|
||||
///
|
||||
@@ -261,7 +261,7 @@ class Offset extends OffsetBase {
|
||||
/// right-hand-side operand (a double).
|
||||
///
|
||||
/// See also [scale].
|
||||
Offset operator *(double operand) => new Offset(dx * operand, dy * operand);
|
||||
Offset operator *(double operand) => Offset(dx * operand, dy * operand);
|
||||
|
||||
/// Division operator.
|
||||
///
|
||||
@@ -270,21 +270,21 @@ class Offset extends OffsetBase {
|
||||
/// operand (a double).
|
||||
///
|
||||
/// See also [scale].
|
||||
Offset operator /(double operand) => new Offset(dx / operand, dy / operand);
|
||||
Offset operator /(double operand) => Offset(dx / operand, dy / operand);
|
||||
|
||||
/// Integer (truncating) division operator.
|
||||
///
|
||||
/// Returns an offset whose coordinates are the coordinates of the
|
||||
/// left-hand-side operand (an Offset) divided by the scalar right-hand-side
|
||||
/// operand (a double), rounded towards zero.
|
||||
Offset operator ~/(double operand) => new Offset((dx ~/ operand).toDouble(), (dy ~/ operand).toDouble());
|
||||
Offset operator ~/(double operand) => Offset((dx ~/ operand).toDouble(), (dy ~/ operand).toDouble());
|
||||
|
||||
/// Modulo (remainder) operator.
|
||||
///
|
||||
/// Returns an offset whose coordinates are the remainder of dividing the
|
||||
/// coordinates of the left-hand-side operand (an Offset) by the scalar
|
||||
/// right-hand-side operand (a double).
|
||||
Offset operator %(double operand) => new Offset(dx % operand, dy % operand);
|
||||
Offset operator %(double operand) => Offset(dx % operand, dy % operand);
|
||||
|
||||
/// Rectangle constructor operator.
|
||||
///
|
||||
@@ -294,9 +294,9 @@ class Offset extends OffsetBase {
|
||||
///
|
||||
/// ```dart
|
||||
/// Rect myRect = Offset.zero & const Size(100.0, 100.0);
|
||||
/// // same as: new Rect.fromLTWH(0.0, 0.0, 100.0, 100.0)
|
||||
/// // same as: Rect.fromLTWH(0.0, 0.0, 100.0, 100.0)
|
||||
/// ```
|
||||
Rect operator &(Size other) => new Rect.fromLTWH(dx, dy, other.width, other.height);
|
||||
Rect operator &(Size other) => Rect.fromLTWH(dx, dy, other.width, other.height);
|
||||
|
||||
/// Linearly interpolate between two offsets.
|
||||
///
|
||||
@@ -321,7 +321,7 @@ class Offset extends OffsetBase {
|
||||
return b * t;
|
||||
if (b == null)
|
||||
return a * (1.0 - t);
|
||||
return new Offset(lerpDouble(a.dx, b.dx, t), lerpDouble(a.dy, b.dy, t));
|
||||
return Offset(lerpDouble(a.dx, b.dx, t), lerpDouble(a.dy, b.dy, t));
|
||||
}
|
||||
|
||||
/// Compares two Offsets for equality.
|
||||
@@ -407,7 +407,7 @@ class Size extends OffsetBase {
|
||||
}
|
||||
|
||||
/// An empty size, one with a zero width and a zero height.
|
||||
static const Size zero = const Size(0.0, 0.0);
|
||||
static const Size zero = Size(0.0, 0.0);
|
||||
|
||||
/// A size whose [width] and [height] are infinite.
|
||||
///
|
||||
@@ -415,7 +415,7 @@ class Size extends OffsetBase {
|
||||
///
|
||||
/// * [isInfinite], which checks whether either dimension is infinite.
|
||||
/// * [isFinite], which checks whether both dimensions are finite.
|
||||
static const Size infinite = const Size(double.infinity, double.infinity);
|
||||
static const Size infinite = Size(double.infinity, double.infinity);
|
||||
|
||||
/// Whether this size encloses a non-zero area.
|
||||
///
|
||||
@@ -440,10 +440,10 @@ class Size extends OffsetBase {
|
||||
/// right-hand-side operand.
|
||||
OffsetBase operator -(OffsetBase other) {
|
||||
if (other is Size)
|
||||
return new Offset(width - other.width, height - other.height);
|
||||
return Offset(width - other.width, height - other.height);
|
||||
if (other is Offset)
|
||||
return new Size(width - other.dx, height - other.dy);
|
||||
throw new ArgumentError(other);
|
||||
return Size(width - other.dx, height - other.dy);
|
||||
throw ArgumentError(other);
|
||||
}
|
||||
|
||||
/// Binary addition operator for adding an [Offset] to a [Size].
|
||||
@@ -453,35 +453,35 @@ class Size extends OffsetBase {
|
||||
/// right-hand-side operand, an [Offset], and whose [height] is the sum of the
|
||||
/// [height] of the left-hand-side operand and the [Offset.dy] dimension of
|
||||
/// the right-hand-side operand.
|
||||
Size operator +(Offset other) => new Size(width + other.dx, height + other.dy);
|
||||
Size operator +(Offset other) => Size(width + other.dx, height + other.dy);
|
||||
|
||||
/// Multiplication operator.
|
||||
///
|
||||
/// Returns a [Size] whose dimensions are the dimensions of the left-hand-side
|
||||
/// operand (a [Size]) multiplied by the scalar right-hand-side operand (a
|
||||
/// [double]).
|
||||
Size operator *(double operand) => new Size(width * operand, height * operand);
|
||||
Size operator *(double operand) => Size(width * operand, height * operand);
|
||||
|
||||
/// Division operator.
|
||||
///
|
||||
/// Returns a [Size] whose dimensions are the dimensions of the left-hand-side
|
||||
/// operand (a [Size]) divided by the scalar right-hand-side operand (a
|
||||
/// [double]).
|
||||
Size operator /(double operand) => new Size(width / operand, height / operand);
|
||||
Size operator /(double operand) => Size(width / operand, height / operand);
|
||||
|
||||
/// Integer (truncating) division operator.
|
||||
///
|
||||
/// Returns a [Size] whose dimensions are the dimensions of the left-hand-side
|
||||
/// operand (a [Size]) divided by the scalar right-hand-side operand (a
|
||||
/// [double]), rounded towards zero.
|
||||
Size operator ~/(double operand) => new Size((width ~/ operand).toDouble(), (height ~/ operand).toDouble());
|
||||
Size operator ~/(double operand) => Size((width ~/ operand).toDouble(), (height ~/ operand).toDouble());
|
||||
|
||||
/// Modulo (remainder) operator.
|
||||
///
|
||||
/// Returns a [Size] whose dimensions are the remainder of dividing the
|
||||
/// left-hand-side operand (a [Size]) by the scalar right-hand-side operand (a
|
||||
/// [double]).
|
||||
Size operator %(double operand) => new Size(width % operand, height % operand);
|
||||
Size operator %(double operand) => Size(width % operand, height % operand);
|
||||
|
||||
/// The lesser of the magnitudes of the [width] and the [height].
|
||||
double get shortestSide => math.min(width.abs(), height.abs());
|
||||
@@ -503,54 +503,54 @@ class Size extends OffsetBase {
|
||||
/// given offset (which is interpreted as the top-left corner) and this size.
|
||||
///
|
||||
/// See also [Rect.topCenter].
|
||||
Offset topCenter(Offset origin) => new Offset(origin.dx + width / 2.0, origin.dy);
|
||||
Offset topCenter(Offset origin) => Offset(origin.dx + width / 2.0, origin.dy);
|
||||
|
||||
/// The offset to the intersection of the top and right edges of the rectangle
|
||||
/// described by the given offset (which is interpreted as the top-left corner)
|
||||
/// and this size.
|
||||
///
|
||||
/// See also [Rect.topRight].
|
||||
Offset topRight(Offset origin) => new Offset(origin.dx + width, origin.dy);
|
||||
Offset topRight(Offset origin) => Offset(origin.dx + width, origin.dy);
|
||||
|
||||
/// The offset to the center of the left edge of the rectangle described by the
|
||||
/// given offset (which is interpreted as the top-left corner) and this size.
|
||||
///
|
||||
/// See also [Rect.centerLeft].
|
||||
Offset centerLeft(Offset origin) => new Offset(origin.dx, origin.dy + height / 2.0);
|
||||
Offset centerLeft(Offset origin) => Offset(origin.dx, origin.dy + height / 2.0);
|
||||
|
||||
/// The offset to the point halfway between the left and right and the top and
|
||||
/// bottom edges of the rectangle described by the given offset (which is
|
||||
/// interpreted as the top-left corner) and this size.
|
||||
///
|
||||
/// See also [Rect.center].
|
||||
Offset center(Offset origin) => new Offset(origin.dx + width / 2.0, origin.dy + height / 2.0);
|
||||
Offset center(Offset origin) => Offset(origin.dx + width / 2.0, origin.dy + height / 2.0);
|
||||
|
||||
/// The offset to the center of the right edge of the rectangle described by the
|
||||
/// given offset (which is interpreted as the top-left corner) and this size.
|
||||
///
|
||||
/// See also [Rect.centerLeft].
|
||||
Offset centerRight(Offset origin) => new Offset(origin.dx + width, origin.dy + height / 2.0);
|
||||
Offset centerRight(Offset origin) => Offset(origin.dx + width, origin.dy + height / 2.0);
|
||||
|
||||
/// The offset to the intersection of the bottom and left edges of the
|
||||
/// rectangle described by the given offset (which is interpreted as the
|
||||
/// top-left corner) and this size.
|
||||
///
|
||||
/// See also [Rect.bottomLeft].
|
||||
Offset bottomLeft(Offset origin) => new Offset(origin.dx, origin.dy + height);
|
||||
Offset bottomLeft(Offset origin) => Offset(origin.dx, origin.dy + height);
|
||||
|
||||
/// The offset to the center of the bottom edge of the rectangle described by
|
||||
/// the given offset (which is interpreted as the top-left corner) and this
|
||||
/// size.
|
||||
///
|
||||
/// See also [Rect.bottomLeft].
|
||||
Offset bottomCenter(Offset origin) => new Offset(origin.dx + width / 2.0, origin.dy + height);
|
||||
Offset bottomCenter(Offset origin) => Offset(origin.dx + width / 2.0, origin.dy + height);
|
||||
|
||||
/// The offset to the intersection of the bottom and right edges of the
|
||||
/// rectangle described by the given offset (which is interpreted as the
|
||||
/// top-left corner) and this size.
|
||||
///
|
||||
/// See also [Rect.bottomRight].
|
||||
Offset bottomRight(Offset origin) => new Offset(origin.dx + width, origin.dy + height);
|
||||
Offset bottomRight(Offset origin) => Offset(origin.dx + width, origin.dy + height);
|
||||
|
||||
/// Whether the point specified by the given offset (which is assumed to be
|
||||
/// relative to the top left of the size) lies between the left and right and
|
||||
@@ -563,7 +563,7 @@ class Size extends OffsetBase {
|
||||
}
|
||||
|
||||
/// A [Size] with the [width] and [height] swapped.
|
||||
Size get flipped => new Size(height, width);
|
||||
Size get flipped => Size(height, width);
|
||||
|
||||
/// Linearly interpolate between two sizes
|
||||
///
|
||||
@@ -588,7 +588,7 @@ class Size extends OffsetBase {
|
||||
return b * t;
|
||||
if (b == null)
|
||||
return a * (1.0 - t);
|
||||
return new Size(lerpDouble(a.width, b.width, t), lerpDouble(a.height, b.height, t));
|
||||
return Size(lerpDouble(a.width, b.width, t), lerpDouble(a.height, b.height, t));
|
||||
}
|
||||
|
||||
/// Compares two Sizes for equality.
|
||||
@@ -684,7 +684,7 @@ class Rect {
|
||||
|
||||
/// The distance between the upper-left corner and the lower-right corner of
|
||||
/// this rectangle.
|
||||
Size get size => new Size(width, height);
|
||||
Size get size => Size(width, height);
|
||||
|
||||
/// Whether any of the dimensions are `NaN`.
|
||||
bool get hasNaN => left.isNaN || top.isNaN || right.isNaN || bottom.isNaN;
|
||||
@@ -721,7 +721,7 @@ class Rect {
|
||||
/// To translate a rectangle by separate x and y components rather than by an
|
||||
/// [Offset], consider [translate].
|
||||
Rect shift(Offset offset) {
|
||||
return new Rect.fromLTRB(left + offset.dx, top + offset.dy, right + offset.dx, bottom + offset.dy);
|
||||
return Rect.fromLTRB(left + offset.dx, top + offset.dy, right + offset.dx, bottom + offset.dy);
|
||||
}
|
||||
|
||||
/// Returns a new rectangle with translateX added to the x components and
|
||||
@@ -730,12 +730,12 @@ class Rect {
|
||||
/// To translate a rectangle by an [Offset] rather than by separate x and y
|
||||
/// components, consider [shift].
|
||||
Rect translate(double translateX, double translateY) {
|
||||
return new Rect.fromLTRB(left + translateX, top + translateY, right + translateX, bottom + translateY);
|
||||
return Rect.fromLTRB(left + translateX, top + translateY, right + translateX, bottom + translateY);
|
||||
}
|
||||
|
||||
/// Returns a new rectangle with edges moved outwards by the given delta.
|
||||
Rect inflate(double delta) {
|
||||
return new Rect.fromLTRB(left - delta, top - delta, right + delta, bottom + delta);
|
||||
return Rect.fromLTRB(left - delta, top - delta, right + delta, bottom + delta);
|
||||
}
|
||||
|
||||
/// Returns a new rectangle with edges moved inwards by the given delta.
|
||||
@@ -746,7 +746,7 @@ class Rect {
|
||||
/// for this to be meaningful. If the two rectangles do not overlap,
|
||||
/// then the resulting Rect will have a negative width or height.
|
||||
Rect intersect(Rect other) {
|
||||
return new Rect.fromLTRB(
|
||||
return Rect.fromLTRB(
|
||||
math.max(left, other.left),
|
||||
math.max(top, other.top),
|
||||
math.min(right, other.right),
|
||||
@@ -757,7 +757,7 @@ class Rect {
|
||||
/// Returns a new rectangle which is the bounding box containing this
|
||||
/// rectangle and the given rectangle.
|
||||
Rect expandToInclude(Rect other) {
|
||||
return new Rect.fromLTRB(
|
||||
return Rect.fromLTRB(
|
||||
math.min(left, other.left),
|
||||
math.min(top, other.top),
|
||||
math.max(right, other.right),
|
||||
@@ -785,48 +785,48 @@ class Rect {
|
||||
/// The offset to the intersection of the top and left edges of this rectangle.
|
||||
///
|
||||
/// See also [Size.topLeft].
|
||||
Offset get topLeft => new Offset(left, top);
|
||||
Offset get topLeft => Offset(left, top);
|
||||
|
||||
/// The offset to the center of the top edge of this rectangle.
|
||||
///
|
||||
/// See also [Size.topCenter].
|
||||
Offset get topCenter => new Offset(left + width / 2.0, top);
|
||||
Offset get topCenter => Offset(left + width / 2.0, top);
|
||||
|
||||
/// The offset to the intersection of the top and right edges of this rectangle.
|
||||
///
|
||||
/// See also [Size.topRight].
|
||||
Offset get topRight => new Offset(right, top);
|
||||
Offset get topRight => Offset(right, top);
|
||||
|
||||
/// The offset to the center of the left edge of this rectangle.
|
||||
///
|
||||
/// See also [Size.centerLeft].
|
||||
Offset get centerLeft => new Offset(left, top + height / 2.0);
|
||||
Offset get centerLeft => Offset(left, top + height / 2.0);
|
||||
|
||||
/// The offset to the point halfway between the left and right and the top and
|
||||
/// bottom edges of this rectangle.
|
||||
///
|
||||
/// See also [Size.center].
|
||||
Offset get center => new Offset(left + width / 2.0, top + height / 2.0);
|
||||
Offset get center => Offset(left + width / 2.0, top + height / 2.0);
|
||||
|
||||
/// The offset to the center of the right edge of this rectangle.
|
||||
///
|
||||
/// See also [Size.centerLeft].
|
||||
Offset get centerRight => new Offset(right, top + height / 2.0);
|
||||
Offset get centerRight => Offset(right, top + height / 2.0);
|
||||
|
||||
/// The offset to the intersection of the bottom and left edges of this rectangle.
|
||||
///
|
||||
/// See also [Size.bottomLeft].
|
||||
Offset get bottomLeft => new Offset(left, bottom);
|
||||
Offset get bottomLeft => Offset(left, bottom);
|
||||
|
||||
/// The offset to the center of the bottom edge of this rectangle.
|
||||
///
|
||||
/// See also [Size.bottomLeft].
|
||||
Offset get bottomCenter => new Offset(left + width / 2.0, bottom);
|
||||
Offset get bottomCenter => Offset(left + width / 2.0, bottom);
|
||||
|
||||
/// The offset to the intersection of the bottom and right edges of this rectangle.
|
||||
///
|
||||
/// See also [Size.bottomRight].
|
||||
Offset get bottomRight => new Offset(right, bottom);
|
||||
Offset get bottomRight => Offset(right, bottom);
|
||||
|
||||
/// Whether the point specified by the given offset (which is assumed to be
|
||||
/// relative to the origin) lies between the left and right and the top and
|
||||
@@ -858,12 +858,12 @@ class Rect {
|
||||
if (a == null && b == null)
|
||||
return null;
|
||||
if (a == null)
|
||||
return new Rect.fromLTRB(b.left * t, b.top * t, b.right * t, b.bottom * t);
|
||||
return Rect.fromLTRB(b.left * t, b.top * t, b.right * t, b.bottom * t);
|
||||
if (b == null) {
|
||||
final double k = 1.0 - t;
|
||||
return new Rect.fromLTRB(a.left * k, a.top * k, a.right * k, a.bottom * k);
|
||||
return Rect.fromLTRB(a.left * k, a.top * k, a.right * k, a.bottom * k);
|
||||
}
|
||||
return new Rect.fromLTRB(
|
||||
return Rect.fromLTRB(
|
||||
lerpDouble(a.left, b.left, t),
|
||||
lerpDouble(a.top, b.top, t),
|
||||
lerpDouble(a.right, b.right, t),
|
||||
@@ -908,7 +908,7 @@ class Radius {
|
||||
/// A radius with [x] and [y] values set to zero.
|
||||
///
|
||||
/// You can use [Radius.zero] with [RRect] to have right-angle corners.
|
||||
static const Radius zero = const Radius.circular(0.0);
|
||||
static const Radius zero = Radius.circular(0.0);
|
||||
|
||||
/// Unary negation operator.
|
||||
///
|
||||
@@ -918,49 +918,49 @@ class Radius {
|
||||
/// occur as part of expressions. For example, negating a radius of one pixel
|
||||
/// and then adding the result to another radius is equivalent to subtracting
|
||||
/// a radius of one pixel from the other.
|
||||
Radius operator -() => new Radius.elliptical(-x, -y);
|
||||
Radius operator -() => Radius.elliptical(-x, -y);
|
||||
|
||||
/// Binary subtraction operator.
|
||||
///
|
||||
/// Returns a radius whose [x] value is the left-hand-side operand's [x]
|
||||
/// minus the right-hand-side operand's [x] and whose [y] value is the
|
||||
/// left-hand-side operand's [y] minus the right-hand-side operand's [y].
|
||||
Radius operator -(Radius other) => new Radius.elliptical(x - other.x, y - other.y);
|
||||
Radius operator -(Radius other) => Radius.elliptical(x - other.x, y - other.y);
|
||||
|
||||
/// Binary addition operator.
|
||||
///
|
||||
/// Returns a radius whose [x] value is the sum of the [x] values of the
|
||||
/// two operands, and whose [y] value is the sum of the [y] values of the
|
||||
/// two operands.
|
||||
Radius operator +(Radius other) => new Radius.elliptical(x + other.x, y + other.y);
|
||||
Radius operator +(Radius other) => Radius.elliptical(x + other.x, y + other.y);
|
||||
|
||||
/// Multiplication operator.
|
||||
///
|
||||
/// Returns a radius whose coordinates are the coordinates of the
|
||||
/// left-hand-side operand (a radius) multiplied by the scalar
|
||||
/// right-hand-side operand (a double).
|
||||
Radius operator *(double operand) => new Radius.elliptical(x * operand, y * operand);
|
||||
Radius operator *(double operand) => Radius.elliptical(x * operand, y * operand);
|
||||
|
||||
/// Division operator.
|
||||
///
|
||||
/// Returns a radius whose coordinates are the coordinates of the
|
||||
/// left-hand-side operand (a radius) divided by the scalar right-hand-side
|
||||
/// operand (a double).
|
||||
Radius operator /(double operand) => new Radius.elliptical(x / operand, y / operand);
|
||||
Radius operator /(double operand) => Radius.elliptical(x / operand, y / operand);
|
||||
|
||||
/// Integer (truncating) division operator.
|
||||
///
|
||||
/// Returns a radius whose coordinates are the coordinates of the
|
||||
/// left-hand-side operand (a radius) divided by the scalar right-hand-side
|
||||
/// operand (a double), rounded towards zero.
|
||||
Radius operator ~/(double operand) => new Radius.elliptical((x ~/ operand).toDouble(), (y ~/ operand).toDouble());
|
||||
Radius operator ~/(double operand) => Radius.elliptical((x ~/ operand).toDouble(), (y ~/ operand).toDouble());
|
||||
|
||||
/// Modulo (remainder) operator.
|
||||
///
|
||||
/// Returns a radius whose coordinates are the remainder of dividing the
|
||||
/// coordinates of the left-hand-side operand (a radius) by the scalar
|
||||
/// right-hand-side operand (a double).
|
||||
Radius operator %(double operand) => new Radius.elliptical(x % operand, y % operand);
|
||||
Radius operator %(double operand) => Radius.elliptical(x % operand, y % operand);
|
||||
|
||||
/// Linearly interpolate between two radii.
|
||||
///
|
||||
@@ -982,12 +982,12 @@ class Radius {
|
||||
if (a == null && b == null)
|
||||
return null;
|
||||
if (a == null)
|
||||
return new Radius.elliptical(b.x * t, b.y * t);
|
||||
return Radius.elliptical(b.x * t, b.y * t);
|
||||
if (b == null) {
|
||||
final double k = 1.0 - t;
|
||||
return new Radius.elliptical(a.x * k, a.y * k);
|
||||
return Radius.elliptical(a.x * k, a.y * k);
|
||||
}
|
||||
return new Radius.elliptical(
|
||||
return Radius.elliptical(
|
||||
lerpDouble(a.x, b.x, t),
|
||||
lerpDouble(a.y, b.y, t),
|
||||
);
|
||||
@@ -1098,10 +1098,10 @@ class RRect {
|
||||
double top,
|
||||
double right,
|
||||
double bottom, {
|
||||
Radius topLeft: Radius.zero,
|
||||
Radius topRight: Radius.zero,
|
||||
Radius bottomRight: Radius.zero,
|
||||
Radius bottomLeft: Radius.zero,
|
||||
Radius topLeft = Radius.zero,
|
||||
Radius topRight = Radius.zero,
|
||||
Radius bottomRight = Radius.zero,
|
||||
Radius bottomLeft = Radius.zero,
|
||||
}) : this._raw(
|
||||
top: top,
|
||||
left: left,
|
||||
@@ -1124,10 +1124,10 @@ class RRect {
|
||||
RRect.fromRectAndCorners(
|
||||
Rect rect,
|
||||
{
|
||||
Radius topLeft: Radius.zero,
|
||||
Radius topRight: Radius.zero,
|
||||
Radius bottomRight: Radius.zero,
|
||||
Radius bottomLeft: Radius.zero
|
||||
Radius topLeft = Radius.zero,
|
||||
Radius topRight = Radius.zero,
|
||||
Radius bottomRight = Radius.zero,
|
||||
Radius bottomLeft = Radius.zero
|
||||
}
|
||||
) : this._raw(
|
||||
top: rect.top,
|
||||
@@ -1204,7 +1204,7 @@ class RRect {
|
||||
final double tlRadiusY;
|
||||
|
||||
/// The top-left [Radius].
|
||||
Radius get tlRadius => new Radius.elliptical(tlRadiusX, tlRadiusY);
|
||||
Radius get tlRadius => Radius.elliptical(tlRadiusX, tlRadiusY);
|
||||
|
||||
/// The top-right horizontal radius.
|
||||
final double trRadiusX;
|
||||
@@ -1213,7 +1213,7 @@ class RRect {
|
||||
final double trRadiusY;
|
||||
|
||||
/// The top-right [Radius].
|
||||
Radius get trRadius => new Radius.elliptical(trRadiusX, trRadiusY);
|
||||
Radius get trRadius => Radius.elliptical(trRadiusX, trRadiusY);
|
||||
|
||||
/// The bottom-right horizontal radius.
|
||||
final double brRadiusX;
|
||||
@@ -1222,7 +1222,7 @@ class RRect {
|
||||
final double brRadiusY;
|
||||
|
||||
/// The bottom-right [Radius].
|
||||
Radius get brRadius => new Radius.elliptical(brRadiusX, brRadiusY);
|
||||
Radius get brRadius => Radius.elliptical(brRadiusX, brRadiusY);
|
||||
|
||||
/// The bottom-left horizontal radius.
|
||||
final double blRadiusX;
|
||||
@@ -1231,14 +1231,14 @@ class RRect {
|
||||
final double blRadiusY;
|
||||
|
||||
/// The bottom-left [Radius].
|
||||
Radius get blRadius => new Radius.elliptical(blRadiusX, blRadiusY);
|
||||
Radius get blRadius => Radius.elliptical(blRadiusX, blRadiusY);
|
||||
|
||||
/// A rounded rectangle with all the values set to zero.
|
||||
static const RRect zero = RRect._raw();
|
||||
|
||||
/// Returns a new [RRect] translated by the given offset.
|
||||
RRect shift(Offset offset) {
|
||||
return new RRect._raw(
|
||||
return RRect._raw(
|
||||
left: left + offset.dx,
|
||||
top: top + offset.dy,
|
||||
right: right + offset.dx,
|
||||
@@ -1257,7 +1257,7 @@ class RRect {
|
||||
/// Returns a new [RRect] with edges and radii moved outwards by the given
|
||||
/// delta.
|
||||
RRect inflate(double delta) {
|
||||
return new RRect._raw(
|
||||
return RRect._raw(
|
||||
left: left - delta,
|
||||
top: top - delta,
|
||||
right: right + delta,
|
||||
@@ -1283,7 +1283,7 @@ class RRect {
|
||||
double get height => bottom - top;
|
||||
|
||||
/// The bounding box of this rounded rectangle (the rectangle with no rounded corners).
|
||||
Rect get outerRect => new Rect.fromLTRB(left, top, right, bottom);
|
||||
Rect get outerRect => Rect.fromLTRB(left, top, right, bottom);
|
||||
|
||||
/// The non-rounded rectangle that is constrained by the smaller of the two
|
||||
/// diagonals, with each diagonal traveling through the middle of the curve
|
||||
@@ -1297,7 +1297,7 @@ class RRect {
|
||||
final double rightRadius = math.max(trRadiusX, brRadiusX);
|
||||
final double bottomRadius = math.max(brRadiusY, blRadiusY);
|
||||
|
||||
return new Rect.fromLTRB(
|
||||
return Rect.fromLTRB(
|
||||
left + leftRadius * kInsetFactor,
|
||||
top + topRadius * kInsetFactor,
|
||||
right - rightRadius * kInsetFactor,
|
||||
@@ -1316,7 +1316,7 @@ class RRect {
|
||||
final double topRadius = math.max(tlRadiusY, trRadiusY);
|
||||
final double rightRadius = math.max(trRadiusX, brRadiusX);
|
||||
final double bottomRadius = math.max(brRadiusY, blRadiusY);
|
||||
return new Rect.fromLTRB(
|
||||
return Rect.fromLTRB(
|
||||
left + leftRadius,
|
||||
top + topRadius,
|
||||
right - rightRadius,
|
||||
@@ -1331,7 +1331,7 @@ class RRect {
|
||||
Rect get wideMiddleRect {
|
||||
final double topRadius = math.max(tlRadiusY, trRadiusY);
|
||||
final double bottomRadius = math.max(brRadiusY, blRadiusY);
|
||||
return new Rect.fromLTRB(
|
||||
return Rect.fromLTRB(
|
||||
left,
|
||||
top + topRadius,
|
||||
right,
|
||||
@@ -1346,7 +1346,7 @@ class RRect {
|
||||
Rect get tallMiddleRect {
|
||||
final double leftRadius = math.max(blRadiusX, tlRadiusX);
|
||||
final double rightRadius = math.max(trRadiusX, brRadiusX);
|
||||
return new Rect.fromLTRB(
|
||||
return Rect.fromLTRB(
|
||||
left + leftRadius,
|
||||
top,
|
||||
right - rightRadius,
|
||||
@@ -1405,7 +1405,7 @@ class RRect {
|
||||
|
||||
/// The offset to the point halfway between the left and right and the top and
|
||||
/// bottom edges of this rectangle.
|
||||
Offset get center => new Offset(left + width / 2.0, top + height / 2.0);
|
||||
Offset get center => Offset(left + width / 2.0, top + height / 2.0);
|
||||
|
||||
// Returns the minimum between min and scale to which radius1 and radius2
|
||||
// should be scaled with in order not to exceed the limit.
|
||||
@@ -1429,7 +1429,7 @@ class RRect {
|
||||
scale = _getMin(scale, brRadiusX, blRadiusX, width);
|
||||
|
||||
if (scale < 1.0) {
|
||||
return new RRect._raw(
|
||||
return RRect._raw(
|
||||
top: top,
|
||||
left: left,
|
||||
right: right,
|
||||
@@ -1445,7 +1445,7 @@ class RRect {
|
||||
);
|
||||
}
|
||||
|
||||
return new RRect._raw(
|
||||
return RRect._raw(
|
||||
top: top,
|
||||
left: left,
|
||||
right: right,
|
||||
@@ -1536,7 +1536,7 @@ class RRect {
|
||||
if (a == null && b == null)
|
||||
return null;
|
||||
if (a == null) {
|
||||
return new RRect._raw(
|
||||
return RRect._raw(
|
||||
left: b.left * t,
|
||||
top: b.top * t,
|
||||
right: b.right * t,
|
||||
@@ -1553,7 +1553,7 @@ class RRect {
|
||||
}
|
||||
if (b == null) {
|
||||
final double k = 1.0 - t;
|
||||
return new RRect._raw(
|
||||
return RRect._raw(
|
||||
left: a.left * k,
|
||||
top: a.top * k,
|
||||
right: a.right * k,
|
||||
@@ -1568,7 +1568,7 @@ class RRect {
|
||||
blRadiusY: a.blRadiusY * k,
|
||||
);
|
||||
}
|
||||
return new RRect._raw(
|
||||
return RRect._raw(
|
||||
left: lerpDouble(a.left, b.left, t),
|
||||
top: lerpDouble(a.top, b.top, t),
|
||||
right: lerpDouble(a.right, b.right, t),
|
||||
@@ -1702,10 +1702,10 @@ class RSTransform {
|
||||
final double ssin = math.sin(rotation) * scale;
|
||||
final double tx = translateX + -scos * anchorX + ssin * anchorY;
|
||||
final double ty = translateY + -ssin * anchorX - scos * anchorY;
|
||||
return new RSTransform(scos, ssin, tx, ty);
|
||||
return RSTransform(scos, ssin, tx, ty);
|
||||
}
|
||||
|
||||
final Float32List _value = new Float32List(4);
|
||||
final Float32List _value = Float32List(4);
|
||||
|
||||
/// The cosine of the rotation multiplied by the scale factor.
|
||||
double get scos => _value[0];
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
part of dart.ui;
|
||||
|
||||
class _HashEnd { const _HashEnd(); }
|
||||
const _HashEnd _hashEnd = const _HashEnd();
|
||||
const _HashEnd _hashEnd = _HashEnd();
|
||||
|
||||
/// Jenkins hash function, optimized for small integers.
|
||||
//
|
||||
|
||||
@@ -31,13 +31,13 @@ void _updateWindowMetrics(double devicePixelRatio,
|
||||
double viewInsetLeft) {
|
||||
window
|
||||
.._devicePixelRatio = devicePixelRatio
|
||||
.._physicalSize = new Size(width, height)
|
||||
.._padding = new WindowPadding._(
|
||||
.._physicalSize = Size(width, height)
|
||||
.._padding = WindowPadding._(
|
||||
top: paddingTop,
|
||||
right: paddingRight,
|
||||
bottom: paddingBottom,
|
||||
left: paddingLeft)
|
||||
.._viewInsets = new WindowPadding._(
|
||||
.._viewInsets = WindowPadding._(
|
||||
top: viewInsetTop,
|
||||
right: viewInsetRight,
|
||||
bottom: viewInsetBottom,
|
||||
@@ -63,12 +63,12 @@ _LocaleClosure _getLocaleClosure() => _localeClosure;
|
||||
void _updateLocales(List<String> locales) {
|
||||
const int stringsPerLocale = 4;
|
||||
final int numLocales = locales.length ~/ stringsPerLocale;
|
||||
window._locales = new List<Locale>(numLocales);
|
||||
window._locales = List<Locale>(numLocales);
|
||||
for (int localeIndex = 0; localeIndex < numLocales; localeIndex++) {
|
||||
final String countryCode = locales[localeIndex * stringsPerLocale + 1];
|
||||
final String scriptCode = locales[localeIndex * stringsPerLocale + 2];
|
||||
|
||||
window._locales[localeIndex] = new Locale.fromSubtags(
|
||||
window._locales[localeIndex] = Locale.fromSubtags(
|
||||
languageCode: locales[localeIndex * stringsPerLocale],
|
||||
countryCode: countryCode.isEmpty ? null : countryCode,
|
||||
scriptCode: scriptCode.isEmpty ? null : scriptCode,
|
||||
@@ -123,7 +123,7 @@ void _updateSemanticsEnabled(bool enabled) {
|
||||
@pragma('vm:entry-point')
|
||||
// ignore: unused_element
|
||||
void _updateAccessibilityFeatures(int values) {
|
||||
final AccessibilityFeatures newFeatures = new AccessibilityFeatures._(values);
|
||||
final AccessibilityFeatures newFeatures = AccessibilityFeatures._(values);
|
||||
if (newFeatures == window._accessibilityFeatures)
|
||||
return;
|
||||
window._accessibilityFeatures = newFeatures;
|
||||
@@ -169,7 +169,7 @@ void _dispatchSemanticsAction(int id, int action, ByteData args) {
|
||||
@pragma('vm:entry-point')
|
||||
// ignore: unused_element
|
||||
void _beginFrame(int microseconds) {
|
||||
_invoke1<Duration>(window.onBeginFrame, window._onBeginFrameZone, new Duration(microseconds: microseconds));
|
||||
_invoke1<Duration>(window.onBeginFrame, window._onBeginFrameZone, Duration(microseconds: microseconds));
|
||||
}
|
||||
|
||||
@pragma('vm:entry-point')
|
||||
@@ -277,11 +277,11 @@ PointerDataPacket _unpackPointerDataPacket(ByteData packet) {
|
||||
const int kBytesPerPointerData = _kPointerDataFieldCount * kStride;
|
||||
final int length = packet.lengthInBytes ~/ kBytesPerPointerData;
|
||||
assert(length * kBytesPerPointerData == packet.lengthInBytes);
|
||||
final List<PointerData> data = new List<PointerData>(length);
|
||||
final List<PointerData> data = List<PointerData>(length);
|
||||
for (int i = 0; i < length; ++i) {
|
||||
int offset = i * _kPointerDataFieldCount;
|
||||
data[i] = new PointerData(
|
||||
timeStamp: new Duration(microseconds: packet.getInt64(kStride * offset++, _kFakeHostEndian)),
|
||||
data[i] = PointerData(
|
||||
timeStamp: Duration(microseconds: packet.getInt64(kStride * offset++, _kFakeHostEndian)),
|
||||
change: PointerChange.values[packet.getInt64(kStride * offset++, _kFakeHostEndian)],
|
||||
kind: PointerDeviceKind.values[packet.getInt64(kStride * offset++, _kFakeHostEndian)],
|
||||
signalKind: PointerSignalKind.values[packet.getInt64(kStride * offset++, _kFakeHostEndian)],
|
||||
@@ -308,5 +308,5 @@ PointerDataPacket _unpackPointerDataPacket(ByteData packet) {
|
||||
);
|
||||
assert(offset == (i + 1) * _kPointerDataFieldCount);
|
||||
}
|
||||
return new PointerDataPacket(data: data);
|
||||
return PointerDataPacket(data: data);
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ Future<developer.ServiceExtensionResponse> _scheduleFrame(
|
||||
// Schedule the frame.
|
||||
window.scheduleFrame();
|
||||
// Always succeed.
|
||||
return new developer.ServiceExtensionResponse.result(json.encode(<String, String>{
|
||||
return developer.ServiceExtensionResponse.result(json.encode(<String, String>{
|
||||
'type': 'Success',
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -177,7 +177,7 @@ class Color {
|
||||
///
|
||||
/// Out of range values will have unexpected effects.
|
||||
Color withAlpha(int a) {
|
||||
return new Color.fromARGB(a, red, green, blue);
|
||||
return Color.fromARGB(a, red, green, blue);
|
||||
}
|
||||
|
||||
/// Returns a new color that matches this color with the alpha channel
|
||||
@@ -194,7 +194,7 @@ class Color {
|
||||
///
|
||||
/// Out of range values will have unexpected effects.
|
||||
Color withRed(int r) {
|
||||
return new Color.fromARGB(alpha, r, green, blue);
|
||||
return Color.fromARGB(alpha, r, green, blue);
|
||||
}
|
||||
|
||||
/// Returns a new color that matches this color with the green channel
|
||||
@@ -202,7 +202,7 @@ class Color {
|
||||
///
|
||||
/// Out of range values will have unexpected effects.
|
||||
Color withGreen(int g) {
|
||||
return new Color.fromARGB(alpha, red, g, blue);
|
||||
return Color.fromARGB(alpha, red, g, blue);
|
||||
}
|
||||
|
||||
/// Returns a new color that matches this color with the blue channel replaced
|
||||
@@ -210,7 +210,7 @@ class Color {
|
||||
///
|
||||
/// Out of range values will have unexpected effects.
|
||||
Color withBlue(int b) {
|
||||
return new Color.fromARGB(alpha, red, green, b);
|
||||
return Color.fromARGB(alpha, red, green, b);
|
||||
}
|
||||
|
||||
// See <https://www.w3.org/TR/WCAG20/#relativeluminancedef>
|
||||
@@ -264,7 +264,7 @@ class Color {
|
||||
return _scaleAlpha(b, t);
|
||||
if (b == null)
|
||||
return _scaleAlpha(a, 1.0 - t);
|
||||
return new Color.fromARGB(
|
||||
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),
|
||||
@@ -288,7 +288,7 @@ class Color {
|
||||
final int invAlpha = 0xff - alpha;
|
||||
int backAlpha = background.alpha;
|
||||
if (backAlpha == 0xff) { // Opaque background case
|
||||
return new Color.fromARGB(
|
||||
return Color.fromARGB(
|
||||
0xff,
|
||||
(alpha * foreground.red + invAlpha * background.red) ~/ 0xff,
|
||||
(alpha * foreground.green + invAlpha * background.green) ~/ 0xff,
|
||||
@@ -298,7 +298,7 @@ class Color {
|
||||
backAlpha = (backAlpha * invAlpha) ~/ 0xff;
|
||||
final int outAlpha = alpha + backAlpha;
|
||||
assert(outAlpha != 0x00);
|
||||
return new Color.fromARGB(
|
||||
return Color.fromARGB(
|
||||
outAlpha,
|
||||
(foreground.red * alpha + background.red * backAlpha) ~/ outAlpha,
|
||||
(foreground.green * alpha + background.green * backAlpha) ~/ outAlpha,
|
||||
@@ -1043,7 +1043,7 @@ class Paint {
|
||||
//
|
||||
// The binary format must match the deserialization code in paint.cc.
|
||||
|
||||
final ByteData _data = new ByteData(_kDataByteCount);
|
||||
final ByteData _data = ByteData(_kDataByteCount);
|
||||
static const int _kIsAntiAliasIndex = 0;
|
||||
static const int _kColorIndex = 1;
|
||||
static const int _kBlendModeIndex = 2;
|
||||
@@ -1117,7 +1117,7 @@ class Paint {
|
||||
/// [colorFilter].
|
||||
Color get color {
|
||||
final int encoded = _data.getInt32(_kColorOffset, _kFakeHostEndian);
|
||||
return new Color(encoded ^ _kColorDefault);
|
||||
return Color(encoded ^ _kColorDefault);
|
||||
}
|
||||
set color(Color value) {
|
||||
assert(value != null);
|
||||
@@ -1275,7 +1275,7 @@ class Paint {
|
||||
case MaskFilter._TypeNone:
|
||||
return null;
|
||||
case MaskFilter._TypeBlur:
|
||||
return new MaskFilter.blur(
|
||||
return MaskFilter.blur(
|
||||
BlurStyle.values[_data.getInt32(_kMaskFilterBlurStyleOffset, _kFakeHostEndian)],
|
||||
_data.getFloat32(_kMaskFilterSigmaOffset, _kFakeHostEndian),
|
||||
);
|
||||
@@ -1327,7 +1327,7 @@ class Paint {
|
||||
return _objects[_kShaderIndex];
|
||||
}
|
||||
set shader(Shader value) {
|
||||
_objects ??= new List<dynamic>(_kObjectCount);
|
||||
_objects ??= List<dynamic>(_kObjectCount);
|
||||
_objects[_kShaderIndex] = value;
|
||||
}
|
||||
|
||||
@@ -1342,12 +1342,12 @@ class Paint {
|
||||
case ColorFilter._TypeNone:
|
||||
return null;
|
||||
case ColorFilter._TypeMode:
|
||||
return new ColorFilter.mode(
|
||||
new Color(_data.getInt32(_kColorFilterColorOffset, _kFakeHostEndian)),
|
||||
return ColorFilter.mode(
|
||||
Color(_data.getInt32(_kColorFilterColorOffset, _kFakeHostEndian)),
|
||||
BlendMode.values[_data.getInt32(_kColorFilterBlendModeOffset, _kFakeHostEndian)],
|
||||
);
|
||||
case ColorFilter._TypeMatrix:
|
||||
return new ColorFilter.matrix(_objects[_kColorFilterMatrixIndex]);
|
||||
return ColorFilter.matrix(_objects[_kColorFilterMatrixIndex]);
|
||||
case ColorFilter._TypeLinearToSrgbGamma:
|
||||
return const ColorFilter.linearToSrgbGamma();
|
||||
case ColorFilter._TypeSrgbToLinearGamma:
|
||||
@@ -1378,7 +1378,7 @@ class Paint {
|
||||
} else if (value._type == ColorFilter._TypeMatrix) {
|
||||
assert(value._matrix != null);
|
||||
|
||||
_objects ??= new List<dynamic>(_kObjectCount);
|
||||
_objects ??= List<dynamic>(_kObjectCount);
|
||||
_objects[_kColorFilterMatrixIndex] = Float32List.fromList(value._matrix);
|
||||
}
|
||||
}
|
||||
@@ -1386,7 +1386,7 @@ class Paint {
|
||||
|
||||
/// Whether the colors of the image are inverted when drawn.
|
||||
///
|
||||
/// inverting the colors of an image applies a new color filter that will
|
||||
/// 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 {
|
||||
@@ -1398,7 +1398,7 @@ class Paint {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
final StringBuffer result = new StringBuffer();
|
||||
final StringBuffer result = StringBuffer();
|
||||
String semicolon = '';
|
||||
result.write('Paint(');
|
||||
if (style == PaintingStyle.stroke) {
|
||||
@@ -1548,7 +1548,7 @@ class Image extends NativeFieldWrapperClass2 {
|
||||
///
|
||||
/// Returns a future that completes with the binary image data or an error
|
||||
/// if encoding fails.
|
||||
Future<ByteData> toByteData({ImageByteFormat format: ImageByteFormat.rawRgba}) {
|
||||
Future<ByteData> toByteData({ImageByteFormat format = ImageByteFormat.rawRgba}) {
|
||||
return _futurize((_Callback<ByteData> callback) {
|
||||
return _toByteData(format.index, (Uint8List encoded) {
|
||||
callback(encoded?.buffer?.asByteData());
|
||||
@@ -1585,7 +1585,7 @@ class FrameInfo extends NativeFieldWrapperClass2 {
|
||||
FrameInfo._();
|
||||
|
||||
/// The duration this frame should be shown.
|
||||
Duration get duration => new Duration(milliseconds: _durationMillis);
|
||||
Duration get duration => Duration(milliseconds: _durationMillis);
|
||||
int get _durationMillis native 'FrameInfo_durationMillis';
|
||||
|
||||
/// The [Image] object for this frame.
|
||||
@@ -1706,7 +1706,7 @@ void decodeImageFromPixels(
|
||||
ImageDecoderCallback callback,
|
||||
{int rowBytes, double decodedCacheRatioCap = 0}
|
||||
) {
|
||||
final _ImageInfo imageInfo = new _ImageInfo(width, height, format.index, rowBytes);
|
||||
final _ImageInfo imageInfo = _ImageInfo(width, height, format.index, rowBytes);
|
||||
final Future<Codec> codecFuture = _futurize(
|
||||
(_Callback<Codec> callback) => _instantiateImageCodec(pixels, callback, imageInfo, decodedCacheRatioCap)
|
||||
);
|
||||
@@ -1932,10 +1932,10 @@ class Path extends NativeFieldWrapperClass2 {
|
||||
/// point if both are greater than zero but too small to describe an arc.
|
||||
///
|
||||
void arcToPoint(Offset arcEnd, {
|
||||
Radius radius: Radius.zero,
|
||||
double rotation: 0.0,
|
||||
bool largeArc: false,
|
||||
bool clockwise: true,
|
||||
Radius radius = Radius.zero,
|
||||
double rotation = 0.0,
|
||||
bool largeArc = false,
|
||||
bool clockwise = true,
|
||||
}) {
|
||||
assert(_offsetIsValid(arcEnd));
|
||||
assert(_radiusIsValid(radius));
|
||||
@@ -1962,10 +1962,10 @@ class Path extends NativeFieldWrapperClass2 {
|
||||
/// 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,
|
||||
Radius radius = Radius.zero,
|
||||
double rotation = 0.0,
|
||||
bool largeArc = false,
|
||||
bool clockwise = true,
|
||||
}) {
|
||||
assert(_offsetIsValid(arcEndDelta));
|
||||
assert(_radiusIsValid(radius));
|
||||
@@ -2126,7 +2126,7 @@ class Path extends NativeFieldWrapperClass2 {
|
||||
// see https://skia.org/user/api/SkPath_Reference#SkPath_getBounds
|
||||
Rect getBounds() {
|
||||
final Float32List rect = _getBounds();
|
||||
return new Rect.fromLTRB(rect[0], rect[1], rect[2], rect[3]);
|
||||
return Rect.fromLTRB(rect[0], rect[1], rect[2], rect[3]);
|
||||
}
|
||||
Float32List _getBounds() native 'Path_getBounds';
|
||||
|
||||
@@ -2139,11 +2139,11 @@ class Path extends NativeFieldWrapperClass2 {
|
||||
static Path combine(PathOperation operation, Path path1, Path path2) {
|
||||
assert(path1 != null);
|
||||
assert(path2 != null);
|
||||
final Path path = new Path();
|
||||
final Path path = Path();
|
||||
if (path._op(path1, path2, operation.index)) {
|
||||
return path;
|
||||
}
|
||||
throw new StateError('Path.combine() failed. This may be due an invalid path; in particular, check for NaN values.');
|
||||
throw StateError('Path.combine() failed. This may be due an invalid path; in particular, check for NaN values.');
|
||||
}
|
||||
bool _op(Path path1, Path path2, int operation) native 'Path_op';
|
||||
|
||||
@@ -2151,8 +2151,8 @@ class Path extends NativeFieldWrapperClass2 {
|
||||
///
|
||||
/// 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}) {
|
||||
return new PathMetrics._(this, forceClosed);
|
||||
PathMetrics computeMetrics({bool forceClosed = false}) {
|
||||
return PathMetrics._(this, forceClosed);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2173,7 +2173,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) {
|
||||
return new Tangent(position, new Offset(math.cos(angle), math.sin(angle)));
|
||||
return Tangent(position, Offset(math.cos(angle), math.sin(angle)));
|
||||
}
|
||||
|
||||
/// Position of the tangent.
|
||||
@@ -2220,7 +2220,7 @@ class Tangent {
|
||||
/// valid until the next one is obtained.
|
||||
class PathMetrics extends collection.IterableBase<PathMetric> {
|
||||
PathMetrics._(Path path, bool forceClosed) :
|
||||
_iterator = new PathMetricIterator._(new _PathMeasure(path, forceClosed));
|
||||
_iterator = PathMetricIterator._(_PathMeasure(path, forceClosed));
|
||||
|
||||
final Iterator<PathMetric> _iterator;
|
||||
|
||||
@@ -2315,7 +2315,7 @@ class PathMetric {
|
||||
/// `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}) {
|
||||
return _measure.extractPath(contourIndex, start, end, startWithMoveTo: startWithMoveTo);
|
||||
}
|
||||
|
||||
@@ -2343,19 +2343,19 @@ class _PathMeasure extends NativeFieldWrapperClass2 {
|
||||
if (posTan[0] == 0.0) {
|
||||
return null;
|
||||
} else {
|
||||
return new Tangent(
|
||||
new Offset(posTan[1], posTan[2]),
|
||||
new Offset(posTan[3], posTan[4])
|
||||
return Tangent(
|
||||
Offset(posTan[1], posTan[2]),
|
||||
Offset(posTan[3], posTan[4])
|
||||
);
|
||||
}
|
||||
}
|
||||
Float32List _getPosTan(int contourIndex, double distance) native 'PathMeasure_getPosTan';
|
||||
|
||||
Path extractPath(int contourIndex, double start, double end, {bool startWithMoveTo: true}) {
|
||||
Path extractPath(int contourIndex, double start, double end, {bool startWithMoveTo = true}) {
|
||||
assert(contourIndex <= currentContourIndex, 'Iterator must be advanced before index $contourIndex can be used.');
|
||||
return _extractPath(contourIndex, start, end, startWithMoveTo: startWithMoveTo);
|
||||
}
|
||||
Path _extractPath(int contourIndex, double start, double end, {bool startWithMoveTo: true}) native 'PathMeasure_getSegment';
|
||||
Path _extractPath(int contourIndex, double start, double end, {bool startWithMoveTo = true}) native 'PathMeasure_getSegment';
|
||||
|
||||
bool isClosed(int contourIndex) {
|
||||
assert(contourIndex <= currentContourIndex, 'Iterator must be advanced before index $contourIndex can be used.');
|
||||
@@ -2565,7 +2565,7 @@ class ImageFilter extends NativeFieldWrapperClass2 {
|
||||
void _constructor() native 'ImageFilter_constructor';
|
||||
|
||||
/// Creates an image filter that applies a Gaussian blur.
|
||||
ImageFilter.blur({ double sigmaX: 0.0, double sigmaY: 0.0 }) {
|
||||
ImageFilter.blur({ double sigmaX = 0.0, double sigmaY = 0.0 }) {
|
||||
_constructor();
|
||||
_initBlur(sigmaX, sigmaY);
|
||||
}
|
||||
@@ -2576,9 +2576,9 @@ class ImageFilter extends NativeFieldWrapperClass2 {
|
||||
/// For example, applying a positive scale matrix (see [new Matrix4.diagonal3])
|
||||
/// when used with [BackdropFilter] would magnify the background image.
|
||||
ImageFilter.matrix(Float64List matrix4,
|
||||
{ FilterQuality filterQuality: FilterQuality.low }) {
|
||||
{ FilterQuality filterQuality = FilterQuality.low }) {
|
||||
if (matrix4.length != 16)
|
||||
throw new ArgumentError('"matrix4" must have 16 entries.');
|
||||
throw ArgumentError('"matrix4" must have 16 entries.');
|
||||
_constructor();
|
||||
_initMatrix(matrix4, filterQuality.index);
|
||||
}
|
||||
@@ -2647,7 +2647,7 @@ enum TileMode {
|
||||
|
||||
Int32List _encodeColorList(List<Color> colors) {
|
||||
final int colorCount = colors.length;
|
||||
final Int32List result = new Int32List(colorCount);
|
||||
final Int32List result = Int32List(colorCount);
|
||||
for (int i = 0; i < colorCount; ++i)
|
||||
result[i] = colors[i].value;
|
||||
return result;
|
||||
@@ -2656,7 +2656,7 @@ Int32List _encodeColorList(List<Color> colors) {
|
||||
Float32List _encodePointList(List<Offset> points) {
|
||||
assert(points != null);
|
||||
final int pointCount = points.length;
|
||||
final Float32List result = new Float32List(pointCount * 2);
|
||||
final Float32List result = Float32List(pointCount * 2);
|
||||
for (int i = 0; i < pointCount; ++i) {
|
||||
final int xIndex = i * 2;
|
||||
final int yIndex = xIndex + 1;
|
||||
@@ -2671,7 +2671,7 @@ Float32List _encodePointList(List<Offset> points) {
|
||||
Float32List _encodeTwoPoints(Offset pointA, Offset pointB) {
|
||||
assert(_offsetIsValid(pointA));
|
||||
assert(_offsetIsValid(pointB));
|
||||
final Float32List result = new Float32List(4);
|
||||
final Float32List result = Float32List(4);
|
||||
result[0] = pointA.dx;
|
||||
result[1] = pointA.dy;
|
||||
result[2] = pointB.dx;
|
||||
@@ -2723,7 +2723,7 @@ class Gradient extends Shader {
|
||||
_validateColorStops(colors, colorStops);
|
||||
final Float32List endPointsBuffer = _encodeTwoPoints(from, to);
|
||||
final Int32List colorsBuffer = _encodeColorList(colors);
|
||||
final Float32List colorStopsBuffer = colorStops == null ? null : new Float32List.fromList(colorStops);
|
||||
final Float32List colorStopsBuffer = colorStops == null ? null : Float32List.fromList(colorStops);
|
||||
_constructor();
|
||||
_initLinear(endPointsBuffer, colorsBuffer, colorStopsBuffer, tileMode.index);
|
||||
}
|
||||
@@ -2775,7 +2775,7 @@ class Gradient extends Shader {
|
||||
focalRadius ??= 0.0;
|
||||
_validateColorStops(colors, colorStops);
|
||||
final Int32List colorsBuffer = _encodeColorList(colors);
|
||||
final Float32List colorStopsBuffer = colorStops == null ? null : new Float32List.fromList(colorStops);
|
||||
final Float32List colorStopsBuffer = colorStops == null ? null : Float32List.fromList(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
|
||||
@@ -2835,7 +2835,7 @@ class Gradient extends Shader {
|
||||
super._() {
|
||||
_validateColorStops(colors, colorStops);
|
||||
final Int32List colorsBuffer = _encodeColorList(colors);
|
||||
final Float32List colorStopsBuffer = colorStops == null ? null : new Float32List.fromList(colorStops);
|
||||
final Float32List colorStopsBuffer = colorStops == null ? null : Float32List.fromList(colorStops);
|
||||
_constructor();
|
||||
_initSweep(center.dx, center.dy, colorsBuffer, colorStopsBuffer, tileMode.index, startAngle, endAngle, matrix4);
|
||||
}
|
||||
@@ -2844,10 +2844,10 @@ class Gradient extends Shader {
|
||||
static void _validateColorStops(List<Color> colors, List<double> colorStops) {
|
||||
if (colorStops == null) {
|
||||
if (colors.length != 2)
|
||||
throw new ArgumentError('"colors" must have length 2 if "colorStops" is omitted.');
|
||||
throw ArgumentError('"colors" must have length 2 if "colorStops" is omitted.');
|
||||
} else {
|
||||
if (colors.length != colorStops.length)
|
||||
throw new ArgumentError('"colors" and "colorStops" arguments must have equal length.');
|
||||
throw ArgumentError('"colors" and "colorStops" arguments must have equal length.');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2867,7 +2867,7 @@ class ImageShader extends Shader {
|
||||
assert(matrix4 != null),
|
||||
super._() {
|
||||
if (matrix4.length != 16)
|
||||
throw new ArgumentError('"matrix4" must have 16 entries.');
|
||||
throw ArgumentError('"matrix4" must have 16 entries.');
|
||||
_constructor();
|
||||
_initWithImage(image, tmx.index, tmy.index, matrix4);
|
||||
}
|
||||
@@ -2901,11 +2901,11 @@ class Vertices extends NativeFieldWrapperClass2 {
|
||||
}) : assert(mode != null),
|
||||
assert(positions != null) {
|
||||
if (textureCoordinates != null && textureCoordinates.length != positions.length)
|
||||
throw new ArgumentError('"positions" and "textureCoordinates" lengths must match.');
|
||||
throw ArgumentError('"positions" and "textureCoordinates" lengths must match.');
|
||||
if (colors != null && colors.length != positions.length)
|
||||
throw new ArgumentError('"positions" and "colors" lengths must match.');
|
||||
throw ArgumentError('"positions" and "colors" lengths must match.');
|
||||
if (indices != null && indices.any((int i) => i < 0 || i >= positions.length))
|
||||
throw new ArgumentError('"indices" values must be valid indices in the positions list.');
|
||||
throw ArgumentError('"indices" values must be valid indices in the positions list.');
|
||||
|
||||
final Float32List encodedPositions = _encodePointList(positions);
|
||||
final Float32List encodedTextureCoordinates = (textureCoordinates != null)
|
||||
@@ -2915,12 +2915,12 @@ class Vertices extends NativeFieldWrapperClass2 {
|
||||
? _encodeColorList(colors)
|
||||
: null;
|
||||
final Uint16List encodedIndices = indices != null
|
||||
? new Uint16List.fromList(indices)
|
||||
? Uint16List.fromList(indices)
|
||||
: null;
|
||||
|
||||
_constructor();
|
||||
if (!_init(mode.index, encodedPositions, encodedTextureCoordinates, encodedColors, encodedIndices))
|
||||
throw new ArgumentError('Invalid configuration for vertices.');
|
||||
throw ArgumentError('Invalid configuration for vertices.');
|
||||
}
|
||||
|
||||
Vertices.raw(
|
||||
@@ -2932,15 +2932,15 @@ class Vertices extends NativeFieldWrapperClass2 {
|
||||
}) : assert(mode != null),
|
||||
assert(positions != null) {
|
||||
if (textureCoordinates != null && textureCoordinates.length != positions.length)
|
||||
throw new ArgumentError('"positions" and "textureCoordinates" lengths must match.');
|
||||
throw ArgumentError('"positions" and "textureCoordinates" lengths must match.');
|
||||
if (colors != null && colors.length * 2 != positions.length)
|
||||
throw new ArgumentError('"positions" and "colors" lengths must match.');
|
||||
throw ArgumentError('"positions" and "colors" lengths must match.');
|
||||
if (indices != null && indices.any((int i) => i < 0 || i >= positions.length))
|
||||
throw new ArgumentError('"indices" values must be valid indices in the positions list.');
|
||||
throw ArgumentError('"indices" values must be valid indices in the positions list.');
|
||||
|
||||
_constructor();
|
||||
if (!_init(mode.index, positions, textureCoordinates, colors, indices))
|
||||
throw new ArgumentError('Invalid configuration for vertices.');
|
||||
throw ArgumentError('Invalid configuration for vertices.');
|
||||
}
|
||||
|
||||
void _constructor() native 'Vertices_constructor';
|
||||
@@ -3029,7 +3029,7 @@ class Canvas extends NativeFieldWrapperClass2 {
|
||||
@pragma('vm:entry-point')
|
||||
Canvas(PictureRecorder recorder, [ Rect cullRect ]) : assert(recorder != null) {
|
||||
if (recorder.isRecording)
|
||||
throw new ArgumentError('"recorder" must not already be associated with another Canvas.');
|
||||
throw ArgumentError('"recorder" must not already be associated with another Canvas.');
|
||||
cullRect ??= Rect.largest;
|
||||
_constructor(recorder, cullRect.left, cullRect.top, cullRect.right, cullRect.bottom);
|
||||
}
|
||||
@@ -3089,7 +3089,7 @@ class Canvas extends NativeFieldWrapperClass2 {
|
||||
/// Rect rect = Offset.zero & size;
|
||||
/// canvas.save();
|
||||
/// canvas.clipRRect(new RRect.fromRectXY(rect, 100.0, 100.0));
|
||||
/// canvas.saveLayer(rect, new Paint());
|
||||
/// canvas.saveLayer(rect, Paint());
|
||||
/// canvas.drawPaint(new Paint()..color = Colors.red);
|
||||
/// canvas.drawPaint(new Paint()..color = Colors.white);
|
||||
/// canvas.restore();
|
||||
@@ -3222,7 +3222,7 @@ class Canvas extends NativeFieldWrapperClass2 {
|
||||
void transform(Float64List matrix4) {
|
||||
assert(matrix4 != null);
|
||||
if (matrix4.length != 16)
|
||||
throw new ArgumentError('"matrix4" must have 16 entries.');
|
||||
throw ArgumentError('"matrix4" must have 16 entries.');
|
||||
_transform(matrix4);
|
||||
}
|
||||
void _transform(Float64List matrix4) native 'Canvas_transform';
|
||||
@@ -3238,7 +3238,7 @@ class Canvas extends NativeFieldWrapperClass2 {
|
||||
///
|
||||
/// 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(_rectIsValid(rect));
|
||||
assert(clipOp != null);
|
||||
assert(doAntiAlias != null);
|
||||
@@ -3587,7 +3587,7 @@ class Canvas extends NativeFieldWrapperClass2 {
|
||||
assert(points != null);
|
||||
assert(paint != null);
|
||||
if (points.length % 2 != 0)
|
||||
throw new ArgumentError('"points" must have an even number of values.');
|
||||
throw ArgumentError('"points" must have an even number of values.');
|
||||
_drawPoints(paint._objects, paint._data, pointMode.index, points);
|
||||
}
|
||||
|
||||
@@ -3628,12 +3628,12 @@ class Canvas extends NativeFieldWrapperClass2 {
|
||||
|
||||
final int rectCount = rects.length;
|
||||
if (transforms.length != rectCount)
|
||||
throw new ArgumentError('"transforms" and "rects" lengths must match.');
|
||||
throw ArgumentError('"transforms" and "rects" lengths must match.');
|
||||
if (colors.isNotEmpty && colors.length != rectCount)
|
||||
throw new ArgumentError('If non-null, "colors" length must match that of "transforms" and "rects".');
|
||||
throw ArgumentError('If non-null, "colors" length must match that of "transforms" and "rects".');
|
||||
|
||||
final Float32List rstTransformBuffer = new Float32List(rectCount * 4);
|
||||
final Float32List rectBuffer = new Float32List(rectCount * 4);
|
||||
final Float32List rstTransformBuffer = Float32List(rectCount * 4);
|
||||
final Float32List rectBuffer = Float32List(rectCount * 4);
|
||||
|
||||
for (int i = 0; i < rectCount; ++i) {
|
||||
final int index0 = i * 4;
|
||||
@@ -3693,11 +3693,11 @@ class Canvas extends NativeFieldWrapperClass2 {
|
||||
|
||||
final int rectCount = rects.length;
|
||||
if (rstTransforms.length != rectCount)
|
||||
throw new ArgumentError('"rstTransforms" and "rects" lengths must match.');
|
||||
throw ArgumentError('"rstTransforms" and "rects" lengths must match.');
|
||||
if (rectCount % 4 != 0)
|
||||
throw new ArgumentError('"rstTransforms" and "rects" lengths must be a multiple of four.');
|
||||
throw ArgumentError('"rstTransforms" and "rects" lengths must be a multiple of four.');
|
||||
if (colors != null && colors.length * 4 != rectCount)
|
||||
throw new ArgumentError('If non-null, "colors" length must be one fourth the length of "rstTransforms" and "rects".');
|
||||
throw ArgumentError('If non-null, "colors" length must be one fourth the length of "rstTransforms" and "rects".');
|
||||
|
||||
_drawAtlas(
|
||||
paint._objects, paint._data, atlas, rstTransforms, rects,
|
||||
@@ -3757,7 +3757,7 @@ class Picture extends NativeFieldWrapperClass2 {
|
||||
/// rasterized the first time the image is drawn and then cached.
|
||||
Future<Image> toImage(int width, int height) {
|
||||
if (width <= 0 || height <= 0)
|
||||
throw new Exception('Invalid image dimensions.');
|
||||
throw Exception('Invalid image dimensions.');
|
||||
return _futurize(
|
||||
(_Callback<Image> callback) => _toImage(width, height, callback)
|
||||
);
|
||||
@@ -4025,7 +4025,7 @@ typedef _Callbacker<T> = String Function(_Callback<T> callback);
|
||||
/// typedef IntCallback = void Function(int result);
|
||||
///
|
||||
/// String _doSomethingAndCallback(IntCallback callback) {
|
||||
/// new Timer(new Duration(seconds: 1), () { callback(1); });
|
||||
/// Timer(new Duration(seconds: 1), () { callback(1); });
|
||||
/// }
|
||||
///
|
||||
/// Future<int> doSomething() {
|
||||
@@ -4033,15 +4033,15 @@ typedef _Callbacker<T> = String Function(_Callback<T> callback);
|
||||
/// }
|
||||
/// ```
|
||||
Future<T> _futurize<T>(_Callbacker<T> callbacker) {
|
||||
final Completer<T> completer = new Completer<T>.sync();
|
||||
final Completer<T> completer = Completer<T>.sync();
|
||||
final String error = callbacker((T t) {
|
||||
if (t == null) {
|
||||
completer.completeError(new Exception('operation failed'));
|
||||
completer.completeError(Exception('operation failed'));
|
||||
} else {
|
||||
completer.complete(t);
|
||||
}
|
||||
});
|
||||
if (error != null)
|
||||
throw new Exception(error);
|
||||
throw Exception(error);
|
||||
return completer.future;
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ class PluginUtilities {
|
||||
assert(callback != null, "'callback' must not be null.");
|
||||
return _forwardCache.putIfAbsent(callback, () {
|
||||
final int handle = _getCallbackHandle(callback);
|
||||
return handle != null ? new CallbackHandle.fromRawHandle(handle) : null;
|
||||
return handle != null ? CallbackHandle.fromRawHandle(handle) : null;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -70,30 +70,30 @@ enum PointerSignalKind {
|
||||
class PointerData {
|
||||
/// Creates an object that represents the state of a pointer.
|
||||
const PointerData({
|
||||
this.timeStamp: Duration.zero,
|
||||
this.change: PointerChange.cancel,
|
||||
this.kind: PointerDeviceKind.touch,
|
||||
this.timeStamp = Duration.zero,
|
||||
this.change = PointerChange.cancel,
|
||||
this.kind = PointerDeviceKind.touch,
|
||||
this.signalKind,
|
||||
this.device: 0,
|
||||
this.physicalX: 0.0,
|
||||
this.physicalY: 0.0,
|
||||
this.buttons: 0,
|
||||
this.obscured: false,
|
||||
this.pressure: 0.0,
|
||||
this.pressureMin: 0.0,
|
||||
this.pressureMax: 0.0,
|
||||
this.distance: 0.0,
|
||||
this.distanceMax: 0.0,
|
||||
this.size: 0.0,
|
||||
this.radiusMajor: 0.0,
|
||||
this.radiusMinor: 0.0,
|
||||
this.radiusMin: 0.0,
|
||||
this.radiusMax: 0.0,
|
||||
this.orientation: 0.0,
|
||||
this.tilt: 0.0,
|
||||
this.platformData: 0,
|
||||
this.scrollDeltaX: 0.0,
|
||||
this.scrollDeltaY: 0.0,
|
||||
this.device = 0,
|
||||
this.physicalX = 0.0,
|
||||
this.physicalY = 0.0,
|
||||
this.buttons = 0,
|
||||
this.obscured = false,
|
||||
this.pressure = 0.0,
|
||||
this.pressureMin = 0.0,
|
||||
this.pressureMax = 0.0,
|
||||
this.distance = 0.0,
|
||||
this.distanceMax = 0.0,
|
||||
this.size = 0.0,
|
||||
this.radiusMajor = 0.0,
|
||||
this.radiusMinor = 0.0,
|
||||
this.radiusMin = 0.0,
|
||||
this.radiusMax = 0.0,
|
||||
this.orientation = 0.0,
|
||||
this.tilt = 0.0,
|
||||
this.platformData = 0,
|
||||
this.scrollDeltaX = 0.0,
|
||||
this.scrollDeltaY = 0.0,
|
||||
});
|
||||
|
||||
/// Time of event dispatch, relative to an arbitrary timeline.
|
||||
@@ -267,7 +267,7 @@ 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>[] });
|
||||
const PointerDataPacket({ this.data = const <PointerData>[] });
|
||||
|
||||
/// Data about the individual pointers in this packet.
|
||||
///
|
||||
|
||||
@@ -42,55 +42,55 @@ class SemanticsAction {
|
||||
|
||||
/// The equivalent of a user briefly tapping the screen with the finger
|
||||
/// without moving it.
|
||||
static const SemanticsAction tap = const SemanticsAction._(_kTapIndex);
|
||||
static const SemanticsAction tap = SemanticsAction._(_kTapIndex);
|
||||
|
||||
/// The equivalent of a user pressing and holding the screen with the finger
|
||||
/// for a few seconds without moving it.
|
||||
static const SemanticsAction longPress = const SemanticsAction._(_kLongPressIndex);
|
||||
static const SemanticsAction longPress = SemanticsAction._(_kLongPressIndex);
|
||||
|
||||
/// The equivalent of a user moving their finger across the screen from right
|
||||
/// to left.
|
||||
///
|
||||
/// This action should be recognized by controls that are horizontally
|
||||
/// scrollable.
|
||||
static const SemanticsAction scrollLeft = const SemanticsAction._(_kScrollLeftIndex);
|
||||
static const SemanticsAction scrollLeft = SemanticsAction._(_kScrollLeftIndex);
|
||||
|
||||
/// The equivalent of a user moving their finger across the screen from left
|
||||
/// to right.
|
||||
///
|
||||
/// This action should be recognized by controls that are horizontally
|
||||
/// scrollable.
|
||||
static const SemanticsAction scrollRight = const SemanticsAction._(_kScrollRightIndex);
|
||||
static const SemanticsAction scrollRight = SemanticsAction._(_kScrollRightIndex);
|
||||
|
||||
/// The equivalent of a user moving their finger across the screen from
|
||||
/// bottom to top.
|
||||
///
|
||||
/// This action should be recognized by controls that are vertically
|
||||
/// scrollable.
|
||||
static const SemanticsAction scrollUp = const SemanticsAction._(_kScrollUpIndex);
|
||||
static const SemanticsAction scrollUp = SemanticsAction._(_kScrollUpIndex);
|
||||
|
||||
/// The equivalent of a user moving their finger across the screen from top
|
||||
/// to bottom.
|
||||
///
|
||||
/// This action should be recognized by controls that are vertically
|
||||
/// scrollable.
|
||||
static const SemanticsAction scrollDown = const SemanticsAction._(_kScrollDownIndex);
|
||||
static const SemanticsAction scrollDown = SemanticsAction._(_kScrollDownIndex);
|
||||
|
||||
/// A request to increase the value represented by the semantics node.
|
||||
///
|
||||
/// For example, this action might be recognized by a slider control.
|
||||
static const SemanticsAction increase = const SemanticsAction._(_kIncreaseIndex);
|
||||
static const SemanticsAction increase = SemanticsAction._(_kIncreaseIndex);
|
||||
|
||||
/// A request to decrease the value represented by the semantics node.
|
||||
///
|
||||
/// For example, this action might be recognized by a slider control.
|
||||
static const SemanticsAction decrease = const SemanticsAction._(_kDecreaseIndex);
|
||||
static const SemanticsAction decrease = SemanticsAction._(_kDecreaseIndex);
|
||||
|
||||
/// A request to fully show the semantics node on screen.
|
||||
///
|
||||
/// For example, this action might be send to a node in a scrollable list that
|
||||
/// is partially off screen to bring it on screen.
|
||||
static const SemanticsAction showOnScreen = const SemanticsAction._(_kShowOnScreenIndex);
|
||||
static const SemanticsAction showOnScreen = SemanticsAction._(_kShowOnScreenIndex);
|
||||
|
||||
/// Move the cursor forward by one character.
|
||||
///
|
||||
@@ -98,7 +98,7 @@ class SemanticsAction {
|
||||
///
|
||||
/// The action includes a boolean argument, which indicates whether the cursor
|
||||
/// movement should extend (or start) a selection.
|
||||
static const SemanticsAction moveCursorForwardByCharacter = const SemanticsAction._(_kMoveCursorForwardByCharacterIndex);
|
||||
static const SemanticsAction moveCursorForwardByCharacter = SemanticsAction._(_kMoveCursorForwardByCharacterIndex);
|
||||
|
||||
/// Move the cursor backward by one character.
|
||||
///
|
||||
@@ -106,7 +106,7 @@ class SemanticsAction {
|
||||
///
|
||||
/// The action includes a boolean argument, which indicates whether the cursor
|
||||
/// movement should extend (or start) a selection.
|
||||
static const SemanticsAction moveCursorBackwardByCharacter = const SemanticsAction._(_kMoveCursorBackwardByCharacterIndex);
|
||||
static const SemanticsAction moveCursorBackwardByCharacter = SemanticsAction._(_kMoveCursorBackwardByCharacterIndex);
|
||||
|
||||
/// Set the text selection to the given range.
|
||||
///
|
||||
@@ -117,16 +117,16 @@ class SemanticsAction {
|
||||
///
|
||||
/// Setting `base` and `extent` to the same value will move the cursor to
|
||||
/// that position (without selecting anything).
|
||||
static const SemanticsAction setSelection = const SemanticsAction._(_kSetSelectionIndex);
|
||||
static const SemanticsAction setSelection = SemanticsAction._(_kSetSelectionIndex);
|
||||
|
||||
/// Copy the current selection to the clipboard.
|
||||
static const SemanticsAction copy = const SemanticsAction._(_kCopyIndex);
|
||||
static const SemanticsAction copy = SemanticsAction._(_kCopyIndex);
|
||||
|
||||
/// Cut the current selection and place it in the clipboard.
|
||||
static const SemanticsAction cut = const SemanticsAction._(_kCutIndex);
|
||||
static const SemanticsAction cut = SemanticsAction._(_kCutIndex);
|
||||
|
||||
/// Paste the current content of the clipboard.
|
||||
static const SemanticsAction paste = const SemanticsAction._(_kPasteIndex);
|
||||
static const SemanticsAction paste = SemanticsAction._(_kPasteIndex);
|
||||
|
||||
/// Indicates that the node has gained accessibility focus.
|
||||
///
|
||||
@@ -139,7 +139,7 @@ class SemanticsAction {
|
||||
/// The accessibility focus is different from the input focus. The input focus
|
||||
/// is usually held by the element that currently responds to keyboard inputs.
|
||||
/// Accessibility focus and input focus can be held by two different nodes!
|
||||
static const SemanticsAction didGainAccessibilityFocus = const SemanticsAction._(_kDidGainAccessibilityFocusIndex);
|
||||
static const SemanticsAction didGainAccessibilityFocus = SemanticsAction._(_kDidGainAccessibilityFocusIndex);
|
||||
|
||||
/// Indicates that the node has lost accessibility focus.
|
||||
///
|
||||
@@ -152,13 +152,13 @@ class SemanticsAction {
|
||||
/// The accessibility focus is different from the input focus. The input focus
|
||||
/// is usually held by the element that currently responds to keyboard inputs.
|
||||
/// Accessibility focus and input focus can be held by two different nodes!
|
||||
static const SemanticsAction didLoseAccessibilityFocus = const SemanticsAction._(_kDidLoseAccessibilityFocusIndex);
|
||||
static const SemanticsAction didLoseAccessibilityFocus = SemanticsAction._(_kDidLoseAccessibilityFocusIndex);
|
||||
|
||||
/// Indicates that the user has invoked a custom accessibility action.
|
||||
///
|
||||
/// This handler is added automatically whenever a custom accessibility
|
||||
/// action is added to a semantics node.
|
||||
static const SemanticsAction customAction = const SemanticsAction._(_kCustomAction);
|
||||
static const SemanticsAction customAction = SemanticsAction._(_kCustomAction);
|
||||
|
||||
/// A request that the node should be dismissed.
|
||||
///
|
||||
@@ -167,7 +167,7 @@ class SemanticsAction {
|
||||
/// (with TalkBack) special hint text is spoken when focusing the node and
|
||||
/// a custom action is available in the local context menu. On iOS,
|
||||
/// (with VoiceOver) users can perform a standard gesture to dismiss it.
|
||||
static const SemanticsAction dismiss = const SemanticsAction._(_kDismissIndex);
|
||||
static const SemanticsAction dismiss = SemanticsAction._(_kDismissIndex);
|
||||
|
||||
/// Move the cursor forward by one word.
|
||||
///
|
||||
@@ -175,7 +175,7 @@ class SemanticsAction {
|
||||
///
|
||||
/// The action includes a boolean argument, which indicates whether the cursor
|
||||
/// movement should extend (or start) a selection.
|
||||
static const SemanticsAction moveCursorForwardByWord = const SemanticsAction._(_kMoveCursorForwardByWordIndex);
|
||||
static const SemanticsAction moveCursorForwardByWord = SemanticsAction._(_kMoveCursorForwardByWordIndex);
|
||||
|
||||
/// Move the cursor backward by one word.
|
||||
///
|
||||
@@ -183,13 +183,13 @@ class SemanticsAction {
|
||||
///
|
||||
/// The action includes a boolean argument, which indicates whether the cursor
|
||||
/// movement should extend (or start) a selection.
|
||||
static const SemanticsAction moveCursorBackwardByWord = const SemanticsAction._(_kMoveCursorBackwardByWordIndex);
|
||||
static const SemanticsAction moveCursorBackwardByWord = SemanticsAction._(_kMoveCursorBackwardByWordIndex);
|
||||
|
||||
/// The possible semantics actions.
|
||||
///
|
||||
/// The map's key is the [index] of the action and the value is the action
|
||||
/// itself.
|
||||
static const Map<int, SemanticsAction> values = const <int, SemanticsAction>{
|
||||
static const Map<int, SemanticsAction> values = <int, SemanticsAction>{
|
||||
_kTapIndex: tap,
|
||||
_kLongPressIndex: longPress,
|
||||
_kScrollLeftIndex: scrollLeft,
|
||||
@@ -305,7 +305,7 @@ class SemanticsFlag {
|
||||
/// See also:
|
||||
///
|
||||
/// * [SemanticsFlag.isChecked], which controls whether the node is "checked" or "unchecked".
|
||||
static const SemanticsFlag hasCheckedState = const SemanticsFlag._(_kHasCheckedStateIndex);
|
||||
static const SemanticsFlag hasCheckedState = SemanticsFlag._(_kHasCheckedStateIndex);
|
||||
|
||||
/// Whether a semantics node that [hasCheckedState] is checked.
|
||||
///
|
||||
@@ -317,7 +317,7 @@ class SemanticsFlag {
|
||||
/// See also:
|
||||
///
|
||||
/// * [SemanticsFlag.hasCheckedState], which enables a checked state.
|
||||
static const SemanticsFlag isChecked = const SemanticsFlag._(_kIsCheckedIndex);
|
||||
static const SemanticsFlag isChecked = SemanticsFlag._(_kIsCheckedIndex);
|
||||
|
||||
|
||||
/// Whether a semantics node is selected.
|
||||
@@ -326,25 +326,25 @@ class SemanticsFlag {
|
||||
/// "unselected".
|
||||
///
|
||||
/// For example, the active tab in a tab bar has [isSelected] set to true.
|
||||
static const SemanticsFlag isSelected = const SemanticsFlag._(_kIsSelectedIndex);
|
||||
static const SemanticsFlag isSelected = SemanticsFlag._(_kIsSelectedIndex);
|
||||
|
||||
/// Whether the semantic node represents a button.
|
||||
///
|
||||
/// Platforms has special handling for buttons, for example Android's TalkBack
|
||||
/// and iOS's VoiceOver provides an additional hint when the focused object is
|
||||
/// a button.
|
||||
static const SemanticsFlag isButton = const SemanticsFlag._(_kIsButtonIndex);
|
||||
static const SemanticsFlag isButton = SemanticsFlag._(_kIsButtonIndex);
|
||||
|
||||
/// Whether the semantic node represents a text field.
|
||||
///
|
||||
/// Text fields are announced as such and allow text input via accessibility
|
||||
/// affordances.
|
||||
static const SemanticsFlag isTextField = const SemanticsFlag._(_kIsTextFieldIndex);
|
||||
static const SemanticsFlag isTextField = SemanticsFlag._(_kIsTextFieldIndex);
|
||||
|
||||
/// Whether the semantic node currently holds the user's focus.
|
||||
///
|
||||
/// The focused element is usually the current receiver of keyboard inputs.
|
||||
static const SemanticsFlag isFocused = const SemanticsFlag._(_kIsFocusedIndex);
|
||||
static const SemanticsFlag isFocused = SemanticsFlag._(_kIsFocusedIndex);
|
||||
|
||||
/// The semantics node has the quality of either being "enabled" or
|
||||
/// "disabled".
|
||||
@@ -352,33 +352,33 @@ class SemanticsFlag {
|
||||
/// For example, a button can be enabled or disabled and therefore has an
|
||||
/// "enabled" state. Static text is usually neither enabled nor disabled and
|
||||
/// therefore does not have an "enabled" state.
|
||||
static const SemanticsFlag hasEnabledState = const SemanticsFlag._(_kHasEnabledStateIndex);
|
||||
static const SemanticsFlag hasEnabledState = SemanticsFlag._(_kHasEnabledStateIndex);
|
||||
|
||||
/// Whether a semantic node that [hasEnabledState] is currently enabled.
|
||||
///
|
||||
/// A disabled element does not respond to user interaction. For example, a
|
||||
/// button that currently does not respond to user interaction should be
|
||||
/// marked as disabled.
|
||||
static const SemanticsFlag isEnabled = const SemanticsFlag._(_kIsEnabledIndex);
|
||||
static const SemanticsFlag isEnabled = SemanticsFlag._(_kIsEnabledIndex);
|
||||
|
||||
/// Whether a semantic node is in a mutually exclusive group.
|
||||
///
|
||||
/// For example, a radio button is in a mutually exclusive group because
|
||||
/// only one radio button in that group can be marked as [isChecked].
|
||||
static const SemanticsFlag isInMutuallyExclusiveGroup = const SemanticsFlag._(_kIsInMutuallyExclusiveGroupIndex);
|
||||
static const SemanticsFlag isInMutuallyExclusiveGroup = SemanticsFlag._(_kIsInMutuallyExclusiveGroupIndex);
|
||||
|
||||
/// Whether a semantic node is a header that divides content into sections.
|
||||
///
|
||||
/// For example, headers can be used to divide a list of alphabetically
|
||||
/// sorted words into the sections A, B, C, etc. as can be found in many
|
||||
/// address book applications.
|
||||
static const SemanticsFlag isHeader = const SemanticsFlag._(_kIsHeaderIndex);
|
||||
static const SemanticsFlag isHeader = SemanticsFlag._(_kIsHeaderIndex);
|
||||
|
||||
/// Whether the value of the semantics node is obscured.
|
||||
///
|
||||
/// This is usually used for text fields to indicate that its content
|
||||
/// is a password or contains other sensitive information.
|
||||
static const SemanticsFlag isObscured = const SemanticsFlag._(_kIsObscuredIndex);
|
||||
static const SemanticsFlag isObscured = SemanticsFlag._(_kIsObscuredIndex);
|
||||
|
||||
/// Whether the semantics node is the root of a subtree for which a route name
|
||||
/// should be announced.
|
||||
@@ -403,7 +403,7 @@ class SemanticsFlag {
|
||||
///
|
||||
/// This is used in widgets such as Routes, Drawers, and Dialogs to
|
||||
/// communicate significant changes in the visible screen.
|
||||
static const SemanticsFlag scopesRoute = const SemanticsFlag._(_kScopesRouteIndex);
|
||||
static const SemanticsFlag scopesRoute = SemanticsFlag._(_kScopesRouteIndex);
|
||||
|
||||
/// Whether the semantics node label is the name of a visually distinct
|
||||
/// route.
|
||||
@@ -416,7 +416,7 @@ class SemanticsFlag {
|
||||
///
|
||||
/// Updating this label within the same active route subtree will not cause
|
||||
/// additional announcements.
|
||||
static const SemanticsFlag namesRoute = const SemanticsFlag._(_kNamesRouteIndex);
|
||||
static const SemanticsFlag namesRoute = SemanticsFlag._(_kNamesRouteIndex);
|
||||
|
||||
/// Whether the semantics node is considered hidden.
|
||||
///
|
||||
@@ -434,13 +434,13 @@ class SemanticsFlag {
|
||||
/// the semantics tree altogether. Hidden elements are only included in the
|
||||
/// semantics tree to work around platform limitations and they are mainly
|
||||
/// used to implement accessibility scrolling on iOS.
|
||||
static const SemanticsFlag isHidden = const SemanticsFlag._(_kIsHiddenIndex);
|
||||
static const SemanticsFlag isHidden = SemanticsFlag._(_kIsHiddenIndex);
|
||||
|
||||
/// Whether the semantics node represents an image.
|
||||
///
|
||||
/// Both TalkBack and VoiceOver will inform the user the the semantics node
|
||||
/// represents an image.
|
||||
static const SemanticsFlag isImage = const SemanticsFlag._(_kIsImageIndex);
|
||||
static const SemanticsFlag isImage = SemanticsFlag._(_kIsImageIndex);
|
||||
|
||||
/// Whether the semantics node is a live region.
|
||||
///
|
||||
@@ -451,7 +451,7 @@ class SemanticsFlag {
|
||||
/// An example of a live region is a [SnackBar] widget. On Android, A live
|
||||
/// region causes a polite announcement to be generated automatically, even
|
||||
/// if the user does not have focus of the widget.
|
||||
static const SemanticsFlag isLiveRegion = const SemanticsFlag._(_kIsLiveRegionIndex);
|
||||
static const SemanticsFlag isLiveRegion = SemanticsFlag._(_kIsLiveRegionIndex);
|
||||
|
||||
/// The semantics node has the quality of either being "on" or "off".
|
||||
///
|
||||
@@ -462,7 +462,7 @@ class SemanticsFlag {
|
||||
/// See also:
|
||||
///
|
||||
/// * [SemanticsFlag.isToggled], which controls whether the node is "on" or "off".
|
||||
static const SemanticsFlag hasToggledState = const SemanticsFlag._(_kHasToggledStateIndex);
|
||||
static const SemanticsFlag hasToggledState = SemanticsFlag._(_kHasToggledStateIndex);
|
||||
|
||||
/// If true, the semantics node is "on". If false, the semantics node is
|
||||
/// "off".
|
||||
@@ -472,7 +472,7 @@ class SemanticsFlag {
|
||||
/// See also:
|
||||
///
|
||||
/// * [SemanticsFlag.hasToggledState], which enables a toggled state.
|
||||
static const SemanticsFlag isToggled = const SemanticsFlag._(_kIsToggledIndex);
|
||||
static const SemanticsFlag isToggled = SemanticsFlag._(_kIsToggledIndex);
|
||||
|
||||
/// Whether the platform can scroll the semantics node when the user attempts
|
||||
/// to move focus to an offscreen child.
|
||||
@@ -481,12 +481,12 @@ class SemanticsFlag {
|
||||
/// easily move the accessibility focus to the next set of children. A
|
||||
/// [PageView] widget does not have implicit scrolling, so that users don't
|
||||
/// navigate to the next page when reaching the end of the current one.
|
||||
static const SemanticsFlag hasImplicitScrolling = const SemanticsFlag._(_kHasImplicitScrollingIndex);
|
||||
static const SemanticsFlag hasImplicitScrolling = SemanticsFlag._(_kHasImplicitScrollingIndex);
|
||||
|
||||
/// The possible semantics flags.
|
||||
///
|
||||
/// The map's key is the [index] of the flag and the value is the flag itself.
|
||||
static const Map<int, SemanticsFlag> values = const <int, SemanticsFlag>{
|
||||
static const Map<int, SemanticsFlag> values = <int, SemanticsFlag>{
|
||||
_kHasCheckedStateIndex: hasCheckedState,
|
||||
_kIsCheckedIndex: isChecked,
|
||||
_kIsSelectedIndex: isSelected,
|
||||
|
||||
@@ -21,31 +21,31 @@ class FontWeight {
|
||||
final int index;
|
||||
|
||||
/// Thin, the least thick
|
||||
static const FontWeight w100 = const FontWeight._(0);
|
||||
static const FontWeight w100 = FontWeight._(0);
|
||||
|
||||
/// Extra-light
|
||||
static const FontWeight w200 = const FontWeight._(1);
|
||||
static const FontWeight w200 = FontWeight._(1);
|
||||
|
||||
/// Light
|
||||
static const FontWeight w300 = const FontWeight._(2);
|
||||
static const FontWeight w300 = FontWeight._(2);
|
||||
|
||||
/// Normal / regular / plain
|
||||
static const FontWeight w400 = const FontWeight._(3);
|
||||
static const FontWeight w400 = FontWeight._(3);
|
||||
|
||||
/// Medium
|
||||
static const FontWeight w500 = const FontWeight._(4);
|
||||
static const FontWeight w500 = FontWeight._(4);
|
||||
|
||||
/// Semi-bold
|
||||
static const FontWeight w600 = const FontWeight._(5);
|
||||
static const FontWeight w600 = FontWeight._(5);
|
||||
|
||||
/// Bold
|
||||
static const FontWeight w700 = const FontWeight._(6);
|
||||
static const FontWeight w700 = FontWeight._(6);
|
||||
|
||||
/// Extra-bold
|
||||
static const FontWeight w800 = const FontWeight._(7);
|
||||
static const FontWeight w800 = FontWeight._(7);
|
||||
|
||||
/// Black, the most thick
|
||||
static const FontWeight w900 = const FontWeight._(8);
|
||||
static const FontWeight w900 = FontWeight._(8);
|
||||
|
||||
/// The default font weight.
|
||||
static const FontWeight normal = w400;
|
||||
@@ -54,7 +54,7 @@ class FontWeight {
|
||||
static const FontWeight bold = w700;
|
||||
|
||||
/// A list of all the font weights.
|
||||
static const List<FontWeight> values = const <FontWeight>[
|
||||
static const List<FontWeight> values = <FontWeight>[
|
||||
w100, w200, w300, w400, w500, w600, w700, w800, w900
|
||||
];
|
||||
|
||||
@@ -153,7 +153,7 @@ class TextDecoration {
|
||||
int mask = 0;
|
||||
for (TextDecoration decoration in decorations)
|
||||
mask |= decoration._mask;
|
||||
return new TextDecoration._(mask);
|
||||
return TextDecoration._(mask);
|
||||
}
|
||||
|
||||
final int _mask;
|
||||
@@ -164,16 +164,16 @@ class TextDecoration {
|
||||
}
|
||||
|
||||
/// Do not draw a decoration
|
||||
static const TextDecoration none = const TextDecoration._(0x0);
|
||||
static const TextDecoration none = TextDecoration._(0x0);
|
||||
|
||||
/// Draw a line underneath each line of text
|
||||
static const TextDecoration underline = const TextDecoration._(0x1);
|
||||
static const TextDecoration underline = TextDecoration._(0x1);
|
||||
|
||||
/// Draw a line above each line of text
|
||||
static const TextDecoration overline = const TextDecoration._(0x2);
|
||||
static const TextDecoration overline = TextDecoration._(0x2);
|
||||
|
||||
/// Draw a line through each line of text
|
||||
static const TextDecoration lineThrough = const TextDecoration._(0x4);
|
||||
static const TextDecoration lineThrough = TextDecoration._(0x4);
|
||||
|
||||
@override
|
||||
bool operator ==(dynamic other) {
|
||||
@@ -283,7 +283,7 @@ Int32List _encodeTextStyle(
|
||||
Paint foreground,
|
||||
List<Shadow> shadows
|
||||
) {
|
||||
final Int32List result = new Int32List(8);
|
||||
final Int32List result = Int32List(8);
|
||||
if (color != null) {
|
||||
result[0] |= 1 << 1;
|
||||
result[1] = color.value;
|
||||
@@ -408,7 +408,7 @@ class TextStyle {
|
||||
List<Shadow> shadows,
|
||||
}) : assert(color == null || foreground == null,
|
||||
'Cannot provide both a color and a foreground\n'
|
||||
'The color argument is just a shorthand for "foreground: new Paint()..color = color".'
|
||||
'The color argument is just a shorthand for "foreground: Paint()..color = color".'
|
||||
),
|
||||
_encoded = _encodeTextStyle(
|
||||
color,
|
||||
@@ -489,9 +489,9 @@ class TextStyle {
|
||||
@override
|
||||
String toString() {
|
||||
return 'TextStyle('
|
||||
'color: ${ _encoded[0] & 0x00002 == 0x00002 ? new Color(_encoded[1]) : "unspecified"}, '
|
||||
'decoration: ${ _encoded[0] & 0x00004 == 0x00004 ? new TextDecoration._(_encoded[2]) : "unspecified"}, '
|
||||
'decorationColor: ${ _encoded[0] & 0x00008 == 0x00008 ? new Color(_encoded[3]) : "unspecified"}, '
|
||||
'color: ${ _encoded[0] & 0x00002 == 0x00002 ? Color(_encoded[1]) : "unspecified"}, '
|
||||
'decoration: ${ _encoded[0] & 0x00004 == 0x00004 ? TextDecoration._(_encoded[2]) : "unspecified"}, '
|
||||
'decorationColor: ${ _encoded[0] & 0x00008 == 0x00008 ? Color(_encoded[3]) : "unspecified"}, '
|
||||
'decorationStyle: ${ _encoded[0] & 0x00010 == 0x00010 ? TextDecorationStyle.values[_encoded[4]] : "unspecified"}, '
|
||||
// The decorationThickness is not in encoded order in order to keep it near the other decoration properties.
|
||||
'decorationThickness: ${_encoded[0] & 0x00100 == 0x00100 ? _decorationThickness : "unspecified"}, '
|
||||
@@ -547,7 +547,7 @@ Int32List _encodeParagraphStyle(
|
||||
String ellipsis,
|
||||
Locale locale,
|
||||
) {
|
||||
final Int32List result = new Int32List(6); // also update paragraph_builder.cc
|
||||
final Int32List result = Int32List(6); // also update paragraph_builder.cc
|
||||
if (textAlign != null) {
|
||||
result[0] |= 1 << 1;
|
||||
result[1] = textAlign.index;
|
||||
@@ -1028,7 +1028,7 @@ class TextBox {
|
||||
final TextDirection direction;
|
||||
|
||||
/// Returns a rect of the same size as this box.
|
||||
Rect toRect() => new 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.
|
||||
///
|
||||
@@ -1139,7 +1139,7 @@ class TextPosition {
|
||||
/// The arguments must not be null (so the [offset] argument is required).
|
||||
const TextPosition({
|
||||
this.offset,
|
||||
this.affinity: TextAffinity.downstream,
|
||||
this.affinity = TextAffinity.downstream,
|
||||
}) : assert(offset != null),
|
||||
assert(affinity != null);
|
||||
|
||||
@@ -1377,7 +1377,7 @@ class Paragraph extends NativeFieldWrapperClass2 {
|
||||
/// Returns the text position closest to the given offset.
|
||||
TextPosition getPositionForOffset(Offset offset) {
|
||||
final List<int> encoded = _getPositionForOffset(offset.dx, offset.dy);
|
||||
return new TextPosition(offset: encoded[0], affinity: TextAffinity.values[encoded[1]]);
|
||||
return TextPosition(offset: encoded[0], affinity: TextAffinity.values[encoded[1]]);
|
||||
}
|
||||
List<int> _getPositionForOffset(double dx, double dy) native 'Paragraph_getPositionForOffset';
|
||||
|
||||
@@ -1410,7 +1410,7 @@ class Paragraph extends NativeFieldWrapperClass2 {
|
||||
/// paint it with [Canvas.drawParagraph].
|
||||
class ParagraphBuilder extends NativeFieldWrapperClass2 {
|
||||
|
||||
/// Creates a [ParagraphBuilder] object, which is used to create a
|
||||
/// Creates a new [ParagraphBuilder] object, which is used to create a
|
||||
/// [Paragraph].
|
||||
@pragma('vm:entry-point')
|
||||
ParagraphBuilder(ParagraphStyle style) {
|
||||
@@ -1503,7 +1503,7 @@ class ParagraphBuilder extends NativeFieldWrapperClass2 {
|
||||
void addText(String text) {
|
||||
final String error = _addText(text);
|
||||
if (error != null)
|
||||
throw new ArgumentError(error);
|
||||
throw ArgumentError(error);
|
||||
}
|
||||
String _addText(String text) native 'ParagraphBuilder_addText';
|
||||
|
||||
|
||||
@@ -108,7 +108,7 @@ class WindowPadding {
|
||||
final double bottom;
|
||||
|
||||
/// A window padding that has zeros for each edge.
|
||||
static const WindowPadding zero = const WindowPadding._(left: 0.0, top: 0.0, right: 0.0, bottom: 0.0);
|
||||
static const WindowPadding zero = WindowPadding._(left: 0.0, top: 0.0, right: 0.0, bottom: 0.0);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
@@ -141,8 +141,8 @@ class Locale {
|
||||
/// For example:
|
||||
///
|
||||
/// ```dart
|
||||
/// const Locale swissFrench = const Locale('fr', 'CH');
|
||||
/// const Locale canadianFrench = const Locale('fr', 'CA');
|
||||
/// const Locale swissFrench = Locale('fr', 'CH');
|
||||
/// const Locale canadianFrench = Locale('fr', 'CA');
|
||||
/// ```
|
||||
///
|
||||
/// The primary language subtag must not be null. The region subtag is
|
||||
@@ -228,7 +228,7 @@ class Locale {
|
||||
|
||||
// This map is generated by //flutter/tools/gen_locale.dart
|
||||
// Mappings generated for language subtag registry as of 2019-02-27.
|
||||
static const Map<String, String> _deprecatedLanguageSubtagMap = const <String, String>{
|
||||
static const Map<String, String> _deprecatedLanguageSubtagMap = <String, String>{
|
||||
'in': 'id', // Indonesian; deprecated 1989-01-01
|
||||
'iw': 'he', // Hebrew; deprecated 1989-01-01
|
||||
'ji': 'yi', // Yiddish; deprecated 1989-01-01
|
||||
@@ -347,7 +347,7 @@ class Locale {
|
||||
|
||||
// This map is generated by //flutter/tools/gen_locale.dart
|
||||
// Mappings generated for language subtag registry as of 2019-02-27.
|
||||
static const Map<String, String> _deprecatedRegionSubtagMap = const <String, String>{
|
||||
static const Map<String, String> _deprecatedRegionSubtagMap = <String, String>{
|
||||
'BU': 'MM', // Burma; deprecated 1989-12-05
|
||||
'DD': 'DE', // German Democratic Republic; deprecated 1990-10-30
|
||||
'FX': 'FR', // Metropolitan France; deprecated 1997-07-14
|
||||
@@ -867,7 +867,7 @@ class Window {
|
||||
final String error =
|
||||
_sendPlatformMessage(name, _zonedPlatformMessageResponseCallback(callback), data);
|
||||
if (error != null)
|
||||
throw new Exception(error);
|
||||
throw Exception(error);
|
||||
}
|
||||
String _sendPlatformMessage(String name,
|
||||
PlatformMessageResponseCallback callback,
|
||||
@@ -1002,4 +1002,4 @@ enum Brightness {
|
||||
/// 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.
|
||||
final Window window = new Window._();
|
||||
final Window window = Window._();
|
||||
|
||||
@@ -10,53 +10,53 @@ void main() {
|
||||
|
||||
@pragma('vm:entry-point')
|
||||
void sayHi() {
|
||||
print("Hi");
|
||||
print('Hi');
|
||||
}
|
||||
|
||||
@pragma('vm:entry-point')
|
||||
void throwExceptionNow() {
|
||||
throw("Hello");
|
||||
throw 'Hello';
|
||||
}
|
||||
|
||||
@pragma('vm:entry-point')
|
||||
void canRegisterNativeCallback() async {
|
||||
print("In function canRegisterNativeCallback");
|
||||
NotifyNative();
|
||||
print("Called native method from canRegisterNativeCallback");
|
||||
print('In function canRegisterNativeCallback');
|
||||
notifyNative();
|
||||
print('Called native method from canRegisterNativeCallback');
|
||||
}
|
||||
|
||||
void NotifyNative() native "NotifyNative";
|
||||
void notifyNative() native 'NotifyNative';
|
||||
|
||||
@pragma('vm:entry-point')
|
||||
void testIsolateShutdown() { }
|
||||
|
||||
@pragma('vm:entry-point')
|
||||
void testCanSaveCompilationTrace() {
|
||||
List<int> trace = null;
|
||||
List<int> trace;
|
||||
try {
|
||||
trace = saveCompilationTrace();
|
||||
} catch (exception) {
|
||||
print("Could not save compilation trace: " + exception);
|
||||
print('Could not save compilation trace: ' + exception);
|
||||
}
|
||||
NotifyResult(trace != null && trace.length > 0);
|
||||
notifyResult(trace != null && trace.isNotEmpty);
|
||||
}
|
||||
|
||||
void NotifyResult(bool success) native "NotifyNative";
|
||||
void PassMessage(String message) native "PassMessage";
|
||||
void notifyResult(bool success) native 'NotifyNative';
|
||||
void passMessage(String message) native 'PassMessage';
|
||||
|
||||
void secondaryIsolateMain(String message) {
|
||||
print("Secondary isolate got message: " + message);
|
||||
PassMessage("Hello from code is secondary isolate.");
|
||||
NotifyNative();
|
||||
print('Secondary isolate got message: ' + message);
|
||||
passMessage('Hello from code is secondary isolate.');
|
||||
notifyNative();
|
||||
}
|
||||
|
||||
@pragma('vm:entry-point')
|
||||
void testCanLaunchSecondaryIsolate() {
|
||||
Isolate.spawn(secondaryIsolateMain, "Hello from root isolate.");
|
||||
NotifyNative();
|
||||
Isolate.spawn(secondaryIsolateMain, 'Hello from root isolate.');
|
||||
notifyNative();
|
||||
}
|
||||
|
||||
@pragma('vm:entry-point')
|
||||
void testCanRecieveArguments(List<String> args) {
|
||||
NotifyResult(args != null && args.length == 1 && args[0] == "arg1");
|
||||
notifyResult(args != null && args.length == 1 && args[0] == 'arg1');
|
||||
}
|
||||
|
||||
@@ -4,24 +4,24 @@
|
||||
|
||||
import 'dart:isolate';
|
||||
|
||||
main() {}
|
||||
void main() {}
|
||||
|
||||
@pragma('vm:entry-point')
|
||||
fixturesAreFunctionalMain() {
|
||||
SayHiFromFixturesAreFunctionalMain();
|
||||
void fixturesAreFunctionalMain() {
|
||||
sayHiFromFixturesAreFunctionalMain();
|
||||
}
|
||||
|
||||
void SayHiFromFixturesAreFunctionalMain() native "SayHiFromFixturesAreFunctionalMain";
|
||||
void sayHiFromFixturesAreFunctionalMain() native 'SayHiFromFixturesAreFunctionalMain';
|
||||
|
||||
void NotifyNative() native "NotifyNative";
|
||||
void notifyNative() native 'NotifyNative';
|
||||
|
||||
void secondaryIsolateMain(String message) {
|
||||
print("Secondary isolate got message: " + message);
|
||||
NotifyNative();
|
||||
print('Secondary isolate got message: ' + message);
|
||||
notifyNative();
|
||||
}
|
||||
|
||||
@pragma('vm:entry-point')
|
||||
void testCanLaunchSecondaryIsolate() {
|
||||
Isolate.spawn(secondaryIsolateMain, "Hello from root isolate.");
|
||||
NotifyNative();
|
||||
Isolate.spawn(secondaryIsolateMain, 'Hello from root isolate.');
|
||||
notifyNative();
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ void customEntrypoint() {
|
||||
sayHiFromCustomEntrypoint();
|
||||
}
|
||||
|
||||
void sayHiFromCustomEntrypoint() native "SayHiFromCustomEntrypoint";
|
||||
void sayHiFromCustomEntrypoint() native 'SayHiFromCustomEntrypoint';
|
||||
|
||||
|
||||
@pragma('vm:entry-point')
|
||||
@@ -19,9 +19,9 @@ void customEntrypoint1() {
|
||||
sayHiFromCustomEntrypoint3();
|
||||
}
|
||||
|
||||
void sayHiFromCustomEntrypoint1() native "SayHiFromCustomEntrypoint1";
|
||||
void sayHiFromCustomEntrypoint2() native "SayHiFromCustomEntrypoint2";
|
||||
void sayHiFromCustomEntrypoint3() native "SayHiFromCustomEntrypoint3";
|
||||
void sayHiFromCustomEntrypoint1() native 'SayHiFromCustomEntrypoint1';
|
||||
void sayHiFromCustomEntrypoint2() native 'SayHiFromCustomEntrypoint2';
|
||||
void sayHiFromCustomEntrypoint3() native 'SayHiFromCustomEntrypoint3';
|
||||
|
||||
|
||||
@pragma('vm:entry-point')
|
||||
@@ -51,16 +51,16 @@ void notifySemanticsAction(int nodeId, int action, List<int> data) native 'Notif
|
||||
|
||||
/// Returns a future that completes when `window.onSemanticsEnabledChanged`
|
||||
/// fires.
|
||||
Future get semanticsChanged {
|
||||
final Completer semanticsChanged = Completer();
|
||||
Future<void> get semanticsChanged {
|
||||
final Completer<void> semanticsChanged = Completer<void>();
|
||||
window.onSemanticsEnabledChanged = semanticsChanged.complete;
|
||||
return semanticsChanged.future;
|
||||
}
|
||||
|
||||
/// Returns a future that completes when `window.onAccessibilityFeaturesChanged`
|
||||
/// fires.
|
||||
Future get accessibilityFeaturesChanged {
|
||||
final Completer featuresChanged = Completer();
|
||||
Future<void> get accessibilityFeaturesChanged {
|
||||
final Completer<void> featuresChanged = Completer<void>();
|
||||
window.onAccessibilityFeaturesChanged = featuresChanged.complete;
|
||||
return featuresChanged.future;
|
||||
}
|
||||
@@ -73,7 +73,7 @@ class SemanticsActionData {
|
||||
}
|
||||
|
||||
Future<SemanticsActionData> get semanticsAction {
|
||||
final Completer actionReceived = Completer<SemanticsActionData>();
|
||||
final Completer<SemanticsActionData> actionReceived = Completer<SemanticsActionData>();
|
||||
window.onSemanticsAction = (int id, SemanticsAction action, ByteData args) {
|
||||
actionReceived.complete(SemanticsActionData(id, action, args));
|
||||
};
|
||||
@@ -81,7 +81,7 @@ Future<SemanticsActionData> get semanticsAction {
|
||||
}
|
||||
|
||||
@pragma('vm:entry-point')
|
||||
void a11y_main() async {
|
||||
void a11y_main() async { // ignore: non_constant_identifier_names
|
||||
// Return initial state (semantics disabled).
|
||||
notifySemanticsEnabled(window.semanticsEnabled);
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
class ShellProcess {
|
||||
final Completer<Uri> _observatoryUriCompleter = new Completer<Uri>();
|
||||
final Completer<Uri> _observatoryUriCompleter = Completer<Uri>();
|
||||
final Process _process;
|
||||
|
||||
ShellProcess(this._process) : assert(_process != null) {
|
||||
@@ -67,7 +67,7 @@ class ShellLauncher {
|
||||
shellArguments.addAll(args);
|
||||
print('Launching $shellExecutablePath $shellArguments');
|
||||
final Process process = await Process.start(shellExecutablePath, shellArguments);
|
||||
return new ShellProcess(process);
|
||||
return ShellProcess(process);
|
||||
} catch (e) {
|
||||
print('Error launching shell: $e');
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ class ServiceClient {
|
||||
'id': key,
|
||||
});
|
||||
client.add(request);
|
||||
final Completer<Map<String, dynamic>> completer = new Completer<Map<String, dynamic>>();
|
||||
final Completer<Map<String, dynamic>> completer = Completer<Map<String, dynamic>>();
|
||||
_outstandingRequests[key] = completer;
|
||||
print('-> $key ($method)');
|
||||
return completer.future;
|
||||
|
||||
@@ -48,8 +48,8 @@ class Expect {
|
||||
}
|
||||
|
||||
Future<String> readResponse(HttpClientResponse response) {
|
||||
final Completer<String> completer = new Completer<String>();
|
||||
final StringBuffer contents = new StringBuffer();
|
||||
final Completer<String> completer = Completer<String>();
|
||||
final StringBuffer contents = StringBuffer();
|
||||
response.transform(utf8.decoder).listen((String data) {
|
||||
contents.write(data);
|
||||
}, onDone: () => completer.complete(contents.toString()));
|
||||
@@ -59,7 +59,7 @@ Future<String> readResponse(HttpClientResponse response) {
|
||||
// Test accessing the service protocol over http.
|
||||
Future<Null> testHttpProtocolRequest(Uri uri) async {
|
||||
uri = uri.replace(path: 'getVM');
|
||||
final HttpClient client = new HttpClient();
|
||||
final HttpClient client = HttpClient();
|
||||
final HttpClientRequest request = await client.getUrl(uri);
|
||||
final HttpClientResponse response = await request.close();
|
||||
Expect.equals(response.statusCode, 200);
|
||||
@@ -72,7 +72,7 @@ Future<Null> testHttpProtocolRequest(Uri uri) async {
|
||||
Future<Null> testWebSocketProtocolRequest(Uri uri) async {
|
||||
uri = uri.replace(scheme: 'ws', path: 'ws');
|
||||
final WebSocket webSocketClient = await WebSocket.connect(uri.toString());
|
||||
final ServiceClient serviceClient = new ServiceClient(webSocketClient);
|
||||
final ServiceClient serviceClient = ServiceClient(webSocketClient);
|
||||
final Map<String, dynamic> response = await serviceClient.invokeRPC('getVM');
|
||||
Expect.equals(response['type'], 'VM');
|
||||
try {
|
||||
@@ -87,7 +87,7 @@ Future<Null> testWebSocketProtocolRequest(Uri uri) async {
|
||||
// Test accessing an Observatory UI asset.
|
||||
Future<Null> testHttpAssetRequest(Uri uri) async {
|
||||
uri = uri.replace(path: 'third_party/trace_viewer_full.html');
|
||||
final HttpClient client = new HttpClient();
|
||||
final HttpClient client = HttpClient();
|
||||
final HttpClientRequest request = await client.getUrl(uri);
|
||||
final HttpClientResponse response = await request.close();
|
||||
Expect.equals(response.statusCode, 200);
|
||||
@@ -98,10 +98,10 @@ Future<Null> testHttpAssetRequest(Uri uri) async {
|
||||
Future<Null> testStartPaused(Uri uri) async {
|
||||
uri = uri.replace(scheme: 'ws', path: 'ws');
|
||||
final WebSocket webSocketClient = await WebSocket.connect(uri.toString());
|
||||
final Completer<dynamic> isolateStartedId = new Completer<dynamic>();
|
||||
final Completer<dynamic> isolatePausedId = new Completer<dynamic>();
|
||||
final Completer<dynamic> isolateResumeId = new Completer<dynamic>();
|
||||
final ServiceClient serviceClient = new ServiceClient(webSocketClient,
|
||||
final Completer<dynamic> isolateStartedId = Completer<dynamic>();
|
||||
final Completer<dynamic> isolatePausedId = Completer<dynamic>();
|
||||
final Completer<dynamic> isolateResumeId = Completer<dynamic>();
|
||||
final ServiceClient serviceClient = ServiceClient(webSocketClient,
|
||||
isolateStartedId: isolateStartedId,
|
||||
isolatePausedId: isolatePausedId,
|
||||
isolateResumeId: isolateResumeId);
|
||||
@@ -187,13 +187,13 @@ Future<Null> main(List<String> args) async {
|
||||
final List<String> extraArgs = args.length <= 2 ? <String>[] : args.sublist(2);
|
||||
|
||||
final ShellLauncher launcher =
|
||||
new ShellLauncher(shellExecutablePath,
|
||||
ShellLauncher(shellExecutablePath,
|
||||
mainDartPath,
|
||||
false,
|
||||
extraArgs);
|
||||
|
||||
final ShellLauncher startPausedlauncher =
|
||||
new ShellLauncher(shellExecutablePath,
|
||||
ShellLauncher(shellExecutablePath,
|
||||
mainDartPath,
|
||||
true,
|
||||
extraArgs);
|
||||
|
||||
@@ -11,14 +11,14 @@ typedef CanvasCallback = void Function(Canvas canvas);
|
||||
|
||||
void testCanvas(CanvasCallback callback) {
|
||||
try {
|
||||
callback(Canvas(PictureRecorder(), Rect.fromLTRB(0.0, 0.0, 0.0, 0.0)));
|
||||
callback(Canvas(PictureRecorder(), const Rect.fromLTRB(0.0, 0.0, 0.0, 0.0)));
|
||||
} catch (error) { } // ignore: empty_catches
|
||||
}
|
||||
|
||||
void main() {
|
||||
test('canvas APIs should not crash', () async {
|
||||
final Paint paint = Paint();
|
||||
final Rect rect = Rect.fromLTRB(double.nan, double.nan, double.nan, double.nan);
|
||||
const Rect rect = Rect.fromLTRB(double.nan, double.nan, double.nan, double.nan);
|
||||
final RRect rrect = RRect.fromRectAndCorners(rect);
|
||||
const Offset offset = Offset(double.nan, double.nan);
|
||||
final Path path = Path();
|
||||
|
||||
@@ -21,7 +21,7 @@ void main() {
|
||||
|
||||
test('paint set to black', () {
|
||||
const Color c = Color(0x00000000);
|
||||
final Paint p = new Paint();
|
||||
final Paint p = Paint();
|
||||
p.color = c;
|
||||
expect(c.toString(), equals('Color(0x00000000)'));
|
||||
});
|
||||
@@ -29,7 +29,7 @@ void main() {
|
||||
test('color created with out of bounds value', () {
|
||||
try {
|
||||
const Color c = Color(0x100 << 24);
|
||||
final Paint p = new Paint();
|
||||
final Paint p = Paint();
|
||||
p.color = c;
|
||||
} catch (e) {
|
||||
expect(e != null, equals(true));
|
||||
@@ -39,7 +39,7 @@ void main() {
|
||||
test('color created with wildly out of bounds value', () {
|
||||
try {
|
||||
const Color c = Color(1 << 1000000);
|
||||
final Paint p = new Paint();
|
||||
final Paint p = Paint();
|
||||
p.color = c;
|
||||
} catch (e) {
|
||||
expect(e != null, equals(true));
|
||||
|
||||
@@ -47,7 +47,7 @@ void main() {
|
||||
0, 0, 0, double.infinity,
|
||||
]);
|
||||
expect(
|
||||
() => builder.pushTransform(matrix4NaN),
|
||||
() => builder.pushTransform(matrix4Infinity),
|
||||
throwsA(const TypeMatcher<AssertionError>()),
|
||||
);
|
||||
});
|
||||
|
||||
@@ -9,7 +9,7 @@ import 'package:test/test.dart';
|
||||
void main() {
|
||||
test('Gradient.radial with no focal point', () {
|
||||
expect(
|
||||
new Gradient.radial(
|
||||
Gradient.radial(
|
||||
Offset.zero,
|
||||
null,
|
||||
<Color>[const Color(0xFFFFFFFF), const Color(0xFFFFFFFF)],
|
||||
@@ -23,7 +23,7 @@ void main() {
|
||||
test('radial center and focal == Offset.zero and focalRadius == 0.0 is ok',
|
||||
() {
|
||||
expect(
|
||||
() => new Gradient.radial(
|
||||
() => Gradient.radial(
|
||||
Offset.zero,
|
||||
0.0,
|
||||
<Color>[const Color(0xFFFFFFFF), const Color(0xFFFFFFFF)],
|
||||
@@ -38,7 +38,7 @@ void main() {
|
||||
|
||||
test('radial center != focal and focalRadius == 0.0 is ok', () {
|
||||
expect(
|
||||
() => new Gradient.radial(
|
||||
() => Gradient.radial(
|
||||
Offset.zero,
|
||||
0.0,
|
||||
<Color>[const Color(0xFFFFFFFF), const Color(0xFFFFFFFF)],
|
||||
@@ -55,7 +55,7 @@ void main() {
|
||||
test('radial center and focal == Offset.zero and focalRadius != 0.0 assert',
|
||||
() {
|
||||
expect(
|
||||
() => new Gradient.radial(
|
||||
() => Gradient.radial(
|
||||
Offset.zero,
|
||||
0.0,
|
||||
<Color>[const Color(0xFFFFFFFF), const Color(0xFFFFFFFF)],
|
||||
|
||||
@@ -9,37 +9,31 @@ import 'package:test/test.dart';
|
||||
|
||||
void main() {
|
||||
test('path getBounds', () {
|
||||
final Rect r = new Rect.fromLTRB(1.0, 3.0, 5.0, 7.0);
|
||||
final Path p = new Path()..addRect(r);
|
||||
const Rect r = Rect.fromLTRB(1.0, 3.0, 5.0, 7.0);
|
||||
final Path p = Path()..addRect(r);
|
||||
expect(p.getBounds(), equals(r));
|
||||
p.lineTo(20.0, 15.0);
|
||||
expect(p.getBounds(), equals(new Rect.fromLTRB(1.0, 3.0, 20.0, 15.0)));
|
||||
expect(p.getBounds(), equals(const Rect.fromLTRB(1.0, 3.0, 20.0, 15.0)));
|
||||
});
|
||||
|
||||
test('path combine rect', () {
|
||||
final Rect c1 =
|
||||
new Rect.fromCircle(center: const Offset(10.0, 10.0), radius: 10.0);
|
||||
final Rect c2 =
|
||||
new Rect.fromCircle(center: const Offset(5.0, 5.0), radius: 10.0);
|
||||
final Rect c1 = Rect.fromCircle(center: const Offset(10.0, 10.0), radius: 10.0);
|
||||
final Rect c2 = Rect.fromCircle(center: const Offset(5.0, 5.0), radius: 10.0);
|
||||
final Rect c1UnionC2 = c1.expandToInclude(c2);
|
||||
final Rect c1IntersectC2 = c1.intersect(c2);
|
||||
final Path pathCircle1 = new Path()..addRect(c1);
|
||||
final Path pathCircle2 = new Path()..addRect(c2);
|
||||
final Path pathCircle1 = Path()..addRect(c1);
|
||||
final Path pathCircle2 = Path()..addRect(c2);
|
||||
|
||||
final Path difference =
|
||||
Path.combine(PathOperation.difference, pathCircle1, pathCircle2);
|
||||
final Path difference = Path.combine(PathOperation.difference, pathCircle1, pathCircle2);
|
||||
expect(difference.getBounds(), equals(c1));
|
||||
|
||||
final Path reverseDifference =
|
||||
Path.combine(PathOperation.reverseDifference, pathCircle1, pathCircle2);
|
||||
final Path reverseDifference = Path.combine(PathOperation.reverseDifference, pathCircle1, pathCircle2);
|
||||
expect(reverseDifference.getBounds(), equals(c2));
|
||||
|
||||
final Path union =
|
||||
Path.combine(PathOperation.union, pathCircle1, pathCircle2);
|
||||
final Path union = Path.combine(PathOperation.union, pathCircle1, pathCircle2);
|
||||
expect(union.getBounds(), equals(c1UnionC2));
|
||||
|
||||
final Path intersect =
|
||||
Path.combine(PathOperation.intersect, pathCircle1, pathCircle2);
|
||||
final Path intersect = Path.combine(PathOperation.intersect, pathCircle1, pathCircle2);
|
||||
expect(intersect.getBounds(), equals(c1IntersectC2));
|
||||
|
||||
// the bounds on this will be the same as union - but would draw a missing inside piece.
|
||||
@@ -48,31 +42,24 @@ void main() {
|
||||
});
|
||||
|
||||
test('path combine oval', () {
|
||||
final Rect c1 =
|
||||
new Rect.fromCircle(center: const Offset(10.0, 10.0), radius: 10.0);
|
||||
final Rect c2 =
|
||||
new Rect.fromCircle(center: const Offset(5.0, 5.0), radius: 10.0);
|
||||
final Rect c1 = Rect.fromCircle(center: const Offset(10.0, 10.0), radius: 10.0);
|
||||
final Rect c2 = Rect.fromCircle(center: const Offset(5.0, 5.0), radius: 10.0);
|
||||
final Rect c1UnionC2 = c1.expandToInclude(c2);
|
||||
final Rect c1IntersectC2 = c1.intersect(c2);
|
||||
final Path pathCircle1 = new Path()..addOval(c1);
|
||||
final Path pathCircle2 = new Path()..addOval(c2);
|
||||
final Path pathCircle1 = Path()..addOval(c1);
|
||||
final Path pathCircle2 = Path()..addOval(c2);
|
||||
|
||||
final Path difference =
|
||||
Path.combine(PathOperation.difference, pathCircle1, pathCircle2);
|
||||
final Path difference = Path.combine(PathOperation.difference, pathCircle1, pathCircle2);
|
||||
|
||||
expect(difference.getBounds().top, closeTo(0.88, 0.01));
|
||||
|
||||
final Path reverseDifference =
|
||||
Path.combine(PathOperation.reverseDifference, pathCircle1, pathCircle2);
|
||||
expect(reverseDifference.getBounds().right,
|
||||
closeTo(14.11, 0.01));
|
||||
final Path reverseDifference = Path.combine(PathOperation.reverseDifference, pathCircle1, pathCircle2);
|
||||
expect(reverseDifference.getBounds().right, closeTo(14.11, 0.01));
|
||||
|
||||
final Path union =
|
||||
Path.combine(PathOperation.union, pathCircle1, pathCircle2);
|
||||
final Path union = Path.combine(PathOperation.union, pathCircle1, pathCircle2);
|
||||
expect(union.getBounds(), equals(c1UnionC2));
|
||||
|
||||
final Path intersect =
|
||||
Path.combine(PathOperation.intersect, pathCircle1, pathCircle2);
|
||||
final Path intersect = Path.combine(PathOperation.intersect, pathCircle1, pathCircle2);
|
||||
expect(intersect.getBounds(), equals(c1IntersectC2));
|
||||
|
||||
// the bounds on this will be the same as union - but would draw a missing inside piece.
|
||||
@@ -81,8 +68,8 @@ void main() {
|
||||
});
|
||||
|
||||
test('path clone', () {
|
||||
final Path p1 = new Path()..lineTo(20.0, 20.0);
|
||||
final Path p2 = new Path.from(p1);
|
||||
final Path p1 = Path()..lineTo(20.0, 20.0);
|
||||
final Path p2 = Path.from(p1);
|
||||
|
||||
expect(p1.getBounds(), equals(p2.getBounds()));
|
||||
|
||||
@@ -91,8 +78,8 @@ void main() {
|
||||
});
|
||||
|
||||
test('transformation tests', () {
|
||||
final Rect bounds = new Rect.fromLTRB(0.0, 0.0, 10.0, 10.0);
|
||||
final Path p = new Path()..addRect(bounds);
|
||||
const Rect bounds = Rect.fromLTRB(0.0, 0.0, 10.0, 10.0);
|
||||
final Path p = Path()..addRect(bounds);
|
||||
final Float64List scaleMatrix = Float64List.fromList(<double>[
|
||||
2.5, 0.0, 0.0, 0.0, // first col
|
||||
0.0, 0.5, 0.0, 0.0, // second col
|
||||
@@ -104,41 +91,37 @@ void main() {
|
||||
final Path pTransformed = p.transform(scaleMatrix);
|
||||
|
||||
expect(pTransformed.getBounds(),
|
||||
equals(new Rect.fromLTRB(0.0, 0.0, 10 * 2.5, 10 * 0.5)));
|
||||
equals(const Rect.fromLTRB(0.0, 0.0, 10 * 2.5, 10 * 0.5)));
|
||||
|
||||
final Path p2 = new Path()..lineTo(10.0, 10.0);
|
||||
final Path p2 = Path()..lineTo(10.0, 10.0);
|
||||
|
||||
p.addPath(p2, const Offset(10.0, 10.0));
|
||||
expect(p.getBounds(), equals(new Rect.fromLTRB(0.0, 0.0, 20.0, 20.0)));
|
||||
expect(p.getBounds(), equals(const Rect.fromLTRB(0.0, 0.0, 20.0, 20.0)));
|
||||
|
||||
p.addPath(p2, const Offset(20.0, 20.0), matrix4: scaleMatrix);
|
||||
expect(p.getBounds(),
|
||||
equals(new Rect.fromLTRB(0.0, 0.0, 20 + (10 * 2.5), 20 + (10 * .5))));
|
||||
equals(const Rect.fromLTRB(0.0, 0.0, 20 + (10 * 2.5), 20 + (10 * .5))));
|
||||
|
||||
p.extendWithPath(p2, const Offset(0.0, 0.0));
|
||||
expect(p.getBounds(), equals(new Rect.fromLTRB(0.0, 0.0, 45.0, 25.0)));
|
||||
expect(p.getBounds(), equals(const Rect.fromLTRB(0.0, 0.0, 45.0, 25.0)));
|
||||
|
||||
p.extendWithPath(p2, const Offset(45.0, 25.0), matrix4: scaleMatrix);
|
||||
expect(p.getBounds(), equals(new Rect.fromLTRB(0.0, 0.0, 70.0, 30.0)));
|
||||
expect(p.getBounds(), equals(const Rect.fromLTRB(0.0, 0.0, 70.0, 30.0)));
|
||||
});
|
||||
|
||||
test('path metrics tests', () {
|
||||
final Path simpleHorizontalLine = new Path()..lineTo(10.0, 0.0);
|
||||
final Path simpleHorizontalLine = Path()..lineTo(10.0, 0.0);
|
||||
|
||||
// basic tests on horizontal line
|
||||
final PathMetrics simpleHorizontalMetrics =
|
||||
simpleHorizontalLine.computeMetrics();
|
||||
final PathMetrics simpleHorizontalMetrics = simpleHorizontalLine.computeMetrics();
|
||||
expect(simpleHorizontalMetrics.iterator.current, isNull);
|
||||
expect(simpleHorizontalMetrics.iterator.moveNext(), isTrue);
|
||||
expect(simpleHorizontalMetrics.iterator.current, isNotNull);
|
||||
expect(simpleHorizontalMetrics.iterator.current.length, equals(10.0));
|
||||
expect(simpleHorizontalMetrics.iterator.current.isClosed, isFalse);
|
||||
final Path simpleExtract =
|
||||
simpleHorizontalMetrics.iterator.current.extractPath(1.0, 9.0);
|
||||
expect(simpleExtract.getBounds(),
|
||||
equals(new Rect.fromLTRB(1.0, 0.0, 9.0, 0.0)));
|
||||
final Tangent posTan =
|
||||
simpleHorizontalMetrics.iterator.current.getTangentForOffset(1.0);
|
||||
final Path simpleExtract = simpleHorizontalMetrics.iterator.current.extractPath(1.0, 9.0);
|
||||
expect(simpleExtract.getBounds(), equals(const Rect.fromLTRB(1.0, 0.0, 9.0, 0.0)));
|
||||
final Tangent posTan = simpleHorizontalMetrics.iterator.current.getTangentForOffset(1.0);
|
||||
expect(posTan, isNotNull);
|
||||
expect(posTan.position, equals(const Offset(1.0, 0.0)));
|
||||
expect(posTan.angle, equals(0.0));
|
||||
@@ -147,43 +130,33 @@ void main() {
|
||||
expect(simpleHorizontalMetrics.iterator.current, isNull);
|
||||
|
||||
// test with forceClosed
|
||||
final PathMetrics simpleMetricsClosed =
|
||||
simpleHorizontalLine.computeMetrics(forceClosed: true);
|
||||
final PathMetrics simpleMetricsClosed = simpleHorizontalLine.computeMetrics(forceClosed: true);
|
||||
expect(simpleMetricsClosed.iterator.current, isNull);
|
||||
expect(simpleMetricsClosed.iterator.moveNext(), isTrue);
|
||||
expect(simpleMetricsClosed.iterator.current, isNotNull);
|
||||
expect(simpleMetricsClosed.iterator.current.length,
|
||||
equals(20.0)); // because we forced close
|
||||
expect(simpleMetricsClosed.iterator.current.length, equals(20.0)); // because we forced close
|
||||
expect(simpleMetricsClosed.iterator.current.isClosed, isTrue);
|
||||
final Path simpleExtract2 =
|
||||
simpleMetricsClosed.iterator.current.extractPath(1.0, 9.0);
|
||||
expect(simpleExtract2.getBounds(),
|
||||
equals(new Rect.fromLTRB(1.0, 0.0, 9.0, 0.0)));
|
||||
final Path simpleExtract2 = simpleMetricsClosed.iterator.current.extractPath(1.0, 9.0);
|
||||
expect(simpleExtract2.getBounds(), equals(const Rect.fromLTRB(1.0, 0.0, 9.0, 0.0)));
|
||||
expect(simpleMetricsClosed.iterator.moveNext(), isFalse);
|
||||
|
||||
// test getTangentForOffset with vertical line
|
||||
final Path simpleVerticalLine = new Path()..lineTo(0.0, 10.0);
|
||||
final PathMetrics simpleMetricsVertical =
|
||||
simpleVerticalLine.computeMetrics()..iterator.moveNext();
|
||||
final Tangent posTanVertical =
|
||||
simpleMetricsVertical.iterator.current.getTangentForOffset(5.0);
|
||||
final Path simpleVerticalLine = Path()..lineTo(0.0, 10.0);
|
||||
final PathMetrics simpleMetricsVertical = simpleVerticalLine.computeMetrics()..iterator.moveNext();
|
||||
final Tangent posTanVertical = simpleMetricsVertical.iterator.current.getTangentForOffset(5.0);
|
||||
expect(posTanVertical.position, equals(const Offset(0.0, 5.0)));
|
||||
expect(posTanVertical.angle,
|
||||
closeTo(-1.5708, .0001)); // 90 degrees
|
||||
expect(posTanVertical.angle, closeTo(-1.5708, .0001)); // 90 degrees
|
||||
|
||||
// test getTangentForOffset with diagonal line
|
||||
final Path simpleDiagonalLine = new Path()..lineTo(10.0, 10.0);
|
||||
final PathMetrics simpleMetricsDiagonal =
|
||||
simpleDiagonalLine.computeMetrics()..iterator.moveNext();
|
||||
final Path simpleDiagonalLine = Path()..lineTo(10.0, 10.0);
|
||||
final PathMetrics simpleMetricsDiagonal = simpleDiagonalLine.computeMetrics()..iterator.moveNext();
|
||||
final double midPoint = simpleMetricsDiagonal.iterator.current.length / 2;
|
||||
final Tangent posTanDiagonal =
|
||||
simpleMetricsDiagonal.iterator.current.getTangentForOffset(midPoint);
|
||||
final Tangent posTanDiagonal = simpleMetricsDiagonal.iterator.current.getTangentForOffset(midPoint);
|
||||
expect(posTanDiagonal.position, equals(const Offset(5.0, 5.0)));
|
||||
expect(posTanDiagonal.angle,
|
||||
closeTo(-0.7853981633974483, .00001)); // ~45 degrees
|
||||
expect(posTanDiagonal.angle, closeTo(-0.7853981633974483, .00001)); // ~45 degrees
|
||||
|
||||
// test a multi-contour path
|
||||
final Path multiContour = new Path()
|
||||
final Path multiContour = Path()
|
||||
..lineTo(0.0, 10.0)
|
||||
..moveTo(10.0, 10.0)
|
||||
..lineTo(10.0, 15.0);
|
||||
|
||||
@@ -159,7 +159,7 @@ void main() {
|
||||
};
|
||||
});
|
||||
|
||||
final ByteData testData = new ByteData.view(new Uint8List(0).buffer);
|
||||
final ByteData testData = ByteData.view(Uint8List(0).buffer);
|
||||
_dispatchPointerDataPacket(testData);
|
||||
expect(runZone, isNotNull);
|
||||
expect(runZone, same(innerZone));
|
||||
|
||||
@@ -12,7 +12,7 @@ void main() {
|
||||
test('window.sendPlatformMessage preserves callback zone', () {
|
||||
runZoned(() {
|
||||
final Zone innerZone = Zone.current;
|
||||
window.sendPlatformMessage('test', new ByteData.view(new Uint8List(0).buffer), expectAsync1((ByteData data) {
|
||||
window.sendPlatformMessage('test', ByteData.view(Uint8List(0).buffer), expectAsync1((ByteData data) {
|
||||
final Zone runZone = Zone.current;
|
||||
expect(runZone, isNotNull);
|
||||
expect(runZone, same(innerZone));
|
||||
|
||||
@@ -59,6 +59,8 @@ pushd "$BUILDROOT_DIR/flutter/testing/dart"
|
||||
"$HOST_DIR/dart-sdk/bin/pub" get
|
||||
popd
|
||||
|
||||
"$HOST_DIR/dart" --version
|
||||
|
||||
run_test () {
|
||||
"$HOST_DIR/dart" $HOST_DIR/gen/frontend_server.dart.snapshot \
|
||||
--sdk-root $HOST_DIR/flutter_patched_sdk \
|
||||
|
||||
@@ -32,12 +32,12 @@ void main(List<String> arguments) {
|
||||
} else if (Platform.isMacOS) {
|
||||
platform = 'mac-x64';
|
||||
} else {
|
||||
throw new UnimplementedError('Script only support running on Linux or MacOS.');
|
||||
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());
|
||||
|
||||
final Iterable<String> releaseBuilds = new Directory(outPath).listSync()
|
||||
final Iterable<String> releaseBuilds = Directory(outPath).listSync()
|
||||
.where((FileSystemEntity entity) => entity is Directory)
|
||||
.map<String>((FileSystemEntity dir) => p.basename(dir.path))
|
||||
.where((String s) => s.contains('_release'));
|
||||
@@ -101,16 +101,16 @@ int _checkAndroid(String outPath, String nmPath, Iterable<String> builds) {
|
||||
continue;
|
||||
}
|
||||
final Iterable<NmEntry> entries = NmEntry.parse(nmResult.stdout);
|
||||
final Map<String, String> entryMap = Map.fromIterable(
|
||||
final Map<String, String> entryMap = Map<String, String>.fromIterable(
|
||||
entries,
|
||||
key: (entry) => entry.name,
|
||||
value: (entry) => entry.type);
|
||||
final Map<String, String> expectedSymbols = {
|
||||
key: (dynamic entry) => entry.name,
|
||||
value: (dynamic entry) => entry.type);
|
||||
final Map<String, String> expectedSymbols = <String, String>{
|
||||
'JNI_OnLoad': 'T',
|
||||
'_binary_icudtl_dat_size': 'A',
|
||||
'_binary_icudtl_dat_start': 'D',
|
||||
};
|
||||
if (!MapEquality<String, String>().equals(entryMap, expectedSymbols)) {
|
||||
if (!const MapEquality<String, String>().equals(entryMap, expectedSymbols)) {
|
||||
print('ERROR: $libFlutter exports the wrong symbols');
|
||||
print(' Expected $expectedSymbols');
|
||||
print(' Library has $entryMap.');
|
||||
@@ -132,7 +132,7 @@ class NmEntry {
|
||||
static Iterable<NmEntry> parse(String stdout) {
|
||||
return LineSplitter.split(stdout).map((String line) {
|
||||
final List<String> parts = line.split(' ');
|
||||
return new NmEntry._(parts[0], parts[1], parts.last);
|
||||
return NmEntry._(parts[0], parts[1], parts.last);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ Map<String, List<String>> parseSection(String section) {
|
||||
}
|
||||
|
||||
Future<Null> main() async {
|
||||
final HttpClient client = new HttpClient();
|
||||
final HttpClient client = HttpClient();
|
||||
final String body = (await (await (await client.getUrl(Uri.parse(registry))).close()).transform(utf8.decoder).toList()).join('');
|
||||
final List<Map<String, List<String>>> sections = body.split('%%').map<Map<String, List<String>>>(parseSection).toList();
|
||||
final Map<String, List<String>> outputs = <String, List<String>>{'language': <String>[], 'region': <String>[]};
|
||||
|
||||
Reference in New Issue
Block a user