From f3f005c457d85b5b7f6d50bf515bb84fba236e38 Mon Sep 17 00:00:00 2001 From: Ian Hickson Date: Wed, 17 Jan 2018 09:48:56 -0800 Subject: [PATCH] Analysis cleanup of the Dart in the Engine repo (#4554) * Analysis cleanup of the Dart in the Engine repo * Update painting.dart * Update painting.dart --- .travis.yml | 2 +- analysis_options.yaml | 99 ++-- frontend_server/.gitignore | 3 + frontend_server/.packages | 52 -- frontend_server/lib/server.dart | 14 +- frontend_server/test/server_test.dart | 4 +- lib/ui/compositing.dart | 52 +- lib/ui/geometry.dart | 6 + lib/ui/hooks.dart | 10 +- lib/ui/lerp.dart | 6 +- lib/ui/natives.dart | 8 +- lib/ui/painting.dart | 612 +++++++++++++++----- lib/ui/semantics.dart | 44 +- lib/ui/text.dart | 157 ++--- lib/ui/window.dart | 12 +- tools/licenses/lib/cache.dart | 4 +- tools/licenses/lib/filesystem.dart | 4 +- tools/licenses/lib/main.dart | 2 +- tools/licenses/pubspec.lock | 20 +- tools/licenses/pubspec.yaml | 2 +- travis/analyze.sh | 53 +- travis/licenses_golden/licenses_flutter | 1 - travis/licenses_golden/licenses_third_party | 6 +- 23 files changed, 731 insertions(+), 442 deletions(-) create mode 100644 frontend_server/.gitignore delete mode 100644 frontend_server/.packages diff --git a/.travis.yml b/.travis.yml index 0e4a765fae4..92f36683d65 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: dart dart: - - "dev/release/1.25.0-dev.11.0" + - dev sudo: false before_script: - ./travis/setup.sh diff --git a/analysis_options.yaml b/analysis_options.yaml index 48fbcdd36b9..a0bdf532504 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -1,13 +1,18 @@ # Specify analysis options. # -# This file is a copy of analysis_options_repo.yaml from flutter repo: -# https://github.com/flutter/flutter/blob/master/analysis_options_repo.yaml +# This file is a copy of analysis_options_repo.yaml from flutter repo +# as of 2018-01-07, but with "sort_constructors_first" disabled +# (because we have private fake constructors), with +# "always_require_non_null_named_parameters" disabled (because we +# can't import the meta package from the SDK), and with +# "prefer_final_fields" disabled (because we do weird things with +# private fields, especially on the Window object): +# https://github.com/lfutter/flutter/blob/master/analysis_options_repo.yaml analyzer: language: enableStrictCallChecks: true enableSuperMixins: true - enableAssertInitializer: true strong-mode: implicit-dynamic: false errors: @@ -22,88 +27,90 @@ linter: rules: # these rules are documented on and in the same order as # the Dart Lint rules page to make maintenance easier - # http://dart-lang.github.io/linter/lints/ - - # === error rules === - - avoid_empty_else - - avoid_slow_async_io - - cancel_subscriptions - # - close_sinks # https://github.com/flutter/flutter/issues/5789 - # - comment_references # blocked on https://github.com/dart-lang/dartdoc/issues/1153 - - control_flow_in_finally - - empty_statements - - hash_and_equals - # - invariant_booleans # https://github.com/flutter/flutter/issues/5790 - - iterable_contains_unrelated_type - - list_remove_unrelated_type - # - literal_only_boolean_expressions # https://github.com/flutter/flutter/issues/5791 - - no_adjacent_strings_in_list - - no_duplicate_case_values - - test_types_in_equals - - throw_in_finally - - unrelated_type_equality_checks - - valid_regexps - - # === style rules === + # https://github.com/dart-lang/linter/blob/master/example/all.yaml - always_declare_return_types - always_put_control_body_on_new_line - - always_require_non_null_named_parameters + # - always_put_required_named_parameters_first # we prefer having parameters in the same order as fields https://github.com/flutter/flutter/issues/10219 + # always_require_non_null_named_parameters - always_specify_types - annotate_overrides - # - avoid_annotating_with_dynamic # not yet tested + # - avoid_annotating_with_dynamic # conflicts with always_specify_types - avoid_as - # - avoid_catches_without_on_clauses # not yet tested - # - avoid_catching_errors # not yet tested - # - avoid_classes_with_only_static_members # not yet tested - # - avoid_function_literals_in_foreach_calls # not yet tested + # - avoid_catches_without_on_clauses # we do this commonly + # - avoid_catching_errors # we do this commonly + - avoid_classes_with_only_static_members + - avoid_empty_else + - avoid_function_literals_in_foreach_calls - avoid_init_to_null - avoid_null_checks_in_equality_operators # - avoid_positional_boolean_parameters # not yet tested - avoid_return_types_on_setters - # - avoid_returning_null # not yet tested - # - avoid_returning_this # not yet tested + # - avoid_returning_null # we do this commonly + # - avoid_returning_this # https://github.com/dart-lang/linter/issues/842 # - avoid_setters_without_getters # not yet tested - # - avoid_types_on_closure_parameters # not yet tested + - avoid_slow_async_io + # - avoid_types_on_closure_parameters # conflicts with always_specify_types + # - avoid_unused_constructor_parameters # https://github.com/dart-lang/linter/pull/847 - await_only_futures - camel_case_types + - cancel_subscriptions # - cascade_invocations # not yet tested + # - close_sinks # https://github.com/flutter/flutter/issues/5789 + # - comment_references # blocked on https://github.com/dart-lang/dartdoc/issues/1153 # - constant_identifier_names # https://github.com/dart-lang/linter/issues/204 + - control_flow_in_finally - directives_ordering - empty_catches - empty_constructor_bodies + - empty_statements + - hash_and_equals - implementation_imports + # - invariant_booleans # https://github.com/flutter/flutter/issues/5790 + - iterable_contains_unrelated_type # - join_return_with_assignment # not yet tested - library_names - library_prefixes + - list_remove_unrelated_type + # - literal_only_boolean_expressions # https://github.com/flutter/flutter/issues/5791 + - no_adjacent_strings_in_list + - no_duplicate_case_values - non_constant_identifier_names # - omit_local_variable_types # opposite of always_specify_types # - one_member_abstracts # too many false positives # - only_throw_errors # https://github.com/flutter/flutter/issues/5792 - overridden_fields - package_api_docs + - package_names - package_prefixed_library_names # - parameter_assignments # we do this commonly - prefer_adjacent_string_concatenation + - prefer_asserts_in_initializer_lists + # - prefer_bool_in_asserts # not yet tested - prefer_collection_literals - # - prefer_conditional_assignment # not yet tested - # - prefer_const_constructors # https://github.com/dart-lang/linter/issues/752 + - prefer_conditional_assignment + - prefer_const_constructors + - prefer_const_constructors_in_immutables # - prefer_constructors_over_static_methods # not yet tested - prefer_contains # - 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 # https://github.com/dart-lang/linter/issues/506 + # - prefer_final_fields - prefer_final_locals - # - prefer_foreach # not yet tested + - prefer_foreach # - prefer_function_declarations_over_variables # not yet tested - prefer_initializing_formals # - prefer_interpolation_to_compose_strings # not yet tested - prefer_is_empty - prefer_is_not_empty - - public_member_api_docs # this is the only difference from analysis_options_repo.yaml - # - recursive_getters # https://github.com/dart-lang/linter/issues/452 + - prefer_single_quotes + - prefer_typing_uninitialized_variables + - public_member_api_docs # this is the only difference from analysis_options.yaml + - recursive_getters - slash_for_doc_comments - - sort_constructors_first + # - sort_constructors_first - 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 @@ -112,12 +119,12 @@ linter: # - unnecessary_lambdas # https://github.com/dart-lang/linter/issues/498 - unnecessary_null_aware_assignments - unnecessary_null_in_if_null_operators - # - unnecessary_overrides # https://github.com/dart-lang/linter/issues/626 and https://github.com/dart-lang/linter/issues/627 + - unnecessary_overrides + # - unnecessary_statements # not yet tested - unnecessary_this + - unrelated_type_equality_checks - use_rethrow_when_possible # - use_setters_to_change_properties # not yet tested # - use_string_buffers # https://github.com/dart-lang/linter/pull/664 # - use_to_and_as_if_applicable # has false positives, so we prefer to catch this by code-review - - # === pub rules === - - package_names + - valid_regexps diff --git a/frontend_server/.gitignore b/frontend_server/.gitignore new file mode 100644 index 00000000000..83f649232aa --- /dev/null +++ b/frontend_server/.gitignore @@ -0,0 +1,3 @@ +*.dill +pubspec.lock +.packages diff --git a/frontend_server/.packages b/frontend_server/.packages deleted file mode 100644 index d75e7e56bf4..00000000000 --- a/frontend_server/.packages +++ /dev/null @@ -1,52 +0,0 @@ -# Generated by pub on 2017-08-22 07:05:11.485224. -analyzer:../../third_party/dart/pkg/analyzer/lib/ -args:../../third_party/dart/third_party/pkg/args/lib/ -async:../../third_party/dart/third_party/pkg/async/lib/ -barback:../../third_party/dart/third_party/pkg/barback/lib/ -boolean_selector:../../third_party/dart/third_party/pkg/boolean_selector/lib/ -charcode:../../third_party/dart/third_party/pkg/charcode/lib/ -cli_util:../../third_party/dart/third_party/pkg/cli_util/lib/ -collection:../../third_party/dart/third_party/pkg/collection/lib/ -convert:../../third_party/dart/third_party/pkg/convert/lib/ -crypto:../../third_party/dart/third_party/pkg/crypto/lib/ -csslib:../../third_party/dart/third_party/pkg/csslib/lib/ -front_end:../../third_party/dart/pkg/front_end/lib/ -glob:../../third_party/dart/third_party/pkg/glob/lib/ -html:../../third_party/dart/third_party/pkg/html/lib/ -http:../../third_party/dart/third_party/pkg/http/lib/ -http_multi_server:../../third_party/dart/third_party/pkg/http_multi_server/lib/ -http_parser:../../third_party/dart/third_party/pkg/http_parser/lib/ -isolate:../../third_party/dart/third_party/pkg/isolate/lib/ -kernel:../../third_party/dart/pkg/kernel/lib/ -logging:../../third_party/dart/third_party/pkg/logging/lib/ -matcher:../../third_party/dart/third_party/pkg/matcher/lib/ -meta:../../third_party/dart/pkg/meta/lib/ -mime:../../third_party/dart/third_party/pkg/mime/lib/ -mockito:../../third_party/dart/third_party/pkg/mockito/lib/ -package_config:../../third_party/dart/third_party/pkg_tested/package_config/lib/ -package_resolver:../../third_party/dart/third_party/pkg_tested/package_resolver/lib/ -path:../../third_party/dart/third_party/pkg/path/lib/ -plugin:../../third_party/dart/third_party/pkg/plugin/lib/ -pool:../../third_party/dart/third_party/pkg/pool/lib/ -pub_semver:../../third_party/dart/third_party/pkg/pub_semver/lib/ -quiver:../../third_party/dart/third_party/pkg/quiver/lib/ -shelf:../../third_party/dart/third_party/pkg/shelf/lib/ -shelf_packages_handler:../../third_party/dart/third_party/pkg/shelf_packages_handler/lib/ -shelf_static:../../third_party/dart/third_party/pkg/shelf_static/lib/ -shelf_web_socket:../../third_party/dart/third_party/pkg/shelf_web_socket/lib/ -source_map_stack_trace:../../third_party/dart/third_party/pkg/source_map_stack_trace/lib/ -source_maps:../../third_party/dart/third_party/pkg/source_maps/lib/ -source_span:../../third_party/dart/third_party/pkg/source_span/lib/ -stack_trace:../../third_party/dart/third_party/pkg/stack_trace/lib/ -stream_channel:../../third_party/dart/third_party/pkg/stream_channel/lib/ -string_scanner:../../third_party/dart/third_party/pkg/string_scanner/lib/ -test:../../third_party/dart/third_party/pkg/test/lib/ -typed_data:../../third_party/dart/third_party/pkg/typed_data/lib/ -usage:../../third_party/dart/third_party/pkg/usage/lib/ -utf:../../third_party/dart/third_party/pkg/utf/lib/ -vm:../../third_party/dart/pkg/vm/lib/ -watcher:../../third_party/dart/third_party/pkg/watcher/lib/ -web_socket_channel:../../third_party/dart/third_party/pkg/web_socket_channel/lib/ -when:../../third_party/pkg/when/lib/ -yaml:../../third_party/dart/third_party/pkg/yaml/lib/ -frontend_server:lib/ diff --git a/frontend_server/lib/server.dart b/frontend_server/lib/server.dart index 40906c23e29..2b3ba441268 100644 --- a/frontend_server/lib/server.dart +++ b/frontend_server/lib/server.dart @@ -140,9 +140,9 @@ class _FrontendCompiler implements CompilerInterface { IncrementalKernelGenerator generator, }) async { final Uri filenameUri = Uri.base.resolveUri(new Uri.file(filename)); - _kernelBinaryFilename = "$filename.dill"; + _kernelBinaryFilename = '$filename.dill'; final String boundaryKey = new Uuid().generateV4(); - _outputStream.writeln("result $boundaryKey"); + _outputStream.writeln('result $boundaryKey'); final Uri sdkRoot = _ensureFolderPath(options['sdk-root']); final String byteStorePath = options['byte-store']; final CompilerOptions compilerOptions = new CompilerOptions() @@ -182,7 +182,7 @@ class _FrontendCompiler implements CompilerInterface { final BinaryPrinter printer = printerFactory.newBinaryPrinter(sink); printer.writeProgramFile(program); await sink.close(); - _outputStream.writeln("$boundaryKey $_kernelBinaryFilename"); + _outputStream.writeln('$boundaryKey $_kernelBinaryFilename'); } else _outputStream.writeln(boundaryKey); return null; @@ -191,13 +191,13 @@ class _FrontendCompiler implements CompilerInterface { @override Future recompileDelta() async { final String boundaryKey = new Uuid().generateV4(); - _outputStream.writeln("result $boundaryKey"); + _outputStream.writeln('result $boundaryKey'); final DeltaProgram deltaProgram = await _generator.computeDelta(); final IOSink sink = new File(_kernelBinaryFilename).openWrite(); final BinaryPrinter printer = printerFactory.newBinaryPrinter(sink); printer.writeProgramFile(deltaProgram.newProgram); await sink.close(); - _outputStream.writeln("$boundaryKey $_kernelBinaryFilename"); + _outputStream.writeln('$boundaryKey $_kernelBinaryFilename'); return null; } @@ -282,7 +282,7 @@ Future starter( // Has to be a directory, that won't have any of the compiled application // sources, so that no relative paths could show up in the kernel file. Directory.current = Directory.systemTemp; - final Directory workingDirectory = new Directory("flutter_frontend_server"); + final Directory workingDirectory = new Directory('flutter_frontend_server'); workingDirectory.createSync(); Directory.current = workingDirectory; @@ -295,7 +295,7 @@ Future starter( String boundaryKey; input .transform(UTF8.decoder) - .transform(new LineSplitter()) + .transform(const LineSplitter()) .listen((String string) async { switch (state) { case _State.READY_FOR_INSTRUCTION: diff --git a/frontend_server/test/server_test.dart b/frontend_server/test/server_test.dart index 513909e7319..8d489928f5b 100644 --- a/frontend_server/test/server_test.dart +++ b/frontend_server/test/server_test.dart @@ -369,7 +369,7 @@ Future main() async { String boundaryKey; stdoutStreamController.stream .transform(UTF8.decoder) - .transform(new LineSplitter()) + .transform(const LineSplitter()) .listen((String s) { const String RESULT_OUTPUT_SPACE = 'result '; if (boundaryKey == null) { @@ -387,7 +387,7 @@ Future main() async { final _MockedIncrementalKernelGenerator generator = new _MockedIncrementalKernelGenerator(); when(generator.computeDelta()).thenReturn(new Future.value( - new DeltaProgram("", null /* program stub */) + new DeltaProgram('', null /* program stub */) )); final _MockedBinaryPrinterFactory printerFactory = new _MockedBinaryPrinterFactory(); diff --git a/lib/ui/compositing.dart b/lib/ui/compositing.dart index c1cd49a5f2b..dc45490a13e 100644 --- a/lib/ui/compositing.dart +++ b/lib/ui/compositing.dart @@ -20,7 +20,7 @@ class Scene extends NativeFieldWrapperClass2 { /// Releases the resources used by this scene. /// /// After calling this function, the scene is cannot be used further. - void dispose() native "Scene_dispose"; + void dispose() native 'Scene_dispose'; } /// Builds a [Scene] containing the given visuals. @@ -33,7 +33,7 @@ class Scene extends NativeFieldWrapperClass2 { class SceneBuilder extends NativeFieldWrapperClass2 { /// Creates an empty [SceneBuilder] object. SceneBuilder() { _constructor(); } - void _constructor() native "SceneBuilder_constructor"; + void _constructor() native 'SceneBuilder_constructor'; /// Pushes a transform operation onto the operation stack. /// @@ -42,12 +42,12 @@ class SceneBuilder extends NativeFieldWrapperClass2 { /// See [pop] for details about the operation stack. void pushTransform(Float64List matrix4) { if (matrix4 == null) - throw new ArgumentError("[matrix4] argument cannot be null"); + throw new ArgumentError('"matrix4" argument cannot be null'); if (matrix4.length != 16) - throw new ArgumentError("[matrix4] must have 16 entries."); + throw new ArgumentError('"matrix4" must have 16 entries.'); _pushTransform(matrix4); } - void _pushTransform(Float64List matrix4) native "SceneBuilder_pushTransform"; + void _pushTransform(Float64List matrix4) native 'SceneBuilder_pushTransform'; /// Pushes a rectangular clip operation onto the operation stack. /// @@ -60,7 +60,7 @@ class SceneBuilder extends NativeFieldWrapperClass2 { void _pushClipRect(double left, double right, double top, - double bottom) native "SceneBuilder_pushClipRect"; + double bottom) native 'SceneBuilder_pushClipRect'; /// Pushes a rounded-rectangular clip operation onto the operation stack. /// @@ -68,14 +68,14 @@ class SceneBuilder extends NativeFieldWrapperClass2 { /// /// See [pop] for details about the operation stack. void pushClipRRect(RRect rrect) => _pushClipRRect(rrect._value); - void _pushClipRRect(Float32List rrect) native "SceneBuilder_pushClipRRect"; + void _pushClipRRect(Float32List rrect) native 'SceneBuilder_pushClipRRect'; /// Pushes a path clip operation onto the operation stack. /// /// Rasterization outside the given path is discarded. /// /// See [pop] for details about the operation stack. - void pushClipPath(Path path) native "SceneBuilder_pushClipPath"; + void pushClipPath(Path path) native 'SceneBuilder_pushClipPath'; /// Pushes an opacity operation onto the operation stack. /// @@ -85,7 +85,7 @@ class SceneBuilder extends NativeFieldWrapperClass2 { /// opacity). /// /// See [pop] for details about the operation stack. - void pushOpacity(int alpha) native "SceneBuilder_pushOpacity"; + void pushOpacity(int alpha) native 'SceneBuilder_pushOpacity'; /// Pushes a color filter operation onto the operation stack. /// @@ -96,7 +96,7 @@ class SceneBuilder extends NativeFieldWrapperClass2 { void pushColorFilter(Color color, BlendMode blendMode) { _pushColorFilter(color.value, blendMode.index); } - void _pushColorFilter(int color, int blendMode) native "SceneBuilder_pushColorFilter"; + void _pushColorFilter(int color, int blendMode) native 'SceneBuilder_pushColorFilter'; /// Pushes a backdrop filter operation onto the operation stack. /// @@ -104,7 +104,7 @@ class SceneBuilder extends NativeFieldWrapperClass2 { /// rasterizing the given objects. /// /// See [pop] for details about the operation stack. - void pushBackdropFilter(ImageFilter filter) native "SceneBuilder_pushBackdropFilter"; + void pushBackdropFilter(ImageFilter filter) native 'SceneBuilder_pushBackdropFilter'; /// Pushes a shader mask operation onto the operation stack. /// @@ -125,7 +125,7 @@ class SceneBuilder extends NativeFieldWrapperClass2 { double maskRectRight, double maskRectTop, double maskRectBottom, - int blendMode) native "SceneBuilder_pushShaderMask"; + int blendMode) native 'SceneBuilder_pushShaderMask'; /// Pushes a physical layer operation for an arbitrary shape onto the /// operation stack. @@ -137,7 +137,7 @@ class SceneBuilder extends NativeFieldWrapperClass2 { _pushPhysicalShape(path, elevation, color.value); } void _pushPhysicalShape(Path path, double elevation, int color) native - "SceneBuilder_pushPhysicalShape"; + 'SceneBuilder_pushPhysicalShape'; /// Ends the effect of the most recently pushed operation. /// @@ -145,7 +145,7 @@ class SceneBuilder extends NativeFieldWrapperClass2 { /// operations in the stack applies to each of the objects added to the scene. /// Calling this function removes the most recently added operation from the /// stack. - void pop() native "SceneBuilder_pop"; + void pop() native 'SceneBuilder_pop'; /// Adds an object to the scene that displays performance statistics. /// @@ -182,7 +182,7 @@ class SceneBuilder extends NativeFieldWrapperClass2 { double left, double right, double top, - double bottom) native "SceneBuilder_addPerformanceOverlay"; + double bottom) native 'SceneBuilder_addPerformanceOverlay'; /// Adds a [Picture] to the scene. /// @@ -195,7 +195,7 @@ class SceneBuilder extends NativeFieldWrapperClass2 { hints |= 2; _addPicture(offset.dx, offset.dy, picture, hints); } - void _addPicture(double dx, double dy, Picture picture, int hints) native "SceneBuilder_addPicture"; + void _addPicture(double dx, double dy, Picture picture, int hints) native 'SceneBuilder_addPicture'; /// Adds a backend texture to the scene. /// @@ -204,7 +204,7 @@ class SceneBuilder extends NativeFieldWrapperClass2 { assert(offset != null, 'Offset argument was null'); _addTexture(offset.dx, offset.dy, width, height, textureId); } - void _addTexture(double dx, double dy, double width, double height, int textureId) native "SceneBuilder_addTexture"; + void _addTexture(double dx, double dy, double width, double height, int textureId) native 'SceneBuilder_addTexture'; /// (Fuchsia-only) Adds a scene rendered by another application to the scene /// for this application. @@ -227,7 +227,7 @@ class SceneBuilder extends NativeFieldWrapperClass2 { double width, double height, SceneHost sceneHost, - bool hitTestable) native "SceneBuilder_addChildScene"; + bool hitTestable) native 'SceneBuilder_addChildScene'; /// Sets a threshold after which additional debugging information should be recorded. /// @@ -235,7 +235,7 @@ class SceneBuilder extends NativeFieldWrapperClass2 { /// interested in using this feature, please contact [flutter-dev](https://groups.google.com/forum/#!forum/flutter-dev). /// We'll hopefully be able to figure out how to make this feature more useful /// to you. - void setRasterizerTracingThreshold(int frameInterval) native "SceneBuilder_setRasterizerTracingThreshold"; + void setRasterizerTracingThreshold(int frameInterval) native 'SceneBuilder_setRasterizerTracingThreshold'; /// Sets whether the raster cache should checkerboard cached entries. This is /// only useful for debugging purposes. @@ -252,13 +252,13 @@ class SceneBuilder extends NativeFieldWrapperClass2 { /// /// Currently this interface is difficult to use by end-developers. If you're /// interested in using this feature, please contact [flutter-dev](https://groups.google.com/forum/#!forum/flutter-dev). - void setCheckerboardRasterCacheImages(bool checkerboard) native "SceneBuilder_setCheckerboardRasterCacheImages"; + void setCheckerboardRasterCacheImages(bool checkerboard) native 'SceneBuilder_setCheckerboardRasterCacheImages'; /// Sets whether the compositor should checkerboard layers that are rendered /// to offscreen bitmaps. /// /// This is only useful for debugging purposes. - void setCheckerboardOffscreenLayers(bool checkerboard) native "SceneBuilder_setCheckerboardOffscreenLayers"; + void setCheckerboardOffscreenLayers(bool checkerboard) native 'SceneBuilder_setCheckerboardOffscreenLayers'; /// Finishes building the scene. /// @@ -268,7 +268,7 @@ class SceneBuilder extends NativeFieldWrapperClass2 { /// /// After calling this function, the scene builder object is invalid and /// cannot be used further. - Scene build() native "SceneBuilder_build"; + Scene build() native 'SceneBuilder_build'; } /// (Fuchsia-only) Hosts content provided by another application. @@ -285,13 +285,13 @@ class SceneHost extends NativeFieldWrapperClass2 { /// //topaz/public/lib/ui/flutter/. /// /// The scene host takes ownership of the provided export token handle. - SceneHost(dynamic export_token_handle) { - _constructor(export_token_handle); + SceneHost(dynamic exportTokenHandle) { + _constructor(exportTokenHandle); } - void _constructor(dynamic export_token_handle) native "SceneHost_constructor"; + void _constructor(dynamic exportTokenHandle) native 'SceneHost_constructor'; /// Releases the resources associated with the child scene host. /// /// After calling this function, the child scene host cannot be used further. - void dispose() native "SceneHost_dispose"; + void dispose() native 'SceneHost_dispose'; } diff --git a/lib/ui/geometry.dart b/lib/ui/geometry.dart index a15aeda8a01..5478ff34943 100644 --- a/lib/ui/geometry.dart +++ b/lib/ui/geometry.dart @@ -325,6 +325,9 @@ class Offset extends OffsetBase { _dy == typedOther._dy; } + @override + int get hashCode => hashValues(_dx, _dy); + @override String toString() => 'Offset(${dx?.toStringAsFixed(1)}, ${dy?.toStringAsFixed(1)})'; } @@ -566,6 +569,9 @@ class Size extends OffsetBase { _dy == typedOther._dy; } + @override + int get hashCode => hashValues(_dx, _dy); + @override String toString() => 'Size(${width?.toStringAsFixed(1)}, ${height?.toStringAsFixed(1)})'; } diff --git a/lib/ui/hooks.dart b/lib/ui/hooks.dart index 9de206dac38..a11ebd5a2c7 100644 --- a/lib/ui/hooks.dart +++ b/lib/ui/hooks.dart @@ -39,11 +39,11 @@ void _updateWindowMetrics(double devicePixelRatio, _invoke(window.onMetricsChanged, window._onMetricsChangedZone); } -typedef String LocaleClosure(); +typedef String _LocaleClosure(); String _localeClosure() => window._locale.toString(); -LocaleClosure _getLocaleClosure() => _localeClosure; +_LocaleClosure _getLocaleClosure() => _localeClosure; void _updateLocale(String languageCode, String countryCode) { window._locale = new Locale(languageCode, countryCode); @@ -133,7 +133,7 @@ void _invoke1(void callback(A a), Zone zone, A arg) { if (identical(zone, Zone.current)) { callback(arg); } else { - zone.runUnaryGuarded(callback, arg); + zone.runUnaryGuarded(callback, arg); } } @@ -147,7 +147,7 @@ void _invoke2(void callback(A1 a1, A2 a2), Zone zone, A1 arg1, A2 arg2) if (identical(zone, Zone.current)) { callback(arg1, arg2); } else { - zone.runBinaryGuarded(callback, arg1, arg2); + zone.runBinaryGuarded(callback, arg1, arg2); } } @@ -178,7 +178,7 @@ PointerDataPacket _unpackPointerDataPacket(ByteData packet) { const int kBytesPerPointerData = _kPointerDataFieldCount * kStride; final int length = packet.lengthInBytes ~/ kBytesPerPointerData; assert(length * kBytesPerPointerData == packet.lengthInBytes); - List data = new List(length); + final List data = new List(length); for (int i = 0; i < length; ++i) { int offset = i * _kPointerDataFieldCount; data[i] = new PointerData( diff --git a/lib/ui/lerp.dart b/lib/ui/lerp.dart index 76d2d100325..2107969be57 100644 --- a/lib/ui/lerp.dart +++ b/lib/ui/lerp.dart @@ -8,9 +8,7 @@ part of dart.ui; double lerpDouble(num a, num b, double t) { if (a == null && b == null) return null; - if (a == null) - a = 0.0; - if (b == null) - b = 0.0; + a ??= 0.0; + b ??= 0.0; return a + (b - a) * t; } diff --git a/lib/ui/natives.dart b/lib/ui/natives.dart index c2ab70a9074..92c790aee3c 100644 --- a/lib/ui/natives.dart +++ b/lib/ui/natives.dart @@ -10,7 +10,7 @@ void _print(dynamic arg) { } class _Logger { - static void _printString(String s) native "Logger_PrintString"; + static void _printString(String s) native 'Logger_PrintString'; } // A service protocol extension to schedule a frame to be rendered into the @@ -22,7 +22,7 @@ Future _scheduleFrame( // Schedule the frame. window.scheduleFrame(); // Always succeed. - return new developer.ServiceExtensionResponse.result(JSON.encode({ + return new developer.ServiceExtensionResponse.result(JSON.encode({ 'type': 'Success', })); } @@ -35,7 +35,7 @@ void _setupHooks() { }()); } -void _scheduleMicrotask(void callback()) native "ScheduleMicrotask"; +void _scheduleMicrotask(void callback()) native 'ScheduleMicrotask'; String _baseURL; Uri _getBaseURL() => Uri.parse(_baseURL); @@ -51,5 +51,5 @@ Function _getGetBaseURLClosure() => _getBaseURL; // above, the builtin library will be included manually during VM setup. This // symbol is only necessary for precompilation. It is marked as a stanalone // entry point into the VM. This prevents the precompiler from tree shaking -// away "main" +// away "main". Function _getMainClosure() => main; diff --git a/lib/ui/painting.dart b/lib/ui/painting.dart index b68f092add8..2ad6216c233 100644 --- a/lib/ui/painting.dart +++ b/lib/ui/painting.dart @@ -278,27 +278,51 @@ class Color { int get hashCode => value.hashCode; @override - String toString() => "Color(0x${value.toRadixString(16).padLeft(8, '0')})"; + String toString() => 'Color(0x${value.toRadixString(16).padLeft(8, '0')})'; } /// Algorithms to use when painting on the canvas. /// -/// When drawing a shape or image onto a canvas, different algorithms -/// can be used to blend the pixels. The image below shows the effects -/// of these modes. +/// When drawing a shape or image onto a canvas, different algorithms can be +/// used to blend the pixels. The different values of [BlendMode] specify +/// different such algorithms. /// -/// [![Open Skia fiddle to view image.](https://flutter.github.io/assets-for-api-docs/dart-ui/blend_mode.png)](https://fiddle.skia.org/c/864acd0659c7a866ea7296a3184b8bdd) +/// Each algorithm has two inputs, the _source_, which is the image being drawn, +/// and the _destination_, which is the image into which the source image is +/// being composited. The destination is often thought of as the _background_. +/// The source and destination both have four color channels, the red, green, +/// blue, and alpha channels. These are typically represented as numbers in the +/// range 0.0 to 1.0. The output of the algorithm also has these same four +/// channels, with values computed from the source and destination. /// -/// The "src" (source) image is the shape or image being drawn, the "dst" -/// (destination) image is the current contents of the canvas onto which the -/// source is being drawn. +/// The documentation of each value below describes how the algorithm works. In +/// each case, an image shows the output of blending a source image with a +/// destination image. In the images below, the destination is represented by an +/// image with horizontal lines and an opaque landscape photograph, and the +/// source is represented by an image with vertical lines (the same lines but +/// rotated) and a bird clip-art image. The [src] mode shows only the source +/// image, and the [dst] mode shows only the destination image. In the +/// documentation below, the transparency is illustrated by a checkerboard +/// pattern. The [clear] mode drops both the source and destination, resulting +/// in an output that is entirely transparent (illustrated by a solid +/// checkerboard pattern). +/// +/// The horizontal and vertical bars in these images show the red, green, and +/// blue channels with varying opacity levels, then all three color channels +/// together with those same varying opacity levels, then all three color +/// chanels set to zero with those varying opacity levels, then two bars showing +/// a red/green/blue repeating gradient, the first with full opacity and the +/// second with partial opacity, and finally a bar with the three color channels +/// set to zero but the opacity varying in a repeating gradient. +/// +/// ## Application to the [Canvas] API /// /// When using [Canvas.saveLayer] and [Canvas.restore], the blend mode of the /// [Paint] given to the [Canvas.saveLayer] will be applied when /// [Canvas.restore] is called. Each call to [Canvas.saveLayer] introduces a new /// layer onto which shapes and images are painted; when [Canvas.restore] is -/// called, that layer is then _composited_ onto the parent layer, with the -/// "src" being the most-recently-drawn shapes and images, and the "dst" being +/// called, that layer is then composited onto the parent layer, with the source +/// being the most-recently-drawn shapes and images, and the destination being /// the parent layer. (For the first [Canvas.saveLayer] call, the parent layer /// is the canvas itself.) /// @@ -314,6 +338,8 @@ enum BlendMode { /// Drop both the source and destination images, leaving nothing. /// /// This corresponds to the "clear" Porter-Duff operator. + /// + /// ![](https://flutter.github.io/assets-for-api-docs/dart-ui/blend_mode_clear.png) clear, /// Drop the destination image, only paint the source image. @@ -322,6 +348,8 @@ enum BlendMode { /// painted. /// /// This corresponds to the "Copy" Porter-Duff operator. + /// + /// ![](https://flutter.github.io/assets-for-api-docs/dart-ui/blend_mode_src.png) src, /// Drop the source image, only paint the destination image. @@ -330,6 +358,8 @@ enum BlendMode { /// untouched. /// /// This corresponds to the "Destination" Porter-Duff operator. + /// + /// ![](https://flutter.github.io/assets-for-api-docs/dart-ui/blend_mode_dst.png) dst, /// Composite the source image over the destination image. @@ -340,6 +370,8 @@ enum BlendMode { /// /// This corresponds to the "Source over Destination" Porter-Duff operator, /// also known as the Painter's Algorithm. + /// + /// ![](https://flutter.github.io/assets-for-api-docs/dart-ui/blend_mode_srcOver.png) srcOver, /// Composite the source image under the destination image. @@ -347,10 +379,17 @@ enum BlendMode { /// This is the opposite of [srcOver]. /// /// This corresponds to the "Destination over Source" Porter-Duff operator. + /// + /// ![](https://flutter.github.io/assets-for-api-docs/dart-ui/blend_mode_dstOver.png) + /// + /// This is useful when the source image should have been painted before the + /// destination image, but could not be. dstOver, /// Show the source image, but only where the two images overlap. The - /// destination image is not rendered, it is treated merely as a mask. + /// destination image is not rendered, it is treated merely as a mask. The + /// color channels of the destination are ignored, only the opacity has an + /// effect. /// /// To show the destination image instead, consider [dstIn]. /// @@ -359,21 +398,27 @@ enum BlendMode { /// [srcOut]. /// /// This corresponds to the "Source in Destination" Porter-Duff operator. + /// + /// ![](https://flutter.github.io/assets-for-api-docs/dart-ui/blend_mode_srcIn.png) srcIn, /// Show the destination image, but only where the two images overlap. The - /// source image is not rendered, it is treated merely as a mask. + /// source image is not rendered, it is treated merely as a mask. The color + /// channels of the source are ignored, only the opacity has an effect. /// /// To show the source image instead, consider [srcIn]. /// /// To reverse the semantic of the mask (only showing the source where the - /// destination is present, rather than where it is absent), consider [srcIn]. + /// destination is present, rather than where it is absent), consider [dstOut]. /// /// This corresponds to the "Destination in Source" Porter-Duff operator. + /// + /// ![](https://flutter.github.io/assets-for-api-docs/dart-ui/blend_mode_dstIn.png) dstIn, /// Show the source image, but only where the two images do not overlap. The - /// destination image is not rendered, it is treated merely as a mask. + /// destination image is not rendered, it is treated merely as a mask. The color + /// channels of the destination are ignored, only the opacity has an effect. /// /// To show the destination image instead, consider [dstOut]. /// @@ -381,10 +426,13 @@ enum BlendMode { /// destination is present, rather than where it is absent), consider [srcIn]. /// /// This corresponds to the "Source out Destination" Porter-Duff operator. + /// + /// ![](https://flutter.github.io/assets-for-api-docs/dart-ui/blend_mode_srcOut.png) srcOut, /// Show the destination image, but only where the two images do not overlap. The - /// source image is not rendered, it is treated merely as a mask. + /// source image is not rendered, it is treated merely as a mask. The color + /// channels of the source are ignored, only the opacity has an effect. /// /// To show the source image instead, consider [srcOut]. /// @@ -392,51 +440,315 @@ enum BlendMode { /// source is present, rather than where it is absent), consider [dstIn]. /// /// This corresponds to the "Destination out Source" Porter-Duff operator. + /// + /// ![](https://flutter.github.io/assets-for-api-docs/dart-ui/blend_mode_dstOut.png) dstOut, /// Composite the source image over the destination image, but only where it /// overlaps the destination. /// /// This corresponds to the "Source atop Destination" Porter-Duff operator. + /// + /// This is essentially the [srcOver] operator, but with the output's opacity + /// channel being set to that of the destination image instead of being a + /// combination of both image's opacity channels. + /// + /// For a variant with the destination on top instead of the source, see + /// [dstATop]. + /// + /// ![](https://flutter.github.io/assets-for-api-docs/dart-ui/blend_mode_srcATop.png) srcATop, /// Composite the destination image over the source image, but only where it /// overlaps the source. /// /// This corresponds to the "Destination atop Source" Porter-Duff operator. + /// + /// This is essentially the [dstOver] operator, but with the output's opacity + /// channel being set to that of the source image instead of being a + /// combination of both image's opacity channels. + /// + /// For a variant with the source on top instead of the destination, see + /// [srcATop]. + /// + /// ![](https://flutter.github.io/assets-for-api-docs/dart-ui/blend_mode_dstATop.png) dstATop, - /// Composite the source and destination images, leaving transparency where - /// they would overlap. + /// Apply a bitwise `xor` operator to the source and destination images. This + /// leaves transparency where they would overlap. /// /// This corresponds to the "Source xor Destination" Porter-Duff operator. + /// + /// ![](https://flutter.github.io/assets-for-api-docs/dart-ui/blend_mode_xor.png) xor, - /// Composite the source and destination images by summing their components. + /// Sum the components of the source and destination images. + /// + /// Transparency in a pixel of one of the images reduces the contribution of + /// that image to the corresponding output pixel, as if the color of that + /// pixel in that image was darker. /// /// This corresponds to the "Source plus Destination" Porter-Duff operator. + /// + /// ![](https://flutter.github.io/assets-for-api-docs/dart-ui/blend_mode_plus.png) plus, + /// Multiply the color components of the source and destination images. + /// + /// This can only result in the same or darker colors (multiplying by white, + /// 1.0, results in no change; multiplying by black, 0.0, results in black). + /// + /// When compositing two opaque images, this has similar effect to overlapping + /// two transparencies on a projector. + /// + /// For a variant that also multiplies the alpha channel, consider [multiply]. + /// + /// ![](https://flutter.github.io/assets-for-api-docs/dart-ui/blend_mode_modulate.png) + /// + /// See also: + /// + /// * [screen], which does a similar computation but inversed. + /// * [overlay], which combines [modulate] and [screen] to favor the + /// destination image. + /// * [hardLight], which combines [modulate] and [screen] to favor the + /// source image. modulate, // Following blend modes are defined in the CSS Compositing standard. + /// Multiply the inverse of the components of the source and destination + /// images, and inverse the result. + /// + /// Inversing the components means that a fully saturated channel (opaque + /// white) is treated as the value 0.0, and values normally treated as 0.0 + /// (black, transparent) are treated as 1.0. + /// + /// This is essentially the same as [modulate] blend mode, but with the values + /// of the colors inversed before the multiplication and the result being + /// inversed back before rendering. + /// + /// This can only result in the same or lighter colors (multiplying by black, + /// 1.0, results in no change; multiplying by white, 0.0, results in white). + /// Similarly, in the alpha channel, it can only result in more opaque colors. + /// + /// This has similar effect to two projectors displaying their images on the + /// same screen simultaneously. + /// + /// ![](https://flutter.github.io/assets-for-api-docs/dart-ui/blend_mode_screen.png) + /// + /// See also: + /// + /// * [modulate], which does a similar computation but without inversing the + /// values. + /// * [overlay], which combines [modulate] and [screen] to favor the + /// destination image. + /// * [hardLight], which combines [modulate] and [screen] to favor the + /// source image. screen, // The last coeff mode. + /// Multiply the components of the source and destination images after + /// adjusting them to favor the destination. + /// + /// Specifically, if the destination value is smaller, this multiplies it with + /// the source value, whereas is the source value is smaller, it multiplies + /// the inverse of the source value with the inverse of the destination value, + /// then inverses the result. + /// + /// Inversing the components means that a fully saturated channel (opaque + /// white) is treated as the value 0.0, and values normally treated as 0.0 + /// (black, transparent) are treated as 1.0. + /// + /// ![](https://flutter.github.io/assets-for-api-docs/dart-ui/blend_mode_overlay.png) + /// + /// See also: + /// + /// * [modulate], which always multiplies the values. + /// * [screen], which always multiplies the inverses of the values. + /// * [hardLight], which is similar to [overlay] but favors the source image + /// instead of the destination image. overlay, + + /// Composite the source and destination image by choosing the lowest value + /// from each color channel. + /// + /// The opacity of the output image is computed in the same way as for + /// [srcOver]. + /// + /// ![](https://flutter.github.io/assets-for-api-docs/dart-ui/blend_mode_darken.png) darken, + + /// Composite the source and destination image by choosing the highest value + /// from each color channel. + /// + /// The opacity of the output image is computed in the same way as for + /// [srcOver]. + /// + /// ![](https://flutter.github.io/assets-for-api-docs/dart-ui/blend_mode_lighten.png) lighten, + + /// Divide the destination by the inverse of the source. + /// + /// Inversing the components means that a fully saturated channel (opaque + /// white) is treated as the value 0.0, and values normally treated as 0.0 + /// (black, transparent) are treated as 1.0. + /// + /// ![](https://flutter.github.io/assets-for-api-docs/dart-ui/blend_mode_colorDodge.png) colorDodge, + + /// Divide the inverse of the destination by the the source, and inverse the result. + /// + /// Inversing the components means that a fully saturated channel (opaque + /// white) is treated as the value 0.0, and values normally treated as 0.0 + /// (black, transparent) are treated as 1.0. + /// + /// ![](https://flutter.github.io/assets-for-api-docs/dart-ui/blend_mode_colorBurn.png) colorBurn, + + /// Multiply the components of the source and destination images after + /// adjusting them to favor the source. + /// + /// Specifically, if the source value is smaller, this multiplies it with the + /// destination value, whereas is the destination value is smaller, it + /// multiplies the inverse of the destination value with the inverse of the + /// source value, then inverses the result. + /// + /// Inversing the components means that a fully saturated channel (opaque + /// white) is treated as the value 0.0, and values normally treated as 0.0 + /// (black, transparent) are treated as 1.0. + /// + /// ![](https://flutter.github.io/assets-for-api-docs/dart-ui/blend_mode_hardLight.png) + /// + /// See also: + /// + /// * [modulate], which always multiplies the values. + /// * [screen], which always multiplies the inverses of the values. + /// * [overlay], which is similar to [hardLight] but favors the destination + /// image instead of the source image. hardLight, + + /// Use [colorDodge] for source values below 0.5 and [colorBurn] for source + /// values above 0.5. + /// + /// This results in a similal but softer effect than [overlay]. + /// + /// ![](https://flutter.github.io/assets-for-api-docs/dart-ui/blend_mode_softLight.png) + /// + /// See also: + /// + /// * [color], which is a more subtle tinting effect. softLight, + + /// Subtract the smaller value from the bigger value for each channel. + /// + /// Compositing black has no effect; compositing white inverses the colors of + /// the other image. + /// + /// The opacity of the output image is computed in the same way as for + /// [srcOver]. + /// + /// The effect is similar to [exclusion] but harsher. + /// + /// ![](https://flutter.github.io/assets-for-api-docs/dart-ui/blend_mode_difference.png) difference, + + /// Subtract double the product of the two images from the sum of the two + /// images. + /// + /// Compositing black has no effect; compositing white inverses the colors of + /// the other image. + /// + /// The opacity of the output image is computed in the same way as for + /// [srcOver]. + /// + /// The effect is similar to [difference] but softer. + /// + /// ![](https://flutter.github.io/assets-for-api-docs/dart-ui/blend_mode_exclusion.png) exclusion, + + /// Multiply the components of the source and destination images, including + /// the alpha channel. + /// + /// This can only result in the same or darker colors (multiplying by white, + /// 1.0, results in no change; multiplying by black, 0.0, results in black). + /// + /// Since the alpha channel is also multiplied, a fully-transparent pixel + /// (opacity 0.0) in one image results in a fully transparent pixel in the + /// output. This is similar to [dstIn], but with the colors combined. + /// + /// For a variant that multiplies the colors but does not multiply the alpha + /// channel, consider [modulate]. + /// + /// ![](https://flutter.github.io/assets-for-api-docs/dart-ui/blend_mode_multiply.png) multiply, // The last separable mode. + /// Take the hue of the source image, and the saturation and luminosity of the + /// destination image. + /// + /// The effect is to tint the destination image with the source image. + /// + /// The opacity of the output image is computed in the same way as for + /// [srcOver]. Regions that are entirely transparent in the source image take + /// their hue from the destination. + /// + /// ![](https://flutter.github.io/assets-for-api-docs/dart-ui/blend_mode_hue.png) + /// + /// See also: + /// + /// * [color], which is a similar but stronger effect as it also applies the + /// saturation of the source image. + /// * [HSVColor], which allows colors to be expressed using Hue rather than + /// the red/green/blue channels of [Color]. hue, + + /// Take the saturation of the source image, and the hue and luminosity of the + /// destination image. + /// + /// The opacity of the output image is computed in the same way as for + /// [srcOver]. Regions that are entirely transparent in the source image take + /// their saturation from the destination. + /// + /// ![](https://flutter.github.io/assets-for-api-docs/dart-ui/blend_mode_hue.png) + /// + /// See also: + /// + /// * [color], which also applies the hue of the source image. + /// * [luminosity], which applies the luminosity of the source image to the + /// destination. saturation, + + /// Take the hue and saturation of the source image, and the luminosity of the + /// destination image. + /// + /// The effect is to tint the destination image with the source image. + /// + /// The opacity of the output image is computed in the same way as for + /// [srcOver]. Regions that are entirely transparent in the source image take + /// their hue and saturation from the destination. + /// + /// ![](https://flutter.github.io/assets-for-api-docs/dart-ui/blend_mode_color.png) + /// + /// See also: + /// + /// * [hue], which is a similar but weaker effect. + /// * [softLight], which is a similar tinting effect but also tints white. + /// * [saturation], which only applies the saturation of the source image. color, + + /// Take the luminosity of the source image, and the hue and saturation of the + /// destination image. + /// + /// The opacity of the output image is computed in the same way as for + /// [srcOver]. Regions that are entirely transparent in the source image take + /// their luminosity from the destination. + /// + /// ![](https://flutter.github.io/assets-for-api-docs/dart-ui/blend_mode_luminosity.png) + /// + /// See also: + /// + /// * [saturation], which applies the saturation of the source image to the + /// destination. + /// * [ImageFilter.blur], which can be used with [BackdropFilter] for a + /// related effect. luminosity, } @@ -831,7 +1143,7 @@ class Paint { @override String toString() { - StringBuffer result = new StringBuffer(); + final StringBuffer result = new StringBuffer(); String semicolon = ''; result.write('Paint('); if (style == PaintingStyle.stroke) { @@ -892,14 +1204,14 @@ class Paint { /// [Canvas.drawImage]. abstract class Image extends NativeFieldWrapperClass2 { /// The number of image pixels along the image's horizontal axis. - int get width native "Image_width"; + int get width native 'Image_width'; /// The number of image pixels along the image's vertical axis. - int get height native "Image_height"; + int get height native 'Image_height'; /// Release the resources used by this object. The object is no longer usable /// after this method is called. - void dispose() native "Image_dispose"; + void dispose() native 'Image_dispose'; @override String toString() => '[$width\u00D7$height]'; @@ -908,29 +1220,29 @@ abstract class Image extends NativeFieldWrapperClass2 { /// Callback signature for [decodeImageFromList]. typedef void ImageDecoderCallback(Image result); -/// Information for a single animation frame. +/// Information for a single frame of an animation. /// -/// Obtain a FrameInfo with [Codec.getNextFrame]. +/// To obtain an instance of the [FrameInfo] interface, see +/// [Codec.getNextFrame]. abstract class FrameInfo extends NativeFieldWrapperClass2 { - // The duration this frame should be shown. + /// The duration this frame should be shown. Duration get duration => new Duration(milliseconds: _durationMillis); + int get _durationMillis native 'FrameInfo_durationMillis'; - int get _durationMillis native "FrameInfo_durationMillis"; - - // The Image object for this frame. - Image get image native "FrameInfo_image"; + /// The [Image] object for this frame. + Image get image native 'FrameInfo_image'; } /// A handle to an image codec. abstract class Codec extends NativeFieldWrapperClass2 { /// Number of frames in this image. - int get frameCount native "Codec_frameCount"; + int get frameCount native 'Codec_frameCount'; /// Number of times to repeat the animation. /// /// * 0 when the animation should be played once. /// * -1 for infinity repetitions. - int get repetitionCount native "Codec_repetitionCount"; + int get repetitionCount native 'Codec_repetitionCount'; /// Fetches the next animation frame. /// @@ -942,11 +1254,11 @@ abstract class Codec extends NativeFieldWrapperClass2 { } /// Returns an error message on failure, null on success. - String _getNextFrame(_Callback callback) native "Codec_getNextFrame"; + String _getNextFrame(_Callback callback) native 'Codec_getNextFrame'; /// Release the resources used by this object. The object is no longer usable /// after this method is called. - void dispose() native "Codec_dispose"; + void dispose() native 'Codec_dispose'; } /// Instantiates an image codec [Codec] object. @@ -968,7 +1280,7 @@ Future instantiateImageCodec(Uint8List list) { /// /// Returns an error message if the instantiation has failed, null otherwise. String _instantiateImageCodec(Uint8List list, _Callback callback) - native "instantiateImageCodec"; + native 'instantiateImageCodec'; /// Loads a single image frame from a byte array into an [Image] object. /// @@ -1028,7 +1340,7 @@ enum PathFillType { class Path extends NativeFieldWrapperClass2 { /// Create a new empty [Path] object. Path() { _constructor(); } - void _constructor() native "Path_constructor"; + void _constructor() native 'Path_constructor'; /// Determines how the interior of this path is calculated. /// @@ -1036,51 +1348,51 @@ class Path extends NativeFieldWrapperClass2 { PathFillType get fillType => PathFillType.values[_getFillType()]; set fillType(PathFillType value) => _setFillType(value.index); - int _getFillType() native "Path_getFillType"; - void _setFillType(int fillType) native "Path_setFillType"; + int _getFillType() native 'Path_getFillType'; + void _setFillType(int fillType) native 'Path_setFillType'; /// Starts a new subpath at the given coordinate. - void moveTo(double x, double y) native "Path_moveTo"; + void moveTo(double x, double y) native 'Path_moveTo'; /// Starts a new subpath at the given offset from the current point. - void relativeMoveTo(double dx, double dy) native "Path_relativeMoveTo"; + void relativeMoveTo(double dx, double dy) native 'Path_relativeMoveTo'; /// Adds a straight line segment from the current point to the given /// point. - void lineTo(double x, double y) native "Path_lineTo"; + void lineTo(double x, double y) native 'Path_lineTo'; /// Adds a straight line segment from the current point to the point /// at the given offset from the current point. - void relativeLineTo(double dx, double dy) native "Path_relativeLineTo"; + void relativeLineTo(double dx, double dy) native 'Path_relativeLineTo'; /// Adds a quadratic bezier segment that curves from the current /// point to the given point (x2,y2), using the control point /// (x1,y1). - void quadraticBezierTo(double x1, double y1, double x2, double y2) native "Path_quadraticBezierTo"; + void quadraticBezierTo(double x1, double y1, double x2, double y2) native 'Path_quadraticBezierTo'; /// Adds a quadratic bezier segment that curves from the current /// point to the point at the offset (x2,y2) from the current point, /// using the control point at the offset (x1,y1) from the current /// point. - void relativeQuadraticBezierTo(double x1, double y1, double x2, double y2) native "Path_relativeQuadraticBezierTo"; + void relativeQuadraticBezierTo(double x1, double y1, double x2, double y2) native 'Path_relativeQuadraticBezierTo'; /// Adds a cubic bezier segment that curves from the current point /// to the given point (x3,y3), using the control points (x1,y1) and /// (x2,y2). - void cubicTo(double x1, double y1, double x2, double y2, double x3, double y3) native "Path_cubicTo"; + void cubicTo(double x1, double y1, double x2, double y2, double x3, double y3) native 'Path_cubicTo'; /// Adds a cubcic bezier segment that curves from the current point /// to the point at the offset (x3,y3) from the current point, using /// the control points at the offsets (x1,y1) and (x2,y2) from the /// current point. - void relativeCubicTo(double x1, double y1, double x2, double y2, double x3, double y3) native "Path_relativeCubicTo"; + void relativeCubicTo(double x1, double y1, double x2, double y2, double x3, double y3) native 'Path_relativeCubicTo'; /// Adds a bezier segment that curves from the current point to the /// given point (x2,y2), using the control points (x1,y1) and the /// weight w. If the weight is greater than 1, then the curve is a /// hyperbola; if the weight equals 1, it's a parabola; and if it is /// less than 1, it is an ellipse. - void conicTo(double x1, double y1, double x2, double y2, double w) native "Path_conicTo"; + void conicTo(double x1, double y1, double x2, double y2, double w) native 'Path_conicTo'; /// Adds a bezier segment that curves from the current point to the /// point at the offset (x2,y2) from the current point, using the @@ -1088,7 +1400,7 @@ class Path extends NativeFieldWrapperClass2 { /// the weight w. If the weight is greater than 1, then the curve is /// a hyperbola; if the weight equals 1, it's a parabola; and if it /// is less than 1, it is an ellipse. - void relativeConicTo(double x1, double y1, double x2, double y2, double w) native "Path_relativeConicTo"; + void relativeConicTo(double x1, double y1, double x2, double y2, double w) native 'Path_relativeConicTo'; /// If the `forceMoveTo` argument is false, adds a straight line /// segment and an arc segment. @@ -1111,7 +1423,7 @@ class Path extends NativeFieldWrapperClass2 { _arcTo(rect.left, rect.top, rect.right, rect.bottom, startAngle, sweepAngle, forceMoveTo); } void _arcTo(double left, double top, double right, double bottom, - double startAngle, double sweepAngle, bool forceMoveTo) native "Path_arcTo"; + double startAngle, double sweepAngle, bool forceMoveTo) native 'Path_arcTo'; /// Appends up to four conic curves weighted to describe an oval of `radius` /// and rotated by `rotation`. @@ -1138,7 +1450,7 @@ class Path extends NativeFieldWrapperClass2 { } void _arcToPoint(double arcEndX, double arcEndY, double radiusX, double radiusY, double rotation, bool largeArc, - bool clockwise) native "Path_arcToPoint"; + bool clockwise) native 'Path_arcToPoint'; /// Appends up to four conic curves weighted to describe an oval of `radius` @@ -1169,7 +1481,7 @@ class Path extends NativeFieldWrapperClass2 { void _relativeArcToPoint(double arcEndX, double arcEndY, double radiusX, double radiusY, double rotation, bool largeArc, bool clockwise) - native "Path_relativeArcToPoint"; + native 'Path_relativeArcToPoint'; /// Adds a new subpath that consists of four lines that outline the /// given rectangle. @@ -1177,7 +1489,7 @@ class Path extends NativeFieldWrapperClass2 { assert(_rectIsValid(rect)); _addRect(rect.left, rect.top, rect.right, rect.bottom); } - void _addRect(double left, double top, double right, double bottom) native "Path_addRect"; + void _addRect(double left, double top, double right, double bottom) native 'Path_addRect'; /// Adds a new subpath that consists of a curve that forms the /// ellipse that fills the given rectangle. @@ -1185,7 +1497,7 @@ class Path extends NativeFieldWrapperClass2 { assert(_rectIsValid(oval)); _addOval(oval.left, oval.top, oval.right, oval.bottom); } - void _addOval(double left, double top, double right, double bottom) native "Path_addOval"; + void _addOval(double left, double top, double right, double bottom) native 'Path_addOval'; /// Adds a new subpath with one arc segment that consists of the arc /// that follows the edge of the oval bounded by the given @@ -1200,7 +1512,7 @@ class Path extends NativeFieldWrapperClass2 { _addArc(oval.left, oval.top, oval.right, oval.bottom, startAngle, sweepAngle); } void _addArc(double left, double top, double right, double bottom, - double startAngle, double sweepAngle) native "Path_addArc"; + double startAngle, double sweepAngle) native 'Path_addArc'; /// Adds a new subpath with a sequence of line segments that connect the given /// points. @@ -1213,7 +1525,7 @@ class Path extends NativeFieldWrapperClass2 { assert(points != null); _addPolygon(_encodePointList(points), close); } - void _addPolygon(Float32List points, bool close) native "Path_addPolygon"; + void _addPolygon(Float32List points, bool close) native 'Path_addPolygon'; /// Adds a new subpath that consists of the straight lines and /// curves needed to form the rounded rectangle described by the @@ -1222,7 +1534,7 @@ class Path extends NativeFieldWrapperClass2 { assert(_rrectIsValid(rrect)); _addRRect(rrect._value); } - void _addRRect(Float32List rrect) native "Path_addRRect"; + void _addRRect(Float32List rrect) native 'Path_addRRect'; /// Adds a new subpath that consists of the given path offset by the given /// offset. @@ -1231,7 +1543,7 @@ class Path extends NativeFieldWrapperClass2 { assert(_offsetIsValid(offset)); _addPath(path, offset.dx, offset.dy); } - void _addPath(Path path, double dx, double dy) native "Path_addPath"; + void _addPath(Path path, double dx, double dy) native 'Path_addPath'; /// Adds the given path to this path by extending the current segment of this /// path with the the first segment of the given path. @@ -1240,16 +1552,16 @@ class Path extends NativeFieldWrapperClass2 { assert(_offsetIsValid(offset)); _extendWithPath(path, offset.dx, offset.dy); } - void _extendWithPath(Path path, double dx, double dy) native "Path_extendWithPath"; + void _extendWithPath(Path path, double dx, double dy) native 'Path_extendWithPath'; /// Closes the last subpath, as if a straight line had been drawn /// from the current point to the first point of the subpath. - void close() native "Path_close"; + void close() native 'Path_close'; /// Clears the [Path] object of all subpaths, returning it to the /// same state it had when it was created. The _current point_ is /// reset to the origin. - void reset() native "Path_reset"; + void reset() native 'Path_reset'; /// Tests to see if the given point is within the path. (That is, whether the /// point would be in the visible portion of the path if the path was used @@ -1262,7 +1574,7 @@ class Path extends NativeFieldWrapperClass2 { assert(_offsetIsValid(point)); return _contains(point.dx, point.dy); } - bool _contains(double x, double y) native "Path_contains"; + bool _contains(double x, double y) native 'Path_contains'; /// Returns a copy of the path with all the segments of every /// subpath translated by the given offset. @@ -1270,7 +1582,7 @@ class Path extends NativeFieldWrapperClass2 { assert(_offsetIsValid(offset)); return _shift(offset.dx, offset.dy); } - Path _shift(double dx, double dy) native "Path_shift"; + Path _shift(double dx, double dy) native 'Path_shift'; /// Returns a copy of the path with all the segments of every /// subpath transformed by the given matrix. @@ -1280,7 +1592,7 @@ class Path extends NativeFieldWrapperClass2 { throw new ArgumentError('"matrix4" must have 16 entries.'); return _transform(matrix4); } - Path _transform(Float64List matrix4) native "Path_transform"; + Path _transform(Float64List matrix4) native 'Path_transform'; } /// Styles to use for blurs in [MaskFilter] objects. @@ -1358,7 +1670,7 @@ class MaskFilter { int get hashCode => hashValues(_style, _sigma); @override - String toString() => "MaskFilter.blur($_style, ${_sigma.toStringAsFixed(1)})"; + String toString() => 'MaskFilter.blur($_style, ${_sigma.toStringAsFixed(1)})'; } /// A description of a color filter to apply when drawing a shape or compositing @@ -1396,35 +1708,39 @@ class ColorFilter { int get hashCode => hashValues(_color, _blendMode); @override - String toString() => "ColorFilter($_color, $_blendMode)"; + String toString() => 'ColorFilter($_color, $_blendMode)'; } /// A filter operation to apply to a raster image. /// -/// See [SceneBuilder.pushBackdropFilter]. +/// See also: +/// +/// * [BackdropFilter], a widget that applies [ImageFilter] to its rendering. +/// * [SceneBuilder.pushBackdropFilter], which is the low-level API for using +/// this class. class ImageFilter extends NativeFieldWrapperClass2 { - void _constructor() native "ImageFilter_constructor"; + void _constructor() native 'ImageFilter_constructor'; /// A source filter containing an image. // ImageFilter.image({ Image image }) { // _constructor(); // _initImage(image); // } - // void _initImage(Image image) native "ImageFilter_initImage"; + // void _initImage(Image image) native 'ImageFilter_initImage'; /// A source filter containing a picture. // ImageFilter.picture({ Picture picture }) { // _constructor(); // _initPicture(picture); // } - // void _initPicture(Picture picture) native "ImageFilter_initPicture"; + // void _initPicture(Picture picture) native 'ImageFilter_initPicture'; /// Creates an image filter that applies a Gaussian blur. ImageFilter.blur({ double sigmaX: 0.0, double sigmaY: 0.0 }) { _constructor(); _initBlur(sigmaX, sigmaY); } - void _initBlur(double sigmaX, double sigmaY) native "ImageFilter_initBlur"; + void _initBlur(double sigmaX, double sigmaY) native 'ImageFilter_initBlur'; } /// Base class for objects such as [Gradient] and [ImageShader] which @@ -1457,7 +1773,6 @@ enum TileMode { /// The gradient will paint the all the regions outside the inner area with /// the color of the point closest to that region. /// - /// ![](https://flutter.github.io/assets-for-api-docs/dart-ui/tile_mode_clamp_linear.png) /// ![](https://flutter.github.io/assets-for-api-docs/dart-ui/tile_mode_clamp_radial.png) clamp, @@ -1527,7 +1842,7 @@ class Gradient extends Shader { /// Use the [new Gradient.linear] or [new Gradient.radial] constructors to /// obtain a usable [Gradient] object. Gradient(); - void _constructor() native "Gradient_constructor"; + void _constructor() native 'Gradient_constructor'; /// Creates a linear gradient from `from` to `to`. /// @@ -1550,13 +1865,12 @@ class Gradient extends Shader { Offset from, Offset to, List colors, [ - List colorStops = null, + List colorStops, TileMode tileMode = TileMode.clamp, - ]) { - assert(_offsetIsValid(from)); - assert(_offsetIsValid(to)); - assert(colors != null); - assert(tileMode != null); + ]) : assert(_offsetIsValid(from)), + assert(_offsetIsValid(to)), + assert(colors != null), + assert(tileMode != null) { _validateColorStops(colors, colorStops); final Float32List endPointsBuffer = _encodeTwoPoints(from, to); final Int32List colorsBuffer = _encodeColorList(colors); @@ -1564,7 +1878,7 @@ class Gradient extends Shader { _constructor(); _initLinear(endPointsBuffer, colorsBuffer, colorStopsBuffer, tileMode.index); } - void _initLinear(Float32List endPoints, Int32List colors, Float32List colorStops, int tileMode) native "Gradient_initLinear"; + void _initLinear(Float32List endPoints, Int32List colors, Float32List colorStops, int tileMode) native 'Gradient_initLinear'; /// Creates a radial gradient centered at `center` that ends at `radius` /// distance from the center. @@ -1584,22 +1898,22 @@ class Gradient extends Shader { /// If `center`, `radius`, `colors`, or `tileMode` are null, or if `colors` or /// `colorStops` contain null values, this constructor will throw a /// [NoSuchMethodError]. - Gradient.radial(Offset center, - double radius, - List colors, [ - List colorStops = null, - TileMode tileMode = TileMode.clamp, - ]) { - assert(_offsetIsValid(center)); - assert(colors != null); - assert(tileMode != null); + Gradient.radial( + Offset center, + double radius, + List colors, [ + List colorStops, + TileMode tileMode = TileMode.clamp, + ]) : assert(_offsetIsValid(center)), + assert(colors != null), + assert(tileMode != null) { _validateColorStops(colors, colorStops); final Int32List colorsBuffer = _encodeColorList(colors); final Float32List colorStopsBuffer = colorStops == null ? null : new Float32List.fromList(colorStops); _constructor(); _initRadial(center.dx, center.dy, radius, colorsBuffer, colorStopsBuffer, tileMode.index); } - void _initRadial(double centerX, double centerY, double radius, Int32List colors, Float32List colorStops, int tileMode) native "Gradient_initRadial"; + void _initRadial(double centerX, double centerY, double radius, Int32List colors, Float32List colorStops, int tileMode) native 'Gradient_initRadial'; static void _validateColorStops(List colors, List colorStops) { if (colorStops == null) { @@ -1619,18 +1933,18 @@ class ImageShader extends Shader { /// direction and y direction respectively. The fourth argument gives the /// matrix to apply to the effect. All the arguments are required and must not /// be null. - ImageShader(Image image, TileMode tmx, TileMode tmy, Float64List matrix4) { - assert(image != null); // image is checked on the engine side - assert(tmx != null); - assert(tmy != null); - assert(matrix4 != null); + ImageShader(Image image, TileMode tmx, TileMode tmy, Float64List matrix4) : + assert(image != null), // image is checked on the engine side + assert(tmx != null), + assert(tmy != null), + assert(matrix4 != null) { if (matrix4.length != 16) throw new ArgumentError('"matrix4" must have 16 entries.'); _constructor(); _initWithImage(image, tmx.index, tmy.index, matrix4); } - void _constructor() native "ImageShader_constructor"; - void _initWithImage(Image image, int tmx, int tmy, Float64List matrix4) native "ImageShader_initWithImage"; + void _constructor() native 'ImageShader_constructor'; + void _initWithImage(Image image, int tmx, int tmy, Float64List matrix4) native 'ImageShader_initWithImage'; } /// Defines how a list of points is interpreted when drawing a set of triangles. @@ -1656,9 +1970,8 @@ class Vertices extends NativeFieldWrapperClass2 { List textureCoordinates, List colors, List indices, - }) { - assert(mode != null); - assert(positions != null); + }) : assert(mode != null), + assert(positions != null) { if (textureCoordinates != null && textureCoordinates.length != positions.length) throw new ArgumentError('"positions" and "textureCoordinates" lengths must match.'); if (colors != null && colors.length != positions.length) @@ -1666,11 +1979,16 @@ class Vertices extends NativeFieldWrapperClass2 { 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.'); - Float32List encodedPositions = _encodePointList(positions); - Float32List encodedTextureCoordinates = (textureCoordinates != null) ? - _encodePointList(textureCoordinates) : null; - Int32List encodedColors = colors != null ? _encodeColorList(colors) : null; - Int32List encodedIndices = indices != null ? new Int32List.fromList(indices) : null; + final Float32List encodedPositions = _encodePointList(positions); + final Float32List encodedTextureCoordinates = (textureCoordinates != null) + ? _encodePointList(textureCoordinates) + : null; + final Int32List encodedColors = colors != null + ? _encodeColorList(colors) + : null; + final Int32List encodedIndices = indices != null + ? new Int32List.fromList(indices) + : null; _constructor(); _init(mode.index, encodedPositions, encodedTextureCoordinates, encodedColors, encodedIndices); @@ -1682,9 +2000,8 @@ class Vertices extends NativeFieldWrapperClass2 { Float32List textureCoordinates, Int32List colors, Int32List indices, - }) { - assert(mode != null); - assert(positions != null); + }) : assert(mode != null), + assert(positions != null) { if (textureCoordinates != null && textureCoordinates.length != positions.length) throw new ArgumentError('"positions" and "textureCoordinates" lengths must match.'); if (colors != null && colors.length * 2 != positions.length) @@ -1696,13 +2013,13 @@ class Vertices extends NativeFieldWrapperClass2 { _init(mode.index, positions, textureCoordinates, colors, indices); } - void _constructor() native "Vertices_constructor"; + void _constructor() native 'Vertices_constructor'; void _init(int mode, Float32List positions, Float32List textureCoordinates, Int32List colors, - Int32List indices) native "Vertices_init"; + Int32List indices) native 'Vertices_init'; } /// Defines how a list of points is interpreted when drawing a set of points. @@ -1779,8 +2096,7 @@ class Canvas extends NativeFieldWrapperClass2 { /// /// To end the recording, call [PictureRecorder.endRecording] on the /// given recorder. - Canvas(PictureRecorder recorder, [ Rect cullRect ]) { - assert(recorder != null); + Canvas(PictureRecorder recorder, [ Rect cullRect ]) : assert(recorder != null) { if (recorder.isRecording) throw new ArgumentError('"recorder" must not already be associated with another Canvas.'); cullRect ??= Rect.largest; @@ -1790,7 +2106,7 @@ class Canvas extends NativeFieldWrapperClass2 { double left, double top, double right, - double bottom) native "Canvas_constructor"; + double bottom) native 'Canvas_constructor'; /// Saves a copy of the current transform and clip on the save stack. /// @@ -1800,7 +2116,7 @@ class Canvas extends NativeFieldWrapperClass2 { /// /// * [saveLayer], which does the same thing but additionally also groups the /// commands done until the matching [restore]. - void save() native "Canvas_save"; + void save() native 'Canvas_save'; /// Saves a copy of the current transform and clip on the save stack, and then /// creates a new group which subsequent calls will become a part of. When the @@ -1922,13 +2238,13 @@ class Canvas extends NativeFieldWrapperClass2 { } } void _saveLayerWithoutBounds(List paintObjects, ByteData paintData) - native "Canvas_saveLayerWithoutBounds"; + native 'Canvas_saveLayerWithoutBounds'; void _saveLayer(double left, double top, double right, double bottom, List paintObjects, - ByteData paintData) native "Canvas_saveLayer"; + ByteData paintData) native 'Canvas_saveLayer'; /// Pops the current save stack, if there is anything to pop. /// Otherwise, does nothing. @@ -1937,7 +2253,7 @@ class Canvas extends NativeFieldWrapperClass2 { /// /// If the state was pushed with with [saveLayer], then this call will also /// cause the new layer to be composited into the previous layer. - void restore() native "Canvas_restore"; + void restore() native 'Canvas_restore'; /// Returns the number of items on the save stack, including the /// initial state. This means it returns 1 for a clean canvas, and @@ -1945,25 +2261,25 @@ class Canvas extends NativeFieldWrapperClass2 { /// each matching call to [restore] decrements it. /// /// This number cannot go below 1. - int getSaveCount() native "Canvas_getSaveCount"; + int getSaveCount() native 'Canvas_getSaveCount'; /// Add a translation to the current transform, shifting the coordinate space /// horizontally by the first argument and vertically by the second argument. - void translate(double dx, double dy) native "Canvas_translate"; + void translate(double dx, double dy) native 'Canvas_translate'; /// Add an axis-aligned scale to the current transform, scaling by the first /// argument in the horizontal direction and the second in the vertical /// direction. - void scale(double sx, double sy) native "Canvas_scale"; + void scale(double sx, double sy) native 'Canvas_scale'; /// Add a rotation to the current transform. The argument is in radians clockwise. - void rotate(double radians) native "Canvas_rotate"; + void rotate(double radians) native 'Canvas_rotate'; /// Add an axis-aligned skew to the current transform, with the first argument /// being the horizontal skew in radians clockwise around the origin, and the /// second argument being the vertical skew in radians clockwise around the /// origin. - void skew(double sx, double sy) native "Canvas_skew"; + void skew(double sx, double sy) native 'Canvas_skew'; /// Multiply the current transform by the specified 4⨉4 transformation matrix /// specified as a list of values in column-major order. @@ -1973,7 +2289,7 @@ class Canvas extends NativeFieldWrapperClass2 { throw new ArgumentError('"matrix4" must have 16 entries.'); _transform(matrix4); } - void _transform(Float64List matrix4) native "Canvas_transform"; + void _transform(Float64List matrix4) native 'Canvas_transform'; /// Reduces the clip region to the intersection of the current clip and the /// given rectangle. @@ -1995,7 +2311,7 @@ class Canvas extends NativeFieldWrapperClass2 { double top, double right, double bottom, - int clipOp) native "Canvas_clipRect"; + int clipOp) native 'Canvas_clipRect'; /// Reduces the clip region to the intersection of the current clip and the /// given rounded rectangle. @@ -2008,7 +2324,7 @@ class Canvas extends NativeFieldWrapperClass2 { assert(_rrectIsValid(rrect)); _clipRRect(rrect._value); } - void _clipRRect(Float32List rrect) native "Canvas_clipRRect"; + void _clipRRect(Float32List rrect) native 'Canvas_clipRRect'; /// Reduces the clip region to the intersection of the current clip and the /// given [Path]. @@ -2021,7 +2337,7 @@ class Canvas extends NativeFieldWrapperClass2 { assert(path != null); // path is checked on the engine side _clipPath(path); } - void _clipPath(Path path) native "Canvas_clipPath"; + void _clipPath(Path path) native 'Canvas_clipPath'; /// Paints the given [Color] onto the canvas, applying the given /// [BlendMode], with the given color being the source and the background @@ -2031,7 +2347,7 @@ class Canvas extends NativeFieldWrapperClass2 { assert(blendMode != null); _drawColor(color.value, blendMode.index); } - void _drawColor(int color, int blendMode) native "Canvas_drawColor"; + void _drawColor(int color, int blendMode) native 'Canvas_drawColor'; /// Draws a line between the given points using the given paint. The line is /// stroked, the value of the [Paint.style] is ignored for this call. @@ -2048,7 +2364,7 @@ class Canvas extends NativeFieldWrapperClass2 { double x2, double y2, List paintObjects, - ByteData paintData) native "Canvas_drawLine"; + ByteData paintData) native 'Canvas_drawLine'; /// Fills the canvas with the given [Paint]. /// @@ -2058,7 +2374,7 @@ class Canvas extends NativeFieldWrapperClass2 { assert(paint != null); _drawPaint(paint._objects, paint._data); } - void _drawPaint(List paintObjects, ByteData paintData) native "Canvas_drawPaint"; + void _drawPaint(List paintObjects, ByteData paintData) native 'Canvas_drawPaint'; /// Draws a rectangle with the given [Paint]. Whether the rectangle is filled /// or stroked (or both) is controlled by [Paint.style]. @@ -2073,7 +2389,7 @@ class Canvas extends NativeFieldWrapperClass2 { double right, double bottom, List paintObjects, - ByteData paintData) native "Canvas_drawRect"; + ByteData paintData) native 'Canvas_drawRect'; /// Draws a rounded rectangle with the given [Paint]. Whether the rectangle is /// filled or stroked (or both) is controlled by [Paint.style]. @@ -2084,7 +2400,7 @@ class Canvas extends NativeFieldWrapperClass2 { } void _drawRRect(Float32List rrect, List paintObjects, - ByteData paintData) native "Canvas_drawRRect"; + ByteData paintData) native 'Canvas_drawRRect'; /// Draws a shape consisting of the difference between two rounded rectangles /// with the given [Paint]. Whether this shape is filled or stroked (or both) @@ -2100,7 +2416,7 @@ class Canvas extends NativeFieldWrapperClass2 { void _drawDRRect(Float32List outer, Float32List inner, List paintObjects, - ByteData paintData) native "Canvas_drawDRRect"; + ByteData paintData) native 'Canvas_drawDRRect'; /// Draws an axis-aligned oval that fills the given axis-aligned rectangle /// with the given [Paint]. Whether the oval is filled or stroked (or both) is @@ -2116,7 +2432,7 @@ class Canvas extends NativeFieldWrapperClass2 { double right, double bottom, List paintObjects, - ByteData paintData) native "Canvas_drawOval"; + ByteData paintData) native 'Canvas_drawOval'; /// Draws a circle centered at the point given by the first argument and /// that has the radius given by the second argument, with the [Paint] given in @@ -2131,7 +2447,7 @@ class Canvas extends NativeFieldWrapperClass2 { double y, double radius, List paintObjects, - ByteData paintData) native "Canvas_drawCircle"; + ByteData paintData) native 'Canvas_drawCircle'; /// Draw an arc scaled to fit inside the given rectangle. It starts from /// startAngle radians around the oval up to startAngle + sweepAngle @@ -2157,7 +2473,7 @@ class Canvas extends NativeFieldWrapperClass2 { double sweepAngle, bool useCenter, List paintObjects, - ByteData paintData) native "Canvas_drawArc"; + ByteData paintData) native 'Canvas_drawArc'; /// Draws the given [Path] with the given [Paint]. Whether this shape is /// filled or stroked (or both) is controlled by [Paint.style]. If the path is @@ -2169,7 +2485,7 @@ class Canvas extends NativeFieldWrapperClass2 { } void _drawPath(Path path, List paintObjects, - ByteData paintData) native "Canvas_drawPath"; + ByteData paintData) native 'Canvas_drawPath'; /// Draws the given [Image] into the canvas with its top-left corner at the /// given [Offset]. The image is composited into the canvas using the given [Paint]. @@ -2183,7 +2499,7 @@ class Canvas extends NativeFieldWrapperClass2 { double x, double y, List paintObjects, - ByteData paintData) native "Canvas_drawImage"; + ByteData paintData) native 'Canvas_drawImage'; /// Draws the subset of the given image described by the `src` argument into /// the canvas in the axis-aligned rectangle given by the `dst` argument. @@ -2221,7 +2537,7 @@ class Canvas extends NativeFieldWrapperClass2 { double dstRight, double dstBottom, List paintObjects, - ByteData paintData) native "Canvas_drawImageRect"; + ByteData paintData) native 'Canvas_drawImageRect'; /// Draws the given [Image] into the canvas using the given [Paint]. /// @@ -2263,7 +2579,7 @@ class Canvas extends NativeFieldWrapperClass2 { double dstRight, double dstBottom, List paintObjects, - ByteData paintData) native "Canvas_drawImageNine"; + ByteData paintData) native 'Canvas_drawImageNine'; /// Draw the given picture onto the canvas. To create a picture, see /// [PictureRecorder]. @@ -2271,7 +2587,7 @@ class Canvas extends NativeFieldWrapperClass2 { assert(picture != null); // picture is checked on the engine side _drawPicture(picture); } - void _drawPicture(Picture picture) native "Canvas_drawPicture"; + void _drawPicture(Picture picture) native 'Canvas_drawPicture'; /// Draws the text in the given [Paragraph] into this canvas at the given /// [Offset]. @@ -2335,7 +2651,7 @@ class Canvas extends NativeFieldWrapperClass2 { void _drawPoints(List paintObjects, ByteData paintData, int pointMode, - Float32List points) native "Canvas_drawPoints"; + Float32List points) native 'Canvas_drawPoints'; void drawVertices(Vertices vertices, BlendMode blendMode, Paint paint) { assert(vertices != null); // vertices is checked on the engine side @@ -2346,7 +2662,7 @@ class Canvas extends NativeFieldWrapperClass2 { void _drawVertices(Vertices vertices, int blendMode, List paintObjects, - ByteData paintData) native "Canvas_drawVertices"; + ByteData paintData) native 'Canvas_drawVertices'; // // See also: @@ -2453,7 +2769,7 @@ class Canvas extends NativeFieldWrapperClass2 { Float32List rects, Int32List colors, int blendMode, - Float32List cullRect) native "Canvas_drawAtlas"; + Float32List cullRect) native 'Canvas_drawAtlas'; /// Draws a shadow for a [Path] representing the given material elevation. /// @@ -2470,7 +2786,7 @@ class Canvas extends NativeFieldWrapperClass2 { void _drawShadow(Path path, int color, double elevation, - bool transparentOccluder) native "Canvas_drawShadow"; + bool transparentOccluder) native 'Canvas_drawShadow'; } /// An object representing a sequence of recorded graphical operations. @@ -2494,11 +2810,11 @@ abstract class Picture extends NativeFieldWrapperClass2 { /// /// Although the image is returned synchronously, the picture is actually /// rasterized the first time the image is drawn and then cached. - Image toImage(int width, int height) native "Picture_toImage"; + Image toImage(int width, int height) native 'Picture_toImage'; /// Release the resources used by this object. The object is no longer usable /// after this method is called. - void dispose() native "Picture_dispose"; + void dispose() native 'Picture_dispose'; } /// Records a [Picture] containing a sequence of graphical operations. @@ -2510,7 +2826,7 @@ class PictureRecorder extends NativeFieldWrapperClass2 { /// [Canvas] and begin recording, pass this [PictureRecorder] to the /// [Canvas] constructor. PictureRecorder() { _constructor(); } - void _constructor() native "PictureRecorder_constructor"; + void _constructor() native 'PictureRecorder_constructor'; /// Whether this object is currently recording commands. /// @@ -2519,7 +2835,7 @@ class PictureRecorder extends NativeFieldWrapperClass2 { /// call to [endRecording], and false if either this /// [PictureRecorder] has not yet been associated with a [Canvas], /// or the [endRecording] method has already been called. - bool get isRecording native "PictureRecorder_isRecording"; + bool get isRecording native 'PictureRecorder_isRecording'; /// Finishes recording graphical operations. /// @@ -2528,7 +2844,7 @@ class PictureRecorder extends NativeFieldWrapperClass2 { /// and the canvas objects are invalid and cannot be used further. /// /// Returns null if the PictureRecorder is not associated with a canvas. - Picture endRecording() native "PictureRecorder_endRecording"; + Picture endRecording() native 'PictureRecorder_endRecording'; } /// Generic callback signature, used by [_futurize]. @@ -2558,7 +2874,7 @@ typedef String _Callbacker(_Callback callback); /// Future _futurize(_Callbacker callbacker) { final Completer completer = new Completer.sync(); - final String err = callbacker((t) { + final String err = callbacker((T t) { if (t == null) { completer.completeError(new Exception('operation failed')); } else { diff --git a/lib/ui/semantics.dart b/lib/ui/semantics.dart index d191bd7a089..4b9a7f1e81f 100644 --- a/lib/ui/semantics.dart +++ b/lib/ui/semantics.dart @@ -265,7 +265,7 @@ class SemanticsFlag { class SemanticsUpdateBuilder extends NativeFieldWrapperClass2 { /// Creates an empty [SemanticsUpdateBuilder] object. SemanticsUpdateBuilder() { _constructor(); } - void _constructor() native "SemanticsUpdateBuilder_constructor"; + void _constructor() native 'SemanticsUpdateBuilder_constructor'; /// Update the information associated with the node with the given `id`. /// @@ -310,25 +310,27 @@ class SemanticsUpdateBuilder extends NativeFieldWrapperClass2 { String decreasedValue, TextDirection textDirection, Float64List transform, - Int32List children + Int32List children, }) { if (transform.length != 16) throw new ArgumentError('transform argument must have 16 entries.'); - _updateNode(id, - flags, - actions, - rect.left, - rect.top, - rect.right, - rect.bottom, - label, - hint, - value, - increasedValue, - decreasedValue, - textDirection != null ? textDirection.index + 1 : 0, - transform, - children); + _updateNode( + id, + flags, + actions, + rect.left, + rect.top, + rect.right, + rect.bottom, + label, + hint, + value, + increasedValue, + decreasedValue, + textDirection != null ? textDirection.index + 1 : 0, + transform, + children, + ); } void _updateNode( int id, @@ -345,15 +347,15 @@ class SemanticsUpdateBuilder extends NativeFieldWrapperClass2 { String decreasedValue, int textDirection, Float64List transform, - Int32List children - ) native "SemanticsUpdateBuilder_updateNode"; + Int32List children, + ) native 'SemanticsUpdateBuilder_updateNode'; /// Creates a [SemanticsUpdate] object that encapsulates the updates recorded /// by this object. /// /// The returned object can be passed to [Window.updateSemantics] to actually /// update the semantics retained by the system. - SemanticsUpdate build() native "SemanticsUpdateBuilder_build"; + SemanticsUpdate build() native 'SemanticsUpdateBuilder_build'; } /// An opaque object representing a batch of semantics updates. @@ -373,5 +375,5 @@ class SemanticsUpdate extends NativeFieldWrapperClass2 { /// /// After calling this function, the semantics update is cannot be used /// further. - void dispose() native "SemanticsUpdateBuilder_dispose"; + void dispose() native 'SemanticsUpdateBuilder_dispose'; } diff --git a/lib/ui/text.dart b/lib/ui/text.dart index 2194c51bdd7..eda82de1a27 100644 --- a/lib/ui/text.dart +++ b/lib/ui/text.dart @@ -54,7 +54,7 @@ class FontWeight { static const FontWeight bold = w700; /// A list of all the font weights. - static const List values = const [ + static const List values = const [ w100, w200, w300, w400, w500, w600, w700, w800, w900 ]; @@ -83,6 +83,7 @@ class FontWeight { return values[lerpDouble(a?.index ?? normal.index, b?.index ?? normal.index, t).round().clamp(0, 8)]; } + @override String toString() { return const { 0: 'FontWeight.w100', @@ -133,10 +134,10 @@ enum TextAlign { /// A horizontal line used for aligning text. enum TextBaseline { - // The horizontal line used to align the bottom of glyphs for alphabetic characters. + /// The horizontal line used to align the bottom of glyphs for alphabetic characters. alphabetic, - // The horizontal line used to align ideographic characters. + /// The horizontal line used to align ideographic characters. ideographic, } @@ -186,7 +187,7 @@ class TextDecoration { String toString() { if (_mask == 0) return 'TextDecoration.none'; - List values = []; + final List values = []; if (_mask & underline._mask != 0) values.add('underline'); if (_mask & overline._mask != 0) @@ -242,19 +243,21 @@ enum TextDecorationStyle { // // - Element 7: The enum index of the |textBaseline|. // -Int32List _encodeTextStyle(Color color, - TextDecoration decoration, - Color decorationColor, - TextDecorationStyle decorationStyle, - FontWeight fontWeight, - FontStyle fontStyle, - TextBaseline textBaseline, - String fontFamily, - double fontSize, - double letterSpacing, - double wordSpacing, - double height) { - Int32List result = new Int32List(8); +Int32List _encodeTextStyle( + Color color, + TextDecoration decoration, + Color decorationColor, + TextDecorationStyle decorationStyle, + FontWeight fontWeight, + FontStyle fontStyle, + TextBaseline textBaseline, + String fontFamily, + double fontSize, + double letterSpacing, + double wordSpacing, + double height, +) { + final Int32List result = new Int32List(8); if (color != null) { result[0] |= 1 << 1; result[1] = color.value; @@ -334,19 +337,21 @@ class TextStyle { double fontSize, double letterSpacing, double wordSpacing, - double height - }) : _encoded = _encodeTextStyle(color, - decoration, - decorationColor, - decorationStyle, - fontWeight, - fontStyle, - textBaseline, - fontFamily, - fontSize, - letterSpacing, - wordSpacing, - height), + double height, + }) : _encoded = _encodeTextStyle( + color, + decoration, + decorationColor, + decorationStyle, + fontWeight, + fontStyle, + textBaseline, + fontFamily, + fontSize, + letterSpacing, + wordSpacing, + height, + ), _fontFamily = fontFamily ?? '', _fontSize = fontSize, _letterSpacing = letterSpacing, @@ -360,6 +365,7 @@ class TextStyle { final double _wordSpacing; final double _height; + @override bool operator ==(dynamic other) { if (identical(this, other)) return true; @@ -379,8 +385,10 @@ class TextStyle { return true; } + @override int get hashCode => hashValues(hashList(_encoded), _fontFamily, _fontSize, _letterSpacing, _wordSpacing, _height); + @override String toString() { return 'TextStyle(' 'color: ${ _encoded[0] & 0x0002 == 0x0002 ? new Color(_encoded[1]) : "unspecified"}, ' @@ -416,16 +424,18 @@ class TextStyle { // // - Element 4: The value of |maxLines|. // -Int32List _encodeParagraphStyle(TextAlign textAlign, - TextDirection textDirection, - FontWeight fontWeight, - FontStyle fontStyle, - int maxLines, - String fontFamily, - double fontSize, - double lineHeight, - String ellipsis) { - Int32List result = new Int32List(6); // also update paragraph_builder.cc +Int32List _encodeParagraphStyle( + TextAlign textAlign, + TextDirection textDirection, + FontWeight fontWeight, + FontStyle fontStyle, + int maxLines, + String fontFamily, + double fontSize, + double lineHeight, + String ellipsis, +) { + final Int32List result = new Int32List(6); // also update paragraph_builder.cc if (textAlign != null) { result[0] |= 1 << 1; result[1] = textAlign.index; @@ -521,15 +531,17 @@ class ParagraphStyle { double fontSize, double lineHeight, String ellipsis, - }) : _encoded = _encodeParagraphStyle(textAlign, - textDirection, - fontWeight, - fontStyle, - maxLines, - fontFamily, - fontSize, - lineHeight, - ellipsis), + }) : _encoded = _encodeParagraphStyle( + textAlign, + textDirection, + fontWeight, + fontStyle, + maxLines, + fontFamily, + fontSize, + lineHeight, + ellipsis, + ), _fontFamily = fontFamily, _fontSize = fontSize, _lineHeight = lineHeight, @@ -541,6 +553,7 @@ class ParagraphStyle { final double _lineHeight; final String _ellipsis; + @override bool operator ==(dynamic other) { if (identical(this, other)) return true; @@ -559,8 +572,10 @@ class ParagraphStyle { return true; } + @override int get hashCode => hashValues(hashList(_encoded), _fontFamily, _fontSize, _lineHeight, _ellipsis); + @override String toString() { return '$runtimeType(' 'textAlign: ${ _encoded[0] & 0x002 == 0x002 ? TextAlign.values[_encoded[1]] : "unspecified"}, ' @@ -828,9 +843,9 @@ class ParagraphConstraints { /// Creates constraints for laying out a pargraph. /// /// The [width] argument must not be null. - ParagraphConstraints({ this.width }) { - assert(width != null); - } + ParagraphConstraints({ + this.width, + }) : assert(width != null); /// The width the paragraph should use whey computing the positions of glyphs. /// @@ -885,32 +900,32 @@ abstract class Paragraph extends NativeFieldWrapperClass2 { /// The amount of horizontal space this paragraph occupies. /// /// Valid only after [layout] has been called. - double get width native "Paragraph_width"; + double get width native 'Paragraph_width'; /// The amount of vertical space this paragraph occupies. /// /// Valid only after [layout] has been called. - double get height native "Paragraph_height"; + double get height native 'Paragraph_height'; /// The minimum width that this paragraph could be without failing to paint /// its contents within itself. /// /// Valid only after [layout] has been called. - double get minIntrinsicWidth native "Paragraph_minIntrinsicWidth"; + double get minIntrinsicWidth native 'Paragraph_minIntrinsicWidth'; /// Returns the smallest width beyond which increasing the width never /// decreases the height. /// /// Valid only after [layout] has been called. - double get maxIntrinsicWidth native "Paragraph_maxIntrinsicWidth"; + double get maxIntrinsicWidth native 'Paragraph_maxIntrinsicWidth'; /// The distance from the top of the paragraph to the alphabetic /// baseline of the first line, in logical pixels. - double get alphabeticBaseline native "Paragraph_alphabeticBaseline"; + double get alphabeticBaseline native 'Paragraph_alphabeticBaseline'; /// The distance from the top of the paragraph to the ideographic /// baseline of the first line, in logical pixels. - double get ideographicBaseline native "Paragraph_ideographicBaseline"; + double get ideographicBaseline native 'Paragraph_ideographicBaseline'; /// True if there is more vertical content, but the text was truncated, either /// because we reached `maxLines` lines of text or because the `maxLines` was @@ -919,35 +934,35 @@ abstract class Paragraph extends NativeFieldWrapperClass2 { /// /// See the discussion of the `maxLines` and `ellipsis` arguments at [new /// ParagraphStyle]. - bool get didExceedMaxLines native "Paragraph_didExceedMaxLines"; + bool get didExceedMaxLines native 'Paragraph_didExceedMaxLines'; /// Computes the size and position of each glyph in the paragraph. /// /// The [ParagraphConstraints] control how wide the text is allowed to be. void layout(ParagraphConstraints constraints) => _layout(constraints.width); - void _layout(double width) native "Paragraph_layout"; + void _layout(double width) native 'Paragraph_layout'; /// Returns a list of text boxes that enclose the given text range. - List getBoxesForRange(int start, int end) native "Paragraph_getRectsForRange"; + List getBoxesForRange(int start, int end) native 'Paragraph_getRectsForRange'; /// Returns the text position closest to the given offset. TextPosition getPositionForOffset(Offset offset) { - List encoded = _getPositionForOffset(offset.dx, offset.dy); + final List encoded = _getPositionForOffset(offset.dx, offset.dy); return new TextPosition(offset: encoded[0], affinity: TextAffinity.values[encoded[1]]); } - List _getPositionForOffset(double dx, double dy) native "Paragraph_getPositionForOffset"; + List _getPositionForOffset(double dx, double dy) native 'Paragraph_getPositionForOffset'; /// Returns the [start, end] of the word at the given offset. Characters not /// part of a word, such as spaces, symbols, and punctuation, have word breaks /// on both sides. In such cases, this method will return [offset, offset+1]. /// Word boundaries are defined more precisely in Unicode Standard Annex #29 /// http://www.unicode.org/reports/tr29/#Word_Boundaries - List getWordBoundary(int offset) native "Paragraph_getWordBoundary"; + List getWordBoundary(int offset) native 'Paragraph_getWordBoundary'; // Redirecting the paint function in this way solves some dependency problems // in the C++ code. If we straighten out the C++ dependencies, we can remove // this indirection. - void _paint(Canvas canvas, double x, double y) native "Paragraph_paint"; + void _paint(Canvas canvas, double x, double y) native 'Paragraph_paint'; } /// Builds a [Paragraph] containing text with the given styling information. @@ -968,13 +983,13 @@ class ParagraphBuilder extends NativeFieldWrapperClass2 { /// Creates a [ParagraphBuilder] object, which is used to create a /// [Paragraph]. ParagraphBuilder(ParagraphStyle style) { _constructor(style._encoded, style._fontFamily, style._fontSize, style._lineHeight, style._ellipsis); } - void _constructor(Int32List encoded, String fontFamily, double fontSize, double lineHeight, String ellipsis) native "ParagraphBuilder_constructor"; + void _constructor(Int32List encoded, String fontFamily, double fontSize, double lineHeight, String ellipsis) native 'ParagraphBuilder_constructor'; /// Applies the given style to the added text until [pop] is called. /// /// See [pop] for details. void pushStyle(TextStyle style) => _pushStyle(style._encoded, style._fontFamily, style._fontSize, style._letterSpacing, style._wordSpacing, style._height); - void _pushStyle(Int32List encoded, String fontFamily, double fontSize, double letterSpacing, double wordSpacing, double height) native "ParagraphBuilder_pushStyle"; + void _pushStyle(Int32List encoded, String fontFamily, double fontSize, double letterSpacing, double wordSpacing, double height) native 'ParagraphBuilder_pushStyle'; /// Ends the effect of the most recent call to [pushStyle]. /// @@ -982,22 +997,22 @@ class ParagraphBuilder extends NativeFieldWrapperClass2 { /// added to the paragraph is affected by all the styles in the stack. Calling /// [pop] removes the topmost style in the stack, leaving the remaining styles /// in effect. - void pop() native "ParagraphBuilder_pop"; + void pop() native 'ParagraphBuilder_pop'; /// Adds the given text to the paragraph. /// /// The text will be styled according to the current stack of text styles. void addText(String text) { - String error = _addText(text); + final String error = _addText(text); if (error != null) throw new ArgumentError(error); } - String _addText(String text) native "ParagraphBuilder_addText"; + String _addText(String text) native 'ParagraphBuilder_addText'; /// Applies the given paragraph style and returns a [Paragraph] containing the /// added text and associated styling. /// /// After calling this function, the paragraph builder object is invalid and /// cannot be used further. - Paragraph build() native "ParagraphBuilder_build"; + Paragraph build() native 'ParagraphBuilder_build'; } diff --git a/lib/ui/window.dart b/lib/ui/window.dart index 2e8ea7a1b4c..ea2ba070e13 100644 --- a/lib/ui/window.dart +++ b/lib/ui/window.dart @@ -530,7 +530,7 @@ class Window { /// The route or path that the operating system requested when the application /// was launched. String get defaultRouteName => _defaultRouteName(); - String _defaultRouteName() native "Window_defaultRouteName"; + String _defaultRouteName() native 'Window_defaultRouteName'; /// Requests that, at the next appropriate opportunity, the [onBeginFrame] /// and [onDrawFrame] callbacks be invoked. @@ -539,7 +539,7 @@ class Window { /// /// * [SchedulerBinding], the Flutter framework class which manages the /// scheduling of frames. - void scheduleFrame() native "Window_scheduleFrame"; + void scheduleFrame() native 'Window_scheduleFrame'; /// Updates the application's rendering on the GPU with the newly provided /// [Scene]. This function must be called within the scope of the @@ -565,7 +565,7 @@ class Window { /// scheduling of frames. /// * [RendererBinding], the Flutter framework class which manages layout and /// painting. - void render(Scene scene) native "Window_render"; + void render(Scene scene) native 'Window_render'; /// Whether the user has requested that [updateSemantics] be called when /// the semantic contents of window changes. @@ -610,7 +610,7 @@ class Window { /// /// In either case, this function disposes the given update, which means the /// semantics update cannot be used further. - void updateSemantics(SemanticsUpdate update) native "Window_updateSemantics"; + void updateSemantics(SemanticsUpdate update) native 'Window_updateSemantics'; /// Sends a message to a platform-specific plugin. /// @@ -628,7 +628,7 @@ class Window { } void _sendPlatformMessage(String name, PlatformMessageResponseCallback callback, - ByteData data) native "Window_sendPlatformMessage"; + ByteData data) native 'Window_sendPlatformMessage'; /// Called whenever this window receives a message from a platform-specific /// plugin. @@ -653,7 +653,7 @@ class Window { /// Called by [_dispatchPlatformMessage]. void _respondToPlatformMessage(int responseId, ByteData data) - native "Window_respondToPlatformMessage"; + native 'Window_respondToPlatformMessage'; /// Wraps the given [callback] in another callback that ensures that the /// original callback is called in the zone it was registered in. diff --git a/tools/licenses/lib/cache.dart b/tools/licenses/lib/cache.dart index 929250c4b17..55d3928ab46 100644 --- a/tools/licenses/lib/cache.dart +++ b/tools/licenses/lib/cache.dart @@ -7,8 +7,8 @@ import 'dart:collection'; Map _cache = new LinkedHashMap(); const int _maxSize = 10; -dynamic/*=T*/ cache/**/(Key key, dynamic/*=T*/ getter()) { - dynamic/*=T*/ result = _cache[key]; +T cache(Key key, T getter()) { + T result = _cache[key]; if (result != null) { _cache.remove(key); } else { diff --git a/tools/licenses/lib/filesystem.dart b/tools/licenses/lib/filesystem.dart index 3df6b2ae36f..58344a92e63 100644 --- a/tools/licenses/lib/filesystem.dart +++ b/tools/licenses/lib/filesystem.dart @@ -136,6 +136,7 @@ FileType identifyFile(String name, Reader reader) { case '.dex': return FileType.binary; // Dalvik Executable (usually found inside .jar archives) // Dart code case '.dart': return FileType.text; + case '.dill': return FileType.binary; // Compiled Dart code // LLVM bitcode case '.bc': return FileType.binary; // Python code @@ -178,7 +179,8 @@ FileType identifyFile(String name, Reader reader) { case '.apk': return FileType.zip; // Android Package case '.crx': return FileType.binary; // Chrome extension case '.keystore': return FileType.binary; - case '.icc': return FileType.binary; + case '.icc': return FileType.binary; // Color profile + case '.swp': return FileType.binary; // Vim swap file // Archives case '.zip': return FileType.zip; // ZIP case '.tar': return FileType.tar; // Tar diff --git a/tools/licenses/lib/main.dart b/tools/licenses/lib/main.dart index 287aa6551e8..d14009a7b8f 100644 --- a/tools/licenses/lib/main.dart +++ b/tools/licenses/lib/main.dart @@ -52,7 +52,7 @@ abstract class RepositoryLicensedFile extends RepositoryFile { // file names that we are confident won't be included in the final build product static final RegExp _readmeNamePattern = new RegExp(r'\b_*(?:readme|contributing|patents)_*\b', caseSensitive: false); - static final RegExp _buildTimePattern = new RegExp(r'^(?!.*gen$)(?:CMakeLists\.txt|(?:pkgdata)?Makefile(?:\.inc)?(?:\.am|\.in|)|configure(?:\.ac|\.in)?|config\.(?:sub|guess)|.+\.m4|install-sh|.+\.sh|.+\.bat|.+\.pyc?|.+\.pl|icu-configure|.+\.gypi?|.*\.gni?|.+\.mk|.+\.cmake|.+\.gradle|.+\.yaml|vms_make\.com|pom\.xml|\.project|source\.properties)$', caseSensitive: false); + static final RegExp _buildTimePattern = new RegExp(r'^(?!.*gen$)(?:CMakeLists\.txt|(?:pkgdata)?Makefile(?:\.inc)?(?:\.am|\.in|)|configure(?:\.ac|\.in)?|config\.(?:sub|guess)|.+\.m4|install-sh|.+\.sh|.+\.bat|.+\.pyc?|.+\.pl|icu-configure|.+\.gypi?|.*\.gni?|.+\.mk|.+\.cmake|.+\.gradle|.+\.yaml|pubspec\.lock|\.packages|vms_make\.com|pom\.xml|\.project|source\.properties)$', caseSensitive: false); static final RegExp _docsPattern = new RegExp(r'^(?:INSTALL|NEWS|OWNERS|AUTHORS|ChangeLog(?:\.rst|\.[0-9]+)?|.+\.txt|.+\.md|.+\.log|.+\.css|.+\.1|doxygen\.config|.+\.spec(?:\.in)?)$', caseSensitive: false); static final RegExp _devPattern = new RegExp(r'^(?:codereview\.settings|.+\.~|.+\.~[0-9]+~|\.clang-format|\.gitattributes|\.landmines|\.DS_Store|\.travis\.yml)$', caseSensitive: false); static final RegExp _testsPattern = new RegExp(r'^(?:tj(?:bench|example)test\.(?:java\.)?in|example\.c)$', caseSensitive: false); diff --git a/tools/licenses/pubspec.lock b/tools/licenses/pubspec.lock index c06d96fddac..8730d46d077 100644 --- a/tools/licenses/pubspec.lock +++ b/tools/licenses/pubspec.lock @@ -2,52 +2,60 @@ # See http://pub.dartlang.org/doc/glossary.html#lockfile packages: archive: + dependency: "direct main" description: name: archive url: "https://pub.dartlang.org" source: hosted - version: "1.0.27" + version: "1.0.33" args: + dependency: "direct main" description: name: args url: "https://pub.dartlang.org" source: hosted version: "0.13.7" charcode: + dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted version: "1.1.1" collection: + dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.9.1" + version: "1.14.5" convert: + dependency: transitive description: name: convert url: "https://pub.dartlang.org" source: hosted version: "2.0.1" crypto: + dependency: "direct main" description: name: crypto url: "https://pub.dartlang.org" source: hosted - version: "2.0.1" + version: "2.0.2+1" path: + dependency: "direct main" description: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.4.0" + version: "1.5.1" typed_data: + dependency: transitive description: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.1.3" + version: "1.1.5" sdks: - dart: ">=1.17.0-dev.6.2 <2.0.0" + dart: ">=1.21.0 <=2.0.0-dev.16.0" diff --git a/tools/licenses/pubspec.yaml b/tools/licenses/pubspec.yaml index 0ee9032fb26..ba5a68adfac 100644 --- a/tools/licenses/pubspec.yaml +++ b/tools/licenses/pubspec.yaml @@ -3,4 +3,4 @@ dependencies: path: ^1.3.0 archive: ^1.0.24 args: 0.13.7 - crypto: ^2.0.1 + crypto: ^2.0.2+1 diff --git a/travis/analyze.sh b/travis/analyze.sh index 4278552a9c1..70f12aa6384 100755 --- a/travis/analyze.sh +++ b/travis/analyze.sh @@ -1,4 +1,25 @@ +echo "Analyzing dart:ui library..." +RESULTS=`dartanalyzer \ + --options flutter/analysis_options.yaml \ + out/host_debug_unopt/gen/sky/bindings/dart_ui/ui.dart \ + 2>&1 \ + | grep -v "Native functions can only be declared in the SDK and code that is loaded through native extensions" \ + | grep -Ev "The function '.+' (is not|isn't) used" \ + | grep -Ev "The top level variable '.+' isn't used" \ + | grep -Ev "Undefined name 'main'" \ + | grep -v "The library 'dart:_internal' is internal" \ + | grep -Ev "Unused import.+ui\.dart" \ + | grep -Ev "[0-9]+ errors.*found\." \ + | grep -Ev "Analyzing.+out/host_debug_unopt/gen/sky/bindings/dart_ui/ui\.dart"` + +echo "$RESULTS" +if [ -n "$RESULTS" ]; then + echo "Failed." + exit 1; +fi + echo "Analyzing frontend_server..." +pushd flutter/frontend_server/; pub get; popd RESULTS=`dartanalyzer \ --packages=flutter/frontend_server/.packages \ --options flutter/analysis_options.yaml \ @@ -11,35 +32,3 @@ if [ -n "$RESULTS" ]; then echo "Failed." exit 1; fi - -echo "Analyzing dart:ui library..." -RESULTS=`dartanalyzer \ - --supermixin \ - --enable-assert-initializers \ - --initializing-formal-access \ - --enable-strict-call-checks \ - --enable_type_checks \ - --strong \ - --no-implicit-dynamic \ - --package-warnings \ - --fatal-warnings \ - --fatal-hints \ - --lints \ - --fatal-lints \ - out/host_debug_unopt/gen/sky/bindings/dart_ui/ui.dart \ - 2>&1 \ - | grep -v "Native functions can only be declared in the SDK and code that is loaded through native extensions" \ - | grep -Ev "The function '.+' (is not|isn't) used" \ - | grep -Ev "Undefined name 'main'" \ - | grep -Ev "Undefined name 'VMLibraryHooks" \ - | grep -v "The library ''dart:_internal'' is internal" \ - | grep -Ev "Unused import.+ui\.dart" \ - | grep -v "TODO" \ - | grep -Ev "[0-9]+ errors.*found\." \ - | grep -Ev "Analyzing.+out/host_debug_unopt/gen/sky/bindings/dart_ui/ui\.dart"` - -echo "$RESULTS" -if [ -n "$RESULTS" ]; then - echo "Failed." - exit 1; -fi diff --git a/travis/licenses_golden/licenses_flutter b/travis/licenses_golden/licenses_flutter index ff50e3f62bd..dc718ffb2e7 100644 --- a/travis/licenses_golden/licenses_flutter +++ b/travis/licenses_golden/licenses_flutter @@ -1259,7 +1259,6 @@ ORIGIN: ../../../LICENSE TYPE: LicenseType.bsd FILE: ../../../flutter/DEPS FILE: ../../../flutter/content_handler/meta/sandbox -FILE: ../../../flutter/frontend_server/.packages FILE: ../../../flutter/frontend_server/bin/starter.dart FILE: ../../../flutter/frontend_server/lib/server.dart FILE: ../../../flutter/lib/io/dart_io.cc diff --git a/travis/licenses_golden/licenses_third_party b/travis/licenses_golden/licenses_third_party index 5eb00f83072..5315d0a7be9 100644 --- a/travis/licenses_golden/licenses_third_party +++ b/travis/licenses_golden/licenses_third_party @@ -1,4 +1,4 @@ -Signature: 73b746018e6b1764c2596c44e2e81e28 +Signature: 5eac0d88d1c8ffe7fc4768fb2eefb1eb UNUSED LICENSES: @@ -4187,13 +4187,11 @@ FILE: ../../../third_party/dart/client/idea/.idea/inspectionProfiles/Project_Def FILE: ../../../third_party/dart/client/idea/.idea/vcs.xml FILE: ../../../third_party/dart/runtime/CPPLINT.cfg FILE: ../../../third_party/dart/runtime/observatory/.analysis_options -FILE: ../../../third_party/dart/runtime/observatory/.packages FILE: ../../../third_party/dart/runtime/observatory/lib/elements.dart FILE: ../../../third_party/dart/runtime/observatory/lib/src/elements/img/chromium_icon.png FILE: ../../../third_party/dart/runtime/observatory/lib/src/elements/img/dart_icon.png FILE: ../../../third_party/dart/runtime/observatory/lib/src/elements/img/isolate_icon.png FILE: ../../../third_party/dart/runtime/observatory/maintainers/pubspec.template -FILE: ../../../third_party/dart/runtime/observatory/pubspec.lock FILE: ../../../third_party/dart/runtime/observatory/web/favicon.ico FILE: ../../../third_party/dart/runtime/observatory/web/index.html FILE: ../../../third_party/dart/runtime/observatory/web/third_party/trace_viewer_full.html @@ -4201,7 +4199,6 @@ FILE: ../../../third_party/dart/runtime/observatory/web/timeline.html FILE: ../../../third_party/dart/runtime/vm/snapshot_test_in.dat FILE: ../../../third_party/dart/samples/build_dart/test.foo FILE: ../../../third_party/dart/samples/build_dart_simple/test.foo -FILE: ../../../third_party/dart/sdk/lib/_internal/js_runtime/.packages FILE: ../../../third_party/dart/sdk/lib/html/html_common/conversions_dart2js.dart FILE: ../../../third_party/dart/sdk/lib/html/html_common/html_common.dart FILE: ../../../third_party/dart/sdk/lib/libraries.json @@ -4717,7 +4714,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. LIBRARY: dart ORIGIN: ../../../third_party/dart/runtime/bin/crypto_fuchsia.cc + ../../../third_party/dart/LICENSE TYPE: LicenseType.bsd -FILE: ../../../third_party/dart/.packages FILE: ../../../third_party/dart/runtime/bin/crypto_fuchsia.cc FILE: ../../../third_party/dart/runtime/bin/crypto_test.cc FILE: ../../../third_party/dart/runtime/bin/directory_fuchsia.cc