From 88585ef98897007eacc1895f90e1288b5624b960 Mon Sep 17 00:00:00 2001 From: Michael Goderbauer Date: Thu, 25 Aug 2022 09:57:05 -0700 Subject: [PATCH] [analysis_options] sync lint rules with flutter/flutter (#2495) --- analysis_options.yaml | 133 +++++----- .../adaptive_scaffold/example/lib/main.dart | 23 +- .../test/adaptive_layout_demo_test.dart | 2 +- .../lib/src/adaptive_scaffold.dart | 1 - packages/animations/CHANGELOG.md | 3 +- .../example/lib/container_transition.dart | 6 +- .../example/lib/fade_scale_transition.dart | 2 +- .../example/lib/fade_through_transition.dart | 2 +- .../example/lib/shared_axis_transition.dart | 5 +- .../lib/src/fade_through_transition.dart | 2 +- packages/animations/lib/src/modal.dart | 4 +- .../animations/lib/src/open_container.dart | 2 +- .../lib/src/page_transition_switcher.dart | 4 +- packages/animations/pubspec.yaml | 2 +- .../test/fade_scale_transition_test.dart | 6 - .../test/fade_through_transition_test.dart | 2 +- .../animations/test/open_container_test.dart | 12 +- .../test/page_transition_switcher_test.dart | 218 ++++++++-------- .../test/shared_axis_transition_test.dart | 6 +- packages/cross_file/CHANGELOG.md | 4 + packages/cross_file/test/x_file_io_test.dart | 2 +- .../dynamic_layouts/lib/src/dynamic_grid.dart | 4 +- .../test/dynamic_grid_test.dart | 7 +- .../CHANGELOG.md | 4 + .../example/lib/main.dart | 8 +- .../pubspec.yaml | 2 +- packages/flutter_image/CHANGELOG.md | 3 +- packages/flutter_image/lib/network.dart | 5 +- packages/flutter_image/pubspec.yaml | 2 +- packages/flutter_image/test/network_test.dart | 2 +- packages/flutter_markdown/CHANGELOG.md | 4 + .../lib/demos/basic_markdown_demo.dart | 4 +- .../lib/demos/centered_header_demo.dart | 2 + .../lib/demos/extended_emoji_demo.dart | 2 + .../demos/markdown_body_shrink_wrap_demo.dart | 3 + .../lib/demos/minimal_markdown_demo.dart | 3 + .../example/lib/demos/original_demo.dart | 3 + .../lib/demos/subscript_syntax_demo.dart | 3 + .../lib/demos/wrap_alignment_demo.dart | 4 +- .../example/lib/shared/dropdown_menu.dart | 2 +- .../flutter_markdown/example/pubspec.yaml | 5 +- .../lib/src/_functions_io.dart | 1 + .../lib/src/_functions_web.dart | 2 +- .../flutter_markdown/lib/src/builder.dart | 21 +- .../flutter_markdown/lib/src/style_sheet.dart | 104 ++++---- packages/flutter_markdown/lib/src/widget.dart | 7 +- packages/flutter_markdown/pubspec.yaml | 2 +- packages/flutter_markdown/test/html_test.dart | 6 +- .../test/image_test_mocks.dart | 50 ++-- packages/flutter_markdown/test/link_test.dart | 4 +- .../test/markdown_body_shrink_wrap_test.dart | 1 - .../test/scrollable_test.dart | 2 +- packages/flutter_markdown/test/utils.dart | 11 +- packages/fuchsia_ctl/CHANGELOG.md | 5 + packages/fuchsia_ctl/bin/main.dart | 7 +- packages/fuchsia_ctl/lib/src/amber_ctl.dart | 3 +- packages/fuchsia_ctl/lib/src/emulator.dart | 2 +- packages/fuchsia_ctl/lib/src/image_paver.dart | 2 +- .../fuchsia_ctl/lib/src/operation_result.dart | 2 +- .../fuchsia_ctl/lib/src/package_server.dart | 3 +- packages/fuchsia_ctl/lib/src/ssh_client.dart | 2 +- packages/fuchsia_ctl/pubspec.yaml | 2 +- packages/fuchsia_ctl/test/emulator_test.dart | 2 +- .../fuchsia_ctl/test/image_paver_test.dart | 2 +- packages/fuchsia_ctl/test/logger_test.dart | 2 +- .../fuchsia_ctl/test/package_server_test.dart | 1 - packages/go_router/CHANGELOG.md | 3 +- .../example/lib/books/src/screens/books.dart | 2 +- .../lib/books/src/screens/settings.dart | 2 +- .../lib/books/src/screens/sign_in.dart | 2 +- .../go_router/example/lib/named_routes.dart | 3 + .../example/lib/others/extra_param.dart | 3 + .../lib/path_and_query_parameters.dart | 3 + packages/go_router/lib/go_router.dart | 2 +- .../lib/src/information_provider.dart | 3 +- packages/go_router/lib/src/matching.dart | 3 +- .../go_router/lib/src/misc/error_screen.dart | 5 +- .../lib/src/misc/inherited_router.dart | 6 +- .../go_router/lib/src/pages/cupertino.dart | 2 +- .../lib/src/pages/custom_transition_page.dart | 32 +-- .../go_router/lib/src/pages/material.dart | 2 +- packages/go_router/lib/src/path_utils.dart | 2 +- packages/go_router/lib/src/redirection.dart | 7 +- packages/go_router/lib/src/route_data.dart | 2 +- packages/go_router/pubspec.yaml | 2 +- packages/go_router/test/cupertino_test.dart | 2 +- .../test/custom_transition_page_test.dart | 4 +- packages/go_router/test/delegate_test.dart | 2 +- packages/go_router/test/error_page_test.dart | 2 +- packages/go_router/test/go_router_test.dart | 5 +- packages/go_router/test/inherited_test.dart | 8 +- packages/go_router/test/logging_test.dart | 7 +- packages/go_router/test/material_test.dart | 2 +- packages/go_router/test/parser_test.dart | 5 +- packages/go_router/test/path_utils_test.dart | 28 +-- packages/go_router/test/test_helpers.dart | 41 ++- packages/go_router_builder/CHANGELOG.md | 4 + .../lib/src/route_config.dart | 4 +- packages/go_router_builder/pubspec.yaml | 2 +- packages/imitation_game/CHANGELOG.md | 4 + .../imitation_game/bin/imitation_game.dart | 2 + .../smiley/flutter/smiley/lib/main.dart | 10 +- packages/imitation_game/pubspec.yaml | 2 +- packages/metrics_center/CHANGELOG.md | 4 + packages/metrics_center/lib/src/gcs_lock.dart | 2 + .../lib/src/google_benchmark.dart | 3 +- packages/metrics_center/lib/src/skiaperf.dart | 9 +- packages/metrics_center/pubspec.yaml | 2 +- packages/metrics_center/test/common.dart | 2 + .../metrics_center/test/gcs_lock_test.dart | 2 + packages/multicast_dns/CHANGELOG.md | 4 + packages/multicast_dns/example/main.dart | 2 + .../multicast_dns/example/mdns_resolve.dart | 2 + packages/multicast_dns/example/mdns_sd.dart | 2 + packages/multicast_dns/lib/multicast_dns.dart | 10 +- .../lib/src/lookup_resolver.dart | 2 +- .../lib/src/native_protocol_client.dart | 2 +- packages/multicast_dns/lib/src/packet.dart | 4 +- .../lib/src/resource_record.dart | 4 +- packages/multicast_dns/pubspec.yaml | 2 +- packages/multicast_dns/test/decode_test.dart | 2 +- packages/multicast_dns/tool/packet_gen.dart | 6 +- packages/palette_generator/CHANGELOG.md | 3 +- .../palette_generator/example/lib/main.dart | 11 +- .../lib/palette_generator.dart | 26 +- .../palette_generator/palette_generator.iml | 18 -- packages/palette_generator/pubspec.yaml | 2 +- .../test/palette_generator_test.dart | 2 +- packages/pigeon/CHANGELOG.md | 4 + .../e2e_tests/test_objc/lib/dartle.dart | 4 +- packages/pigeon/lib/ast.dart | 4 +- packages/pigeon/lib/cpp_generator.dart | 20 +- packages/pigeon/lib/dart_generator.dart | 44 ++-- packages/pigeon/lib/functional.dart | 4 +- packages/pigeon/lib/generator_tools.dart | 10 +- packages/pigeon/lib/java_generator.dart | 6 +- packages/pigeon/lib/objc_generator.dart | 43 ++-- packages/pigeon/lib/pigeon.dart | 2 +- packages/pigeon/lib/pigeon_cl.dart | 2 +- packages/pigeon/lib/pigeon_lib.dart | 31 ++- packages/pigeon/lib/swift_generator.dart | 11 +- .../mock_handler_tester/test/message.dart | 4 +- .../pigeon/mock_handler_tester/test/test.dart | 4 +- packages/pigeon/pigeons/all_datatypes.dart | 4 +- .../pigeon/pigeons/flutter_unittests.dart | 4 +- packages/pigeon/pigeons/list.dart | 2 +- packages/pigeon/pigeons/primitive.dart | 8 +- .../lib/all_datatypes.dart | 4 +- .../lib/multiple_arity.gen.dart | 4 +- .../lib/non_null_fields.gen.dart | 4 +- .../lib/null_fields.gen.dart | 4 +- .../lib/null_safe_pigeon.dart | 4 +- .../lib/nullable_returns.gen.dart | 4 +- .../lib/primitive.dart | 4 +- .../test/null_fields_test.dart | 20 +- packages/pigeon/pubspec.yaml | 2 +- packages/pigeon/test/ast_generator_test.dart | 3 +- packages/pigeon/test/cpp_generator_test.dart | 111 +++------ packages/pigeon/test/dart_generator_test.dart | 168 +++++-------- .../pigeon/test/generator_tools_test.dart | 8 - packages/pigeon/test/java_generator_test.dart | 123 +++------ packages/pigeon/test/objc_generator_test.dart | 233 ++++++------------ packages/pigeon/test/pigeon_lib_test.dart | 118 ++++----- .../pigeon/test/swift_generator_test.dart | 127 +++------- packages/pigeon/tool/run_tests.dart | 9 +- packages/pointer_interceptor/CHANGELOG.md | 4 + .../example/integration_test/widget_test.dart | 2 + .../pointer_interceptor/example/lib/main.dart | 4 +- packages/pointer_interceptor/pubspec.yaml | 2 +- .../test/tests_exist_elsewhere_test.dart | 2 + packages/rfw/CHANGELOG.md | 5 +- packages/rfw/example/remote/lib/main.dart | 2 +- packages/rfw/example/wasm/lib/main.dart | 6 +- packages/rfw/example/wasm/logic/encode.dart | 1 + .../rfw/lib/src/flutter/core_widgets.dart | 20 +- .../rfw/lib/src/flutter/material_widgets.dart | 6 +- .../rfw/lib/src/flutter/remote_widget.dart | 2 +- packages/rfw/pubspec.yaml | 2 +- packages/rfw/test/binary_test.dart | 2 +- packages/rfw/test/core_widgets_test.dart | 2 +- packages/rfw/test/runtime_test.dart | 2 + .../rfw/test_coverage/bin/test_coverage.dart | 2 + packages/standard_message_codec/CHANGELOG.md | 4 + .../example/lib/readme_excerpts.dart | 2 + .../lib/standard_message_codec.dart | 2 +- packages/standard_message_codec/pubspec.yaml | 2 +- packages/web_benchmarks/CHANGELOG.md | 4 + packages/web_benchmarks/lib/client.dart | 12 +- packages/web_benchmarks/lib/src/browser.dart | 16 +- packages/web_benchmarks/lib/src/runner.dart | 20 +- packages/web_benchmarks/pubspec.yaml | 2 +- .../test/more_tests_in_testing_dir_test.dart | 2 + .../testing/test_app/lib/aboutpage.dart | 2 +- .../test_app/lib/benchmarks/runner.dart | 4 +- .../testing/test_app/lib/homepage.dart | 5 +- .../testing/test_app/lib/main.dart | 2 +- .../testing/test_app/pubspec.yaml | 6 +- packages/xdg_directories/CHANGELOG.md | 3 +- .../xdg_directories/lib/xdg_directories.dart | 1 - packages/xdg_directories/pubspec.yaml | 2 +- .../test/xdg_directories_test.dart | 2 +- 201 files changed, 1102 insertions(+), 1325 deletions(-) delete mode 100644 packages/palette_generator/palette_generator.iml diff --git a/analysis_options.yaml b/analysis_options.yaml index a6b55d7250..faa1b8bf6f 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -1,35 +1,27 @@ # Specify analysis options. # -# Until there are meta linter rules, each desired lint must be explicitly enabled. -# See: https://github.com/dart-lang/linter/issues/288 -# -# For a list of lints, see: http://dart-lang.github.io/linter/lints/ -# See the configuration guide for more -# https://github.com/dart-lang/sdk/tree/master/pkg/analyzer#configuring-the-analyzer -# -# This file is derived from the master file in the flutter repo, and should be -# kept in sync with it. +# This file is a copy of analysis_options.yaml from flutter repo +# as of 2022-07-27, but with some modifications marked with +# "DIFFERENT FROM FLUTTER/FLUTTER" below. The file is expected to +# be kept in sync with the master file from the flutter repo. analyzer: - strong-mode: - implicit-dynamic: false + language: + strict-casts: false # DIFFERENT FROM FLUTTER/FLUTTER, too many violations, TODO(goderbauer): Clean this up. + strict-raw-types: true errors: - # treat missing required parameters as a warning (not a hint) - missing_required_param: warning - # treat missing returns as a warning (not a hint) - missing_return: warning - # allow having TODOs in the code - todo: ignore + # allow self-reference to deprecated members (we do this because otherwise we have + # to annotate every member in every test, assert, etc, when we deprecate something) + deprecated_member_use_from_same_package: ignore # Turned off until null-safe rollout is complete. unnecessary_null_comparison: ignore - exclude: + exclude: # DIFFERENT FROM FLUTTER/FLUTTER # Ignore generated files - '**/*.mocks.dart' # Mockito @GenerateMocks linter: rules: - # these rules are documented on and in the same order as - # the Dart Lint rules page to make maintenance easier + # This list is derived from the list of all available lints located at # https://github.com/dart-lang/linter/blob/master/example/all.yaml - always_declare_return_types - always_put_control_body_on_new_line @@ -40,32 +32,34 @@ linter: - annotate_overrides # - avoid_annotating_with_dynamic # conflicts with always_specify_types - avoid_bool_literals_in_conditional_expressions - # - avoid_catches_without_on_clauses # we do this commonly - # - avoid_catching_errors # we do this commonly + # - avoid_catches_without_on_clauses # blocked on https://github.com/dart-lang/linter/issues/3023 + # - avoid_catching_errors # blocked on https://github.com/dart-lang/linter/issues/3023 - avoid_classes_with_only_static_members - # - avoid_double_and_int_checks # only useful when targeting JS runtime - # - avoid_dynamic_calls # not yet tested + - avoid_double_and_int_checks + - avoid_dynamic_calls - avoid_empty_else - avoid_equals_and_hash_code_on_mutable_classes - # - avoid_escaping_inner_quotes # not yet tested + - avoid_escaping_inner_quotes - avoid_field_initializers_in_const_classes + # - avoid_final_parameters # incompatible with prefer_final_parameters - avoid_function_literals_in_foreach_calls - # - avoid_implementing_value_types # not yet tested + - avoid_implementing_value_types - avoid_init_to_null - # - avoid_js_rounded_ints # only useful when targeting JS runtime + - avoid_js_rounded_ints + # - avoid_multiple_declarations_per_line # seems to be a stylistic choice we don't subscribe to - avoid_null_checks_in_equality_operators - # - avoid_positional_boolean_parameters # not yet tested - # - avoid_print # not yet tested + # - avoid_positional_boolean_parameters # would have been nice to enable this but by now there's too many places that break it + - avoid_print # - avoid_private_typedef_functions # we prefer having typedef (discussion in https://github.com/flutter/flutter/pull/16356) - # - avoid_redundant_argument_values # not yet tested + - avoid_redundant_argument_values - avoid_relative_lib_imports - avoid_renaming_method_parameters - avoid_return_types_on_setters - # - avoid_returning_null # there are plenty of valid reasons to return null - # - avoid_returning_null_for_future # not yet tested + - avoid_returning_null + - avoid_returning_null_for_future - avoid_returning_null_for_void - # - avoid_returning_this # there are plenty of valid reasons to return this - # - avoid_setters_without_getters # not yet tested + # - avoid_returning_this # there are enough valid reasons to return `this` that this lint ends up with too many false positives + - avoid_setters_without_getters - avoid_shadowing_type_parameters - avoid_single_cascade_in_expression_statements - avoid_slow_async_io @@ -75,51 +69,59 @@ linter: - avoid_unnecessary_containers - avoid_unused_constructor_parameters - avoid_void_async - # - avoid_web_libraries_in_flutter # not yet tested + # - avoid_web_libraries_in_flutter # we use web libraries in web-specific code, and our tests prevent us from using them elsewhere - await_only_futures - camel_case_extensions - camel_case_types - cancel_subscriptions - # - cascade_invocations # not yet tested + # - cascade_invocations # doesn't match the typical style of this repo - cast_nullable_to_non_nullable # - close_sinks # not reliable enough + - combinators_ordering # - comment_references # blocked on https://github.com/dart-lang/linter/issues/1142 + - conditional_uri_does_not_exist # - constant_identifier_names # needs an opt-out https://github.com/dart-lang/linter/issues/204 - control_flow_in_finally - # - curly_braces_in_flow_control_structures # not required by flutter style + - curly_braces_in_flow_control_structures + - depend_on_referenced_packages - deprecated_consistency - # - diagnostic_describe_all_properties # not yet tested + # - diagnostic_describe_all_properties # enabled only at the framework level (packages/flutter/lib) - directives_ordering - # - do_not_use_environment # we do this commonly + # - discarded_futures # not yet tested + # - do_not_use_environment # there are appropriate times to use the environment, especially in our tests and build logic - empty_catches - empty_constructor_bodies - empty_statements + - eol_at_end_of_file - exhaustive_cases - file_names - flutter_style_todos - hash_and_equals - implementation_imports - # - invariant_booleans # too many false positives: https://github.com/dart-lang/linter/issues/811 - iterable_contains_unrelated_type # - join_return_with_assignment # not required by flutter style - leading_newlines_in_multiline_strings - library_names - library_prefixes + - library_private_types_in_public_api # - lines_longer_than_80_chars # not required by flutter style - list_remove_unrelated_type - # - literal_only_boolean_expressions # too many false positives: https://github.com/dart-lang/sdk/issues/34181 + # - literal_only_boolean_expressions # too many false positives: https://github.com/dart-lang/linter/issues/453 - missing_whitespace_between_adjacent_strings - no_adjacent_strings_in_list - # - no_default_cases # too many false positives + - no_default_cases - no_duplicate_case_values + - no_leading_underscores_for_library_prefixes + - no_leading_underscores_for_local_identifiers - no_logic_in_create_state # - no_runtimeType_toString # ok in tests; we enable this only in packages/ - non_constant_identifier_names + - noop_primitive_operations - null_check_on_nullable_type_parameter - null_closures # - 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 + - only_throw_errors # this does get disabled in a few places where we have legacy code that uses strings et al - overridden_fields - package_api_docs - package_names @@ -142,6 +144,7 @@ linter: - prefer_final_fields - prefer_final_in_for_each - prefer_final_locals + # - prefer_final_parameters # we should enable this one day when it can be auto-fixed (https://github.com/dart-lang/linter/issues/3104), see also parameter_assignments - prefer_for_elements_to_map_fromIterable - prefer_foreach - prefer_function_declarations_over_variables @@ -151,68 +154,78 @@ linter: - prefer_initializing_formals - prefer_inlined_adds # - prefer_int_literals # conflicts with https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#use-double-literals-for-double-constants - # - prefer_interpolation_to_compose_strings # doesn't work with raw strings, see https://github.com/dart-lang/linter/issues/2490 + - prefer_interpolation_to_compose_strings - prefer_is_empty - prefer_is_not_empty - prefer_is_not_operator - prefer_iterable_whereType - # - prefer_mixin # https://github.com/dart-lang/language/issues/32 + # - prefer_mixin # Has false positives, see https://github.com/dart-lang/linter/issues/3018 + # - prefer_null_aware_method_calls # "call()" is confusing to people new to the language since it's not documented anywhere - prefer_null_aware_operators - # - prefer_relative_imports # incompatible with sub-package imports + - prefer_relative_imports - prefer_single_quotes - prefer_spread_collections - prefer_typing_uninitialized_variables - prefer_void_to_null - provide_deprecation_message - - public_member_api_docs + - public_member_api_docs # DIFFERENT FROM FLUTTER/FLUTTER - recursive_getters + # - require_trailing_commas # blocked on https://github.com/dart-lang/sdk/issues/47441 + - secure_pubspec_urls - sized_box_for_whitespace + # - sized_box_shrink_expand # not yet tested - slash_for_doc_comments - # - sort_child_properties_last # not yet tested + - sort_child_properties_last - sort_constructors_first - # - sort_pub_dependencies + - sort_pub_dependencies # DIFFERENT FROM FLUTTER/FLUTTER: Flutter's use case for not sorting does not apply to this repository. - sort_unnamed_constructors_first - test_types_in_equals - throw_in_finally - tighten_type_of_initializing_formals # - type_annotate_public_apis # subset of always_specify_types - type_init_formals - # - unawaited_futures # too many false positives + # - unawaited_futures # too many false positives, especially with the way AnimationController works - unnecessary_await_in_return - unnecessary_brace_in_string_interps - unnecessary_const + - unnecessary_constructor_name # - unnecessary_final # conflicts with prefer_final_locals - unnecessary_getters_setters # - unnecessary_lambdas # has false positives: https://github.com/dart-lang/linter/issues/498 + - unnecessary_late - unnecessary_new - unnecessary_null_aware_assignments - # - unnecessary_null_checks # not yet tested + - unnecessary_null_aware_operator_on_extension_on_nullable + - unnecessary_null_checks - unnecessary_null_in_if_null_operators - unnecessary_nullable_for_final_variable_declarations - unnecessary_overrides - unnecessary_parenthesis - # - unnecessary_raw_strings # not yet tested + # - unnecessary_raw_strings # what's "necessary" is a matter of opinion; consistency across strings can help readability more than this lint - unnecessary_statements - unnecessary_string_escapes - unnecessary_string_interpolations - unnecessary_this + - unnecessary_to_list_in_spreads - unrelated_type_equality_checks - # - unsafe_html # not yet tested + - unsafe_html + - use_build_context_synchronously + # - use_colored_box # not yet tested + # - use_decorated_box # not yet tested + # - use_enums # not yet tested - use_full_hex_values_for_flutter_colors - use_function_type_syntax_for_parameters - # - use_if_null_to_convert_nulls_to_bools # not yet tested + - use_if_null_to_convert_nulls_to_bools - use_is_even_rather_than_modulo - use_key_in_widget_constructors - use_late_for_private_fields_and_variables - # - use_named_constants # not yet yested + - use_named_constants - use_raw_strings - use_rethrow_when_possible - # - use_setters_to_change_properties # not yet tested + - use_setters_to_change_properties # - use_string_buffers # has false positives: https://github.com/dart-lang/sdk/issues/34182 + - use_super_parameters + - use_test_throws_matchers # - use_to_and_as_if_applicable # has false positives, so we prefer to catch this by code-review - valid_regexps - void_checks - ### Local flutter/packages changes ### - # Flutter has a specific use case for dependencies that are intentionally - # not sorted, which doesn't apply to this repo. - - sort_pub_dependencies diff --git a/packages/adaptive_scaffold/example/lib/main.dart b/packages/adaptive_scaffold/example/lib/main.dart index f68b66873d..3e15cb3898 100644 --- a/packages/adaptive_scaffold/example/lib/main.dart +++ b/packages/adaptive_scaffold/example/lib/main.dart @@ -225,7 +225,6 @@ class _MyHomePageState extends State leading: ScaleTransition( scale: _controller1, child: const _MediumComposeIcon()), backgroundColor: const Color.fromARGB(0, 255, 255, 255), - labelType: NavigationRailLabelType.none, destinations: [ slideInNavigationItem( begin: -1, @@ -288,7 +287,7 @@ class _MyHomePageState extends State padding: const EdgeInsets.fromLTRB(0, 32, 0, 0), child: _ItemList( selected: selected, - items: allItems, + items: _allItems, selectCard: selectCard), ) : const _ExamplePage(), @@ -304,7 +303,7 @@ class _MyHomePageState extends State outAnimation: AdaptiveScaffold.stayOnScreen, key: const Key('sBody'), builder: (_) => SafeArea( - child: _DetailTile(item: allItems[selected ?? 0]), + child: _DetailTile(item: _allItems[selected ?? 0]), ), ) }, @@ -451,6 +450,8 @@ class _LargeComposeIcon extends StatelessWidget { } } +typedef _CardSelectedCallback = void Function(int?); + // ItemList creates the list of cards and the search bar. class _ItemList extends StatelessWidget { const _ItemList({ @@ -462,7 +463,7 @@ class _ItemList extends StatelessWidget { final List<_Item> items; final int? selected; - final Function selectCard; + final _CardSelectedCallback selectCard; @override Widget build(BuildContext context) { @@ -535,7 +536,7 @@ class _ItemListTile extends StatelessWidget { final _Item item; final _Email email; final int? selected; - final Function selectCard; + final _CardSelectedCallback selectCard; @override Widget build(BuildContext context) { @@ -545,19 +546,19 @@ class _ItemListTile extends StatelessWidget { // than large screens. // Small screens open a modal with the detail view while large screens // simply show the details on the secondaryBody. - selectCard(allItems.indexOf(item)); + selectCard(_allItems.indexOf(item)); if (!Breakpoints.mediumAndUp.isActive(context)) { Navigator.of(context).pushNamed(_ExtractRouteArguments.routeName, arguments: _ScreenArguments(item: item, selectCard: selectCard)); } else { - selectCard(allItems.indexOf(item)); + selectCard(_allItems.indexOf(item)); } }, child: Padding( padding: const EdgeInsets.all(8.0), child: Container( decoration: BoxDecoration( - color: selected == allItems.indexOf(item) + color: selected == _allItems.indexOf(item) ? const Color.fromARGB(255, 234, 222, 255) : const Color.fromARGB(255, 243, 237, 247), borderRadius: const BorderRadius.all(Radius.circular(10)), @@ -863,7 +864,7 @@ class _ScreenArguments { required this.selectCard, }); final _Item item; - final Function selectCard; + final _CardSelectedCallback selectCard; } class _ExtractRouteArguments extends StatelessWidget { @@ -888,7 +889,7 @@ class _RouteDetailView extends StatelessWidget { }) : super(key: key); final _Item item; - final Function selectCard; + final _CardSelectedCallback selectCard; @override Widget build(BuildContext context) { @@ -952,7 +953,7 @@ class _Email { /// List of items, each representing a thread of emails which will populate /// the different layouts. -const List<_Item> allItems = <_Item>[ +const List<_Item> _allItems = <_Item>[ _Item( title: 'Dinner Club', emails: <_Email>[ diff --git a/packages/adaptive_scaffold/example/test/adaptive_layout_demo_test.dart b/packages/adaptive_scaffold/example/test/adaptive_layout_demo_test.dart index 90e96d7aa6..45230be33f 100644 --- a/packages/adaptive_scaffold/example/test/adaptive_layout_demo_test.dart +++ b/packages/adaptive_scaffold/example/test/adaptive_layout_demo_test.dart @@ -84,7 +84,7 @@ void main() { expect(tester.getBottomLeft(bn), const Offset(0, 800)); expect(tester.getBottomRight(bn), const Offset(400, 800)); expect(tester.getTopRight(body), const Offset(400, 0)); - expect(tester.getTopLeft(body), const Offset(0, 0)); + expect(tester.getTopLeft(body), Offset.zero); }); testWidgets('adaptive layout does not animate when animations off', diff --git a/packages/adaptive_scaffold/lib/src/adaptive_scaffold.dart b/packages/adaptive_scaffold/lib/src/adaptive_scaffold.dart index a2f4172116..355740ebe1 100644 --- a/packages/adaptive_scaffold/lib/src/adaptive_scaffold.dart +++ b/packages/adaptive_scaffold/lib/src/adaptive_scaffold.dart @@ -357,7 +357,6 @@ class AdaptiveScaffold extends StatefulWidget { controller: ScrollController(), shrinkWrap: true, physics: const AlwaysScrollableScrollPhysics(), - scrollDirection: Axis.vertical, slivers: [ SliverToBoxAdapter( child: Padding( diff --git a/packages/animations/CHANGELOG.md b/packages/animations/CHANGELOG.md index 92411a7c7a..9e379ce03c 100644 --- a/packages/animations/CHANGELOG.md +++ b/packages/animations/CHANGELOG.md @@ -1,6 +1,7 @@ -## NEXT +## 2.0.4 * Updates text theme parameters to avoid deprecation issues. +* Fixes lint warnings. ## 2.0.3 * Updates for non-nullable bindings. diff --git a/packages/animations/example/lib/container_transition.dart b/packages/animations/example/lib/container_transition.dart index 9362d42d95..3fabccbb23 100644 --- a/packages/animations/example/lib/container_transition.dart +++ b/packages/animations/example/lib/container_transition.dart @@ -44,7 +44,7 @@ class OpenContainerTransformDemo extends StatefulWidget { const OpenContainerTransformDemo({Key? key}) : super(key: key); @override - _OpenContainerTransformDemoState createState() { + State createState() { return _OpenContainerTransformDemoState(); } } @@ -54,10 +54,11 @@ class _OpenContainerTransformDemoState ContainerTransitionType _transitionType = ContainerTransitionType.fade; void _showMarkedAsDoneSnackbar(bool? isMarkedAsDone) { - if (isMarkedAsDone ?? false) + if (isMarkedAsDone ?? false) { ScaffoldMessenger.of(context).showSnackBar(const SnackBar( content: Text('Marked as done!'), )); + } } void _showSettingsBottomModalSheet(BuildContext context) { @@ -464,7 +465,6 @@ class _InkWellOverlay extends StatelessWidget { Widget build(BuildContext context) { return SizedBox( height: height, - width: null, child: InkWell( onTap: openContainer, child: child, diff --git a/packages/animations/example/lib/fade_scale_transition.dart b/packages/animations/example/lib/fade_scale_transition.dart index 26a2192b07..b6ca592d73 100644 --- a/packages/animations/example/lib/fade_scale_transition.dart +++ b/packages/animations/example/lib/fade_scale_transition.dart @@ -11,7 +11,7 @@ class FadeScaleTransitionDemo extends StatefulWidget { const FadeScaleTransitionDemo({Key? key}) : super(key: key); @override - _FadeScaleTransitionDemoState createState() => + State createState() => _FadeScaleTransitionDemoState(); } diff --git a/packages/animations/example/lib/fade_through_transition.dart b/packages/animations/example/lib/fade_through_transition.dart index 978af597eb..2cc1dde90c 100644 --- a/packages/animations/example/lib/fade_through_transition.dart +++ b/packages/animations/example/lib/fade_through_transition.dart @@ -11,7 +11,7 @@ class FadeThroughTransitionDemo extends StatefulWidget { const FadeThroughTransitionDemo({Key? key}) : super(key: key); @override - _FadeThroughTransitionDemoState createState() => + State createState() => _FadeThroughTransitionDemoState(); } diff --git a/packages/animations/example/lib/shared_axis_transition.dart b/packages/animations/example/lib/shared_axis_transition.dart index 8fd6d1dffa..eaf0f869b7 100644 --- a/packages/animations/example/lib/shared_axis_transition.dart +++ b/packages/animations/example/lib/shared_axis_transition.dart @@ -11,7 +11,7 @@ class SharedAxisTransitionDemo extends StatefulWidget { const SharedAxisTransitionDemo({Key? key}) : super(key: key); @override - _SharedAxisTransitionDemoState createState() { + State createState() { return _SharedAxisTransitionDemoState(); } } @@ -43,7 +43,6 @@ class _SharedAxisTransitionDemoState extends State { children: [ Expanded( child: PageTransitionSwitcher( - duration: const Duration(milliseconds: 300), reverse: !_isLoggedIn, transitionBuilder: ( Widget child, @@ -51,10 +50,10 @@ class _SharedAxisTransitionDemoState extends State { Animation secondaryAnimation, ) { return SharedAxisTransition( - child: child, animation: animation, secondaryAnimation: secondaryAnimation, transitionType: _transitionType!, + child: child, ); }, child: _isLoggedIn ? _CoursePage() : _SignInPage(), diff --git a/packages/animations/lib/src/fade_through_transition.dart b/packages/animations/lib/src/fade_through_transition.dart index 2d1b6292a8..1b7962893e 100644 --- a/packages/animations/lib/src/fade_through_transition.dart +++ b/packages/animations/lib/src/fade_through_transition.dart @@ -239,8 +239,8 @@ class _ZoomedFadeInFadeOut extends StatelessWidget { Widget? child, ) { return _FadeOut( - child: child, animation: animation, + child: child, ); }, child: child, diff --git a/packages/animations/lib/src/modal.dart b/packages/animations/lib/src/modal.dart index 52da6e1e36..73047d56a2 100644 --- a/packages/animations/lib/src/modal.dart +++ b/packages/animations/lib/src/modal.dart @@ -131,6 +131,8 @@ class _ModalRoute extends PopupRoute { ) { final ThemeData theme = Theme.of(context); return Semantics( + scopesRoute: true, + explicitChildNodes: true, child: SafeArea( child: Builder( builder: (BuildContext context) { @@ -139,8 +141,6 @@ class _ModalRoute extends PopupRoute { }, ), ), - scopesRoute: true, - explicitChildNodes: true, ); } diff --git a/packages/animations/lib/src/open_container.dart b/packages/animations/lib/src/open_container.dart index a3a3c72efd..14c862e970 100644 --- a/packages/animations/lib/src/open_container.dart +++ b/packages/animations/lib/src/open_container.dart @@ -261,7 +261,7 @@ class OpenContainer extends StatefulWidget { final Clip clipBehavior; @override - _OpenContainerState createState() => _OpenContainerState(); + State> createState() => _OpenContainerState(); } class _OpenContainerState extends State> { diff --git a/packages/animations/lib/src/page_transition_switcher.dart b/packages/animations/lib/src/page_transition_switcher.dart index 32bab713ab..9770b05eee 100644 --- a/packages/animations/lib/src/page_transition_switcher.dart +++ b/packages/animations/lib/src/page_transition_switcher.dart @@ -265,13 +265,13 @@ class PageTransitionSwitcher extends StatefulWidget { /// signature. static Widget defaultLayoutBuilder(List entries) { return Stack( - children: entries, alignment: Alignment.center, + children: entries, ); } @override - _PageTransitionSwitcherState createState() => _PageTransitionSwitcherState(); + State createState() => _PageTransitionSwitcherState(); } class _PageTransitionSwitcherState extends State diff --git a/packages/animations/pubspec.yaml b/packages/animations/pubspec.yaml index 56a4beadd9..e320601852 100644 --- a/packages/animations/pubspec.yaml +++ b/packages/animations/pubspec.yaml @@ -2,7 +2,7 @@ name: animations description: Fancy pre-built animations that can easily be integrated into any Flutter application. repository: https://github.com/flutter/packages/tree/main/packages/animations issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+animations%22 -version: 2.0.3 +version: 2.0.4 environment: sdk: '>=2.12.0 <3.0.0' diff --git a/packages/animations/test/fade_scale_transition_test.dart b/packages/animations/test/fade_scale_transition_test.dart index 4fdc668b97..c38b30618a 100644 --- a/packages/animations/test/fade_scale_transition_test.dart +++ b/packages/animations/test/fade_scale_transition_test.dart @@ -20,7 +20,6 @@ void main() { onPressed: () { showModal( context: context, - configuration: const FadeScaleTransitionConfiguration(), builder: (BuildContext context) { return const _FlutterLogoModal(); }, @@ -52,7 +51,6 @@ void main() { onPressed: () { showModal( context: context, - configuration: const FadeScaleTransitionConfiguration(), builder: (BuildContext context) { return _FlutterLogoModal(key: key); }, @@ -120,7 +118,6 @@ void main() { onPressed: () { showModal( context: context, - configuration: const FadeScaleTransitionConfiguration(), builder: (BuildContext context) { return _FlutterLogoModal(key: key); }, @@ -185,7 +182,6 @@ void main() { onPressed: () { showModal( context: context, - configuration: const FadeScaleTransitionConfiguration(), builder: (BuildContext context) { return _FlutterLogoModal(key: key); }, @@ -286,8 +282,6 @@ void main() { onPressed: () { showModal( context: context, - configuration: - const FadeScaleTransitionConfiguration(), builder: (BuildContext context) { return _FlutterLogoModal( key: topKey, diff --git a/packages/animations/test/fade_through_transition_test.dart b/packages/animations/test/fade_through_transition_test.dart index fff378b8c8..7d8a5fa3fd 100644 --- a/packages/animations/test/fade_through_transition_test.dart +++ b/packages/animations/test/fade_through_transition_test.dart @@ -376,9 +376,9 @@ void main() { textDirection: TextDirection.ltr, child: Center( child: FadeThroughTransition( - child: const _StatefulTestWidget(name: 'Foo'), animation: animation, secondaryAnimation: secondaryAnimation, + child: const _StatefulTestWidget(name: 'Foo'), ), ), )); diff --git a/packages/animations/test/open_container_test.dart b/packages/animations/test/open_container_test.dart index 3c53c9534b..66fca5d0c3 100644 --- a/packages/animations/test/open_container_test.dart +++ b/packages/animations/test/open_container_test.dart @@ -1622,7 +1622,7 @@ void main() { expect(material.clipBehavior, Clip.none); }); - Widget _createRootNavigatorTest({ + Widget createRootNavigatorTest({ required Key appKey, required Key nestedNavigatorKey, required bool useRootNavigator, @@ -1670,7 +1670,7 @@ void main() { const Key appKey = Key('App'); const Key nestedNavigatorKey = Key('Nested Navigator'); - await tester.pumpWidget(_createRootNavigatorTest( + await tester.pumpWidget(createRootNavigatorTest( appKey: appKey, nestedNavigatorKey: nestedNavigatorKey, useRootNavigator: false)); @@ -1693,7 +1693,7 @@ void main() { const Key appKey = Key('App'); const Key nestedNavigatorKey = Key('Nested Navigator'); - await tester.pumpWidget(_createRootNavigatorTest( + await tester.pumpWidget(createRootNavigatorTest( appKey: appKey, nestedNavigatorKey: nestedNavigatorKey, useRootNavigator: true)); @@ -1716,7 +1716,7 @@ void main() { const Key appKey = Key('App'); const Key nestedNavigatorKey = Key('Nested Navigator'); - await tester.pumpWidget(_createRootNavigatorTest( + await tester.pumpWidget(createRootNavigatorTest( appKey: appKey, nestedNavigatorKey: nestedNavigatorKey, useRootNavigator: false)); @@ -1733,7 +1733,7 @@ void main() { const Key appKey = Key('App'); const Key nestedNavigatorKey = Key('Nested Navigator'); - await tester.pumpWidget(_createRootNavigatorTest( + await tester.pumpWidget(createRootNavigatorTest( appKey: appKey, nestedNavigatorKey: nestedNavigatorKey, useRootNavigator: true)); @@ -1786,7 +1786,7 @@ void main() { // Regression test for https://github.com/flutter/flutter/issues/72238. testWidgets( - 'OpenContainer\'s source widget is visible in closed container route if ' + "OpenContainer's source widget is visible in closed container route if " 'open container route is pushed from not using the OpenContainer itself', (WidgetTester tester) async { final Widget openContainer = OpenContainer( diff --git a/packages/animations/test/page_transition_switcher_test.dart b/packages/animations/test/page_transition_switcher_test.dart index aa4904e272..c40f4ca9c3 100644 --- a/packages/animations/test/page_transition_switcher_test.dart +++ b/packages/animations/test/page_transition_switcher_test.dart @@ -14,37 +14,37 @@ void main() { await tester.pumpWidget( PageTransitionSwitcher( duration: const Duration(milliseconds: 100), - child: Container(key: containerOne, color: const Color(0x00000000)), transitionBuilder: _transitionBuilder, + child: Container(key: containerOne, color: const Color(0x00000000)), ), ); - Map _primaryAnimation = + Map primaryAnimation = _getPrimaryAnimation([containerOne], tester); - Map _secondaryAnimation = + Map secondaryAnimation = _getSecondaryAnimation([containerOne], tester); - expect(_primaryAnimation[containerOne], equals(1.0)); - expect(_secondaryAnimation[containerOne], equals(0.0)); + expect(primaryAnimation[containerOne], equals(1.0)); + expect(secondaryAnimation[containerOne], equals(0.0)); await tester.pumpWidget( PageTransitionSwitcher( duration: const Duration(milliseconds: 100), - child: Container(key: containerTwo, color: const Color(0xff000000)), transitionBuilder: _transitionBuilder, + child: Container(key: containerTwo, color: const Color(0xff000000)), ), ); await tester.pump(const Duration(milliseconds: 40)); - _primaryAnimation = + primaryAnimation = _getPrimaryAnimation([containerOne, containerTwo], tester); - _secondaryAnimation = + secondaryAnimation = _getSecondaryAnimation([containerOne, containerTwo], tester); // Secondary is running for outgoing widget. - expect(_primaryAnimation[containerOne], equals(1.0)); - expect(_secondaryAnimation[containerOne], moreOrLessEquals(0.4)); + expect(primaryAnimation[containerOne], equals(1.0)); + expect(secondaryAnimation[containerOne], moreOrLessEquals(0.4)); // Primary is running for incoming widget. - expect(_primaryAnimation[containerTwo], moreOrLessEquals(0.4)); - expect(_secondaryAnimation[containerTwo], equals(0.0)); + expect(primaryAnimation[containerTwo], moreOrLessEquals(0.4)); + expect(secondaryAnimation[containerTwo], equals(0.0)); // Container one is underneath container two final Container container = tester.firstWidget(find.byType(Container)); @@ -53,22 +53,22 @@ void main() { await tester.pumpWidget( PageTransitionSwitcher( duration: const Duration(milliseconds: 100), - child: Container(key: containerThree, color: const Color(0xffff0000)), transitionBuilder: _transitionBuilder, + child: Container(key: containerThree, color: const Color(0xffff0000)), ), ); await tester.pump(const Duration(milliseconds: 20)); - _primaryAnimation = _getPrimaryAnimation( + primaryAnimation = _getPrimaryAnimation( [containerOne, containerTwo, containerThree], tester); - _secondaryAnimation = _getSecondaryAnimation( + secondaryAnimation = _getSecondaryAnimation( [containerOne, containerTwo, containerThree], tester); - expect(_primaryAnimation[containerOne], equals(1.0)); - expect(_secondaryAnimation[containerOne], equals(0.6)); - expect(_primaryAnimation[containerTwo], equals(0.6)); - expect(_secondaryAnimation[containerTwo], moreOrLessEquals(0.2)); - expect(_primaryAnimation[containerThree], moreOrLessEquals(0.2)); - expect(_secondaryAnimation[containerThree], equals(0.0)); + expect(primaryAnimation[containerOne], equals(1.0)); + expect(secondaryAnimation[containerOne], equals(0.6)); + expect(primaryAnimation[containerTwo], equals(0.6)); + expect(secondaryAnimation[containerTwo], moreOrLessEquals(0.2)); + expect(primaryAnimation[containerThree], moreOrLessEquals(0.2)); + expect(secondaryAnimation[containerThree], equals(0.0)); await tester.pumpAndSettle(); }); @@ -80,39 +80,39 @@ void main() { await tester.pumpWidget( PageTransitionSwitcher( duration: const Duration(milliseconds: 100), - child: Container(key: containerOne, color: const Color(0x00000000)), transitionBuilder: _transitionBuilder, reverse: true, + child: Container(key: containerOne, color: const Color(0x00000000)), ), ); - Map _primaryAnimation = + Map primaryAnimation = _getPrimaryAnimation([containerOne], tester); - Map _secondaryAnimation = + Map secondaryAnimation = _getSecondaryAnimation([containerOne], tester); - expect(_primaryAnimation[containerOne], equals(1.0)); - expect(_secondaryAnimation[containerOne], equals(0.0)); + expect(primaryAnimation[containerOne], equals(1.0)); + expect(secondaryAnimation[containerOne], equals(0.0)); await tester.pumpWidget( PageTransitionSwitcher( duration: const Duration(milliseconds: 100), - child: Container(key: containerTwo, color: const Color(0xff000000)), transitionBuilder: _transitionBuilder, reverse: true, + child: Container(key: containerTwo, color: const Color(0xff000000)), ), ); await tester.pump(const Duration(milliseconds: 40)); - _primaryAnimation = + primaryAnimation = _getPrimaryAnimation([containerOne, containerTwo], tester); - _secondaryAnimation = + secondaryAnimation = _getSecondaryAnimation([containerOne, containerTwo], tester); // Primary is running forward for outgoing widget. - expect(_primaryAnimation[containerOne], moreOrLessEquals(0.6)); - expect(_secondaryAnimation[containerOne], equals(0.0)); + expect(primaryAnimation[containerOne], moreOrLessEquals(0.6)); + expect(secondaryAnimation[containerOne], equals(0.0)); // Secondary is running forward for incoming widget. - expect(_primaryAnimation[containerTwo], equals(1.0)); - expect(_secondaryAnimation[containerTwo], moreOrLessEquals(0.6)); + expect(primaryAnimation[containerTwo], equals(1.0)); + expect(secondaryAnimation[containerTwo], moreOrLessEquals(0.6)); // Container two two is underneath container one. final Container container = tester.firstWidget(find.byType(Container)); @@ -121,23 +121,23 @@ void main() { await tester.pumpWidget( PageTransitionSwitcher( duration: const Duration(milliseconds: 100), - child: Container(key: containerThree, color: const Color(0xffff0000)), transitionBuilder: _transitionBuilder, reverse: true, + child: Container(key: containerThree, color: const Color(0xffff0000)), ), ); await tester.pump(const Duration(milliseconds: 20)); - _primaryAnimation = _getPrimaryAnimation( + primaryAnimation = _getPrimaryAnimation( [containerOne, containerTwo, containerThree], tester); - _secondaryAnimation = _getSecondaryAnimation( + secondaryAnimation = _getSecondaryAnimation( [containerOne, containerTwo, containerThree], tester); - expect(_primaryAnimation[containerOne], equals(0.4)); - expect(_secondaryAnimation[containerOne], equals(0.0)); - expect(_primaryAnimation[containerTwo], equals(0.8)); - expect(_secondaryAnimation[containerTwo], equals(0.4)); - expect(_primaryAnimation[containerThree], equals(1.0)); - expect(_secondaryAnimation[containerThree], equals(0.8)); + expect(primaryAnimation[containerOne], equals(0.4)); + expect(secondaryAnimation[containerOne], equals(0.0)); + expect(primaryAnimation[containerTwo], equals(0.8)); + expect(secondaryAnimation[containerTwo], equals(0.4)); + expect(primaryAnimation[containerThree], equals(1.0)); + expect(secondaryAnimation[containerThree], equals(0.8)); await tester.pumpAndSettle(); }); @@ -148,56 +148,56 @@ void main() { await tester.pumpWidget( PageTransitionSwitcher( duration: const Duration(milliseconds: 100), - child: Container(key: containerOne, color: const Color(0x00000000)), transitionBuilder: _transitionBuilder, + child: Container(key: containerOne, color: const Color(0x00000000)), ), ); - Map _primaryAnimation = + Map primaryAnimation = _getPrimaryAnimation([containerOne], tester); - Map _secondaryAnimation = + Map secondaryAnimation = _getSecondaryAnimation([containerOne], tester); - expect(_primaryAnimation[containerOne], equals(1.0)); - expect(_secondaryAnimation[containerOne], equals(0.0)); + expect(primaryAnimation[containerOne], equals(1.0)); + expect(secondaryAnimation[containerOne], equals(0.0)); await tester.pumpWidget( PageTransitionSwitcher( duration: const Duration(milliseconds: 100), - child: Container(key: containerTwo, color: const Color(0xff000000)), transitionBuilder: _transitionBuilder, + child: Container(key: containerTwo, color: const Color(0xff000000)), ), ); await tester.pump(const Duration(milliseconds: 40)); - _primaryAnimation = + primaryAnimation = _getPrimaryAnimation([containerOne, containerTwo], tester); - _secondaryAnimation = + secondaryAnimation = _getSecondaryAnimation([containerOne, containerTwo], tester); - expect(_secondaryAnimation[containerOne], moreOrLessEquals(0.4)); - expect(_primaryAnimation[containerOne], equals(1.0)); - expect(_secondaryAnimation[containerTwo], equals(0.0)); - expect(_primaryAnimation[containerTwo], moreOrLessEquals(0.4)); + expect(secondaryAnimation[containerOne], moreOrLessEquals(0.4)); + expect(primaryAnimation[containerOne], equals(1.0)); + expect(secondaryAnimation[containerTwo], equals(0.0)); + expect(primaryAnimation[containerTwo], moreOrLessEquals(0.4)); await tester.pumpWidget( PageTransitionSwitcher( duration: const Duration(milliseconds: 100), - child: Container(key: containerThree, color: const Color(0xffff0000)), transitionBuilder: _transitionBuilder, reverse: true, + child: Container(key: containerThree, color: const Color(0xffff0000)), ), ); await tester.pump(const Duration(milliseconds: 20)); - _primaryAnimation = _getPrimaryAnimation( + primaryAnimation = _getPrimaryAnimation( [containerOne, containerTwo, containerThree], tester); - _secondaryAnimation = _getSecondaryAnimation( + secondaryAnimation = _getSecondaryAnimation( [containerOne, containerTwo, containerThree], tester); - expect(_secondaryAnimation[containerOne], equals(0.6)); - expect(_primaryAnimation[containerOne], equals(1.0)); - expect(_secondaryAnimation[containerTwo], equals(0.0)); - expect(_primaryAnimation[containerTwo], moreOrLessEquals(0.2)); - expect(_secondaryAnimation[containerThree], equals(0.8)); - expect(_primaryAnimation[containerThree], equals(1.0)); + expect(secondaryAnimation[containerOne], equals(0.6)); + expect(primaryAnimation[containerOne], equals(1.0)); + expect(secondaryAnimation[containerTwo], equals(0.0)); + expect(primaryAnimation[containerTwo], moreOrLessEquals(0.2)); + expect(secondaryAnimation[containerThree], equals(0.8)); + expect(primaryAnimation[containerThree], equals(1.0)); await tester.pumpAndSettle(); }); @@ -208,39 +208,39 @@ void main() { await tester.pumpWidget( PageTransitionSwitcher( duration: const Duration(milliseconds: 100), - child: Container(key: containerOne, color: const Color(0x00000000)), transitionBuilder: _transitionBuilder, reverse: true, + child: Container(key: containerOne, color: const Color(0x00000000)), ), ); - Map _primaryAnimation = + Map primaryAnimation = _getPrimaryAnimation([containerOne], tester); - Map _secondaryAnimation = + Map secondaryAnimation = _getSecondaryAnimation([containerOne], tester); - expect(_primaryAnimation[containerOne], equals(1.0)); - expect(_secondaryAnimation[containerOne], equals(0.0)); + expect(primaryAnimation[containerOne], equals(1.0)); + expect(secondaryAnimation[containerOne], equals(0.0)); await tester.pumpWidget( PageTransitionSwitcher( duration: const Duration(milliseconds: 100), - child: Container(key: containerTwo, color: const Color(0xff000000)), transitionBuilder: _transitionBuilder, reverse: true, + child: Container(key: containerTwo, color: const Color(0xff000000)), ), ); await tester.pump(const Duration(milliseconds: 40)); - _primaryAnimation = + primaryAnimation = _getPrimaryAnimation([containerOne, containerTwo], tester); - _secondaryAnimation = + secondaryAnimation = _getSecondaryAnimation([containerOne, containerTwo], tester); // Primary is running in reverse for outgoing widget. - expect(_primaryAnimation[containerOne], moreOrLessEquals(0.6)); - expect(_secondaryAnimation[containerOne], equals(0.0)); + expect(primaryAnimation[containerOne], moreOrLessEquals(0.6)); + expect(secondaryAnimation[containerOne], equals(0.0)); // Secondary is running in reverse for incoming widget. - expect(_primaryAnimation[containerTwo], equals(1.0)); - expect(_secondaryAnimation[containerTwo], moreOrLessEquals(0.6)); + expect(primaryAnimation[containerTwo], equals(1.0)); + expect(secondaryAnimation[containerTwo], moreOrLessEquals(0.6)); // Container two is underneath container one. final Container container = tester.firstWidget(find.byType(Container)); @@ -249,9 +249,8 @@ void main() { await tester.pumpWidget( PageTransitionSwitcher( duration: const Duration(milliseconds: 100), - child: Container(key: containerThree, color: const Color(0xffff0000)), transitionBuilder: _transitionBuilder, - reverse: false, + child: Container(key: containerThree, color: const Color(0xffff0000)), ), ); await tester.pump(const Duration(milliseconds: 20)); @@ -262,16 +261,16 @@ void main() { // it should now be exiting underneath container three. Container three's // primary animation should be running forwards since it is entering above // container two. - _primaryAnimation = _getPrimaryAnimation( + primaryAnimation = _getPrimaryAnimation( [containerOne, containerTwo, containerThree], tester); - _secondaryAnimation = _getSecondaryAnimation( + secondaryAnimation = _getSecondaryAnimation( [containerOne, containerTwo, containerThree], tester); - expect(_primaryAnimation[containerOne], equals(0.4)); - expect(_secondaryAnimation[containerOne], equals(0.0)); - expect(_primaryAnimation[containerTwo], equals(1.0)); - expect(_secondaryAnimation[containerTwo], equals(0.8)); - expect(_primaryAnimation[containerThree], moreOrLessEquals(0.2)); - expect(_secondaryAnimation[containerThree], equals(0.0)); + expect(primaryAnimation[containerOne], equals(0.4)); + expect(secondaryAnimation[containerOne], equals(0.0)); + expect(primaryAnimation[containerTwo], equals(1.0)); + expect(secondaryAnimation[containerTwo], equals(0.8)); + expect(primaryAnimation[containerThree], moreOrLessEquals(0.2)); + expect(secondaryAnimation[containerThree], equals(0.0)); await tester.pumpAndSettle(); }); @@ -285,9 +284,9 @@ void main() { await tester.pumpWidget( PageTransitionSwitcher( duration: const Duration(milliseconds: 100), - child: Container(color: const Color(0x00000000)), transitionBuilder: _transitionBuilder, layoutBuilder: newLayoutBuilder, + child: Container(color: const Color(0x00000000)), ), ); @@ -299,8 +298,8 @@ void main() { await tester.pumpWidget( PageTransitionSwitcher( duration: const Duration(milliseconds: 100), - child: Container(color: const Color(0x00000000)), transitionBuilder: _transitionBuilder, + child: Container(color: const Color(0x00000000)), ), ); @@ -314,8 +313,8 @@ void main() { await tester.pumpWidget( PageTransitionSwitcher( duration: const Duration(milliseconds: 100), - child: Container(color: const Color(0xff000000)), transitionBuilder: _transitionBuilder, + child: Container(color: const Color(0xff000000)), ), ); @@ -333,7 +332,6 @@ void main() { await tester.pumpWidget( const PageTransitionSwitcher( duration: Duration(milliseconds: 100), - child: null, transitionBuilder: _transitionBuilder, ), ); @@ -344,8 +342,8 @@ void main() { await tester.pumpWidget( PageTransitionSwitcher( duration: const Duration(milliseconds: 100), - child: Container(color: const Color(0xff000000)), transitionBuilder: _transitionBuilder, + child: Container(color: const Color(0xff000000)), ), ); @@ -361,7 +359,6 @@ void main() { await tester.pumpWidget( const PageTransitionSwitcher( duration: Duration(milliseconds: 100), - child: null, transitionBuilder: _transitionBuilder, ), ); @@ -381,16 +378,16 @@ void main() { await tester.pumpWidget( PageTransitionSwitcher( duration: const Duration(milliseconds: 100), - child: Container(key: UniqueKey(), color: const Color(0xff000000)), transitionBuilder: _transitionBuilder, + child: Container(key: UniqueKey(), color: const Color(0xff000000)), ), ); await tester.pumpWidget( PageTransitionSwitcher( duration: const Duration(milliseconds: 100), - child: Container(key: UniqueKey(), color: const Color(0xff000000)), transitionBuilder: _transitionBuilder, + child: Container(key: UniqueKey(), color: const Color(0xff000000)), ), ); await tester.pump(const Duration(milliseconds: 50)); @@ -405,8 +402,7 @@ void main() { // Change the widget tree in the middle of the animation. await tester.pumpWidget(Container(color: const Color(0xffff0000))); - expect(await tester.pumpAndSettle(const Duration(milliseconds: 100)), - equals(1)); + expect(await tester.pumpAndSettle(), equals(1)); }); testWidgets("doesn't reset state of the children in transitions.", @@ -420,42 +416,42 @@ void main() { await tester.pumpWidget( PageTransitionSwitcher( duration: const Duration(milliseconds: 100), - child: StatefulTestWidget(key: statefulOne), transitionBuilder: _transitionBuilder, + child: StatefulTestWidget(key: statefulOne), ), ); - Map _primaryAnimation = + Map primaryAnimation = _getPrimaryAnimation([statefulOne], tester); - Map _secondaryAnimation = + Map secondaryAnimation = _getSecondaryAnimation([statefulOne], tester); - expect(_primaryAnimation[statefulOne], equals(1.0)); - expect(_secondaryAnimation[statefulOne], equals(0.0)); + expect(primaryAnimation[statefulOne], equals(1.0)); + expect(secondaryAnimation[statefulOne], equals(0.0)); expect(StatefulTestWidgetState.generation, equals(1)); await tester.pumpWidget( PageTransitionSwitcher( duration: const Duration(milliseconds: 100), - child: StatefulTestWidget(key: statefulTwo), transitionBuilder: _transitionBuilder, + child: StatefulTestWidget(key: statefulTwo), ), ); await tester.pump(const Duration(milliseconds: 50)); expect(find.byType(FadeTransition), findsNWidgets(2)); - _primaryAnimation = + primaryAnimation = _getPrimaryAnimation([statefulOne, statefulTwo], tester); - _secondaryAnimation = + secondaryAnimation = _getSecondaryAnimation([statefulOne, statefulTwo], tester); - expect(_primaryAnimation[statefulTwo], equals(0.5)); - expect(_secondaryAnimation[statefulTwo], equals(0.0)); + expect(primaryAnimation[statefulTwo], equals(0.5)); + expect(secondaryAnimation[statefulTwo], equals(0.0)); expect(StatefulTestWidgetState.generation, equals(2)); await tester.pumpWidget( PageTransitionSwitcher( duration: const Duration(milliseconds: 100), - child: StatefulTestWidget(key: statefulThree), transitionBuilder: _transitionBuilder, + child: StatefulTestWidget(key: statefulThree), ), ); @@ -473,8 +469,8 @@ void main() { textDirection: TextDirection.rtl, child: PageTransitionSwitcher( duration: const Duration(milliseconds: 100), - child: child, transitionBuilder: _transitionBuilder, + child: child, ), ), ); @@ -511,8 +507,8 @@ void main() { textDirection: TextDirection.ltr, child: PageTransitionSwitcher( duration: const Duration(milliseconds: 100), + transitionBuilder: _transitionBuilder, child: Container(key: containerOne, color: const Color(0xFFFF0000)), - transitionBuilder: _transitionBuilder, ), ), ); @@ -524,8 +520,8 @@ void main() { textDirection: TextDirection.ltr, child: PageTransitionSwitcher( duration: const Duration(milliseconds: 100), + transitionBuilder: _transitionBuilder, child: Container(key: containerTwo, color: const Color(0xFF00FF00)), - transitionBuilder: _transitionBuilder, ), ), ); @@ -537,8 +533,8 @@ void main() { textDirection: TextDirection.ltr, child: PageTransitionSwitcher( duration: const Duration(milliseconds: 100), - child: Container(key: containerThree, color: const Color(0xFF0000FF)), transitionBuilder: _transitionBuilder, + child: Container(key: containerThree, color: const Color(0xFF0000FF)), ), ), ); @@ -569,8 +565,8 @@ void main() { textDirection: TextDirection.ltr, child: PageTransitionSwitcher( duration: const Duration(milliseconds: 100), - child: Container(key: containerThree, color: const Color(0x00000000)), transitionBuilder: newTransitionBuilder, + child: Container(key: containerThree, color: const Color(0x00000000)), ), ), ); diff --git a/packages/animations/test/shared_axis_transition_test.dart b/packages/animations/test/shared_axis_transition_test.dart index b91ba7f284..92fd7fcf35 100644 --- a/packages/animations/test/shared_axis_transition_test.dart +++ b/packages/animations/test/shared_axis_transition_test.dart @@ -596,9 +596,9 @@ void main() { child: Center( child: SharedAxisTransition( transitionType: SharedAxisTransitionType.horizontal, - child: const _StatefulTestWidget(name: 'Foo'), animation: animation, secondaryAnimation: secondaryAnimation, + child: const _StatefulTestWidget(name: 'Foo'), ), ), )); @@ -1239,9 +1239,9 @@ void main() { child: Center( child: SharedAxisTransition( transitionType: SharedAxisTransitionType.vertical, - child: const _StatefulTestWidget(name: 'Foo'), animation: animation, secondaryAnimation: secondaryAnimation, + child: const _StatefulTestWidget(name: 'Foo'), ), ), )); @@ -1775,9 +1775,9 @@ void main() { child: Center( child: SharedAxisTransition( transitionType: SharedAxisTransitionType.scaled, - child: const _StatefulTestWidget(name: 'Foo'), animation: animation, secondaryAnimation: secondaryAnimation, + child: const _StatefulTestWidget(name: 'Foo'), ), ), )); diff --git a/packages/cross_file/CHANGELOG.md b/packages/cross_file/CHANGELOG.md index 03ef5241ba..b462e36f7c 100644 --- a/packages/cross_file/CHANGELOG.md +++ b/packages/cross_file/CHANGELOG.md @@ -1,3 +1,7 @@ +## NEXT + +* Fixes lint warnings in tests. + ## 0.3.3+1 * Fixes `lastModified` unimplemented error description. diff --git a/packages/cross_file/test/x_file_io_test.dart b/packages/cross_file/test/x_file_io_test.dart index fd7c9a6721..cb762cb7b5 100644 --- a/packages/cross_file/test/x_file_io_test.dart +++ b/packages/cross_file/test/x_file_io_test.dart @@ -13,7 +13,7 @@ import 'package:test/test.dart'; final String pathPrefix = Directory.current.path.endsWith('test') ? './assets/' : './test/assets/'; -final String path = pathPrefix + 'hello.txt'; +final String path = '${pathPrefix}hello.txt'; const String expectedStringContents = 'Hello, world!'; final Uint8List bytes = Uint8List.fromList(utf8.encode(expectedStringContents)); final File textFile = File(path); diff --git a/packages/dynamic_layouts/lib/src/dynamic_grid.dart b/packages/dynamic_layouts/lib/src/dynamic_grid.dart index 7152ee787c..9649a3ff3a 100644 --- a/packages/dynamic_layouts/lib/src/dynamic_grid.dart +++ b/packages/dynamic_layouts/lib/src/dynamic_grid.dart @@ -29,9 +29,9 @@ class DynamicGridView extends GridView { super.key, required super.gridDelegate, // This creates a SliverChildBuilderDelegate in the super class. - required IndexedWidgetBuilder itemBuilder, + required super.itemBuilder, super.itemCount, - }) : super.builder(itemBuilder: itemBuilder); + }) : super.builder(); // TODO(snat-s): DynamicGridView.wrap? diff --git a/packages/dynamic_layouts/test/dynamic_grid_test.dart b/packages/dynamic_layouts/test/dynamic_grid_test.dart index 5743eb5601..e6ad3300ae 100644 --- a/packages/dynamic_layouts/test/dynamic_grid_test.dart +++ b/packages/dynamic_layouts/test/dynamic_grid_test.dart @@ -16,7 +16,6 @@ void main() { home: Scaffold( body: DynamicGridView( gridDelegate: TestDelegate(crossAxisCount: 2), - children: const [], ), ), ), @@ -41,7 +40,7 @@ void main() { // Only the visible tiles have ben laid out. expect(find.text('Index 0'), findsOneWidget); - expect(tester.getTopLeft(find.text('Index 0')), const Offset(0.0, 0.0)); + expect(tester.getTopLeft(find.text('Index 0')), Offset.zero); expect(find.text('Index 1'), findsOneWidget); expect(tester.getTopLeft(find.text('Index 1')), const Offset(50.0, 0.0)); expect(find.text('Index 2'), findsOneWidget); @@ -72,7 +71,7 @@ void main() { // Only the visible tiles have ben laid out, up to itemCount. expect(find.text('Index 0'), findsOneWidget); - expect(tester.getTopLeft(find.text('Index 0')), const Offset(0.0, 0.0)); + expect(tester.getTopLeft(find.text('Index 0')), Offset.zero); expect(find.text('Index 1'), findsOneWidget); expect(tester.getTopLeft(find.text('Index 1')), const Offset(50.0, 0.0)); expect(find.text('Index 2'), findsOneWidget); @@ -100,7 +99,7 @@ void main() { // Only the visible tiles have ben laid out. expect(find.text('Index 0'), findsOneWidget); - expect(tester.getTopLeft(find.text('Index 0')), const Offset(0.0, 0.0)); + expect(tester.getTopLeft(find.text('Index 0')), Offset.zero); expect(find.text('Index 1'), findsOneWidget); expect(tester.getTopLeft(find.text('Index 1')), const Offset(50.0, 0.0)); expect(find.text('Index 2'), findsOneWidget); diff --git a/packages/extension_google_sign_in_as_googleapis_auth/CHANGELOG.md b/packages/extension_google_sign_in_as_googleapis_auth/CHANGELOG.md index 18590a2e90..64777fafc4 100644 --- a/packages/extension_google_sign_in_as_googleapis_auth/CHANGELOG.md +++ b/packages/extension_google_sign_in_as_googleapis_auth/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.0.7 + +* Fixes lint warnings. + ## 2.0.6 * Drops support for Flutter <2.8. diff --git a/packages/extension_google_sign_in_as_googleapis_auth/example/lib/main.dart b/packages/extension_google_sign_in_as_googleapis_auth/example/lib/main.dart index 904bbb7f36..b8e37b3c8c 100644 --- a/packages/extension_google_sign_in_as_googleapis_auth/example/lib/main.dart +++ b/packages/extension_google_sign_in_as_googleapis_auth/example/lib/main.dart @@ -100,7 +100,7 @@ class SignInDemoState extends State { try { await _googleSignIn.signIn(); } catch (error) { - print(error); + print(error); // ignore: avoid_print } } @@ -122,12 +122,12 @@ class SignInDemoState extends State { const Text('Signed in successfully.'), Text(_contactText), ElevatedButton( - child: const Text('SIGN OUT'), onPressed: _handleSignOut, + child: const Text('SIGN OUT'), ), ElevatedButton( - child: const Text('REFRESH'), onPressed: _handleGetContact, + child: const Text('REFRESH'), ), ], ); @@ -137,8 +137,8 @@ class SignInDemoState extends State { children: [ const Text('You are not currently signed in.'), ElevatedButton( - child: const Text('SIGN IN'), onPressed: _handleSignIn, + child: const Text('SIGN IN'), ), ], ); diff --git a/packages/extension_google_sign_in_as_googleapis_auth/pubspec.yaml b/packages/extension_google_sign_in_as_googleapis_auth/pubspec.yaml index 1ff2656966..63fea3ee44 100644 --- a/packages/extension_google_sign_in_as_googleapis_auth/pubspec.yaml +++ b/packages/extension_google_sign_in_as_googleapis_auth/pubspec.yaml @@ -8,7 +8,7 @@ name: extension_google_sign_in_as_googleapis_auth description: A bridge package between google_sign_in and googleapis_auth, to create Authenticated Clients from google_sign_in user credentials. repository: https://github.com/flutter/packages/tree/main/packages/extension_google_sign_in_as_googleapis_auth issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+extension_google_sign_in_as_googleapis_auth%22 -version: 2.0.6 +version: 2.0.7 environment: sdk: ">=2.12.0 <3.0.0" diff --git a/packages/flutter_image/CHANGELOG.md b/packages/flutter_image/CHANGELOG.md index 39e694a9fc..7413350b75 100644 --- a/packages/flutter_image/CHANGELOG.md +++ b/packages/flutter_image/CHANGELOG.md @@ -1,8 +1,9 @@ -## NEXT +## 4.1.4 * Ignores lint warnings from new changes in Flutter master. * Suppresses more deprecation warnings for changes to Flutter master. * Removes duplicate test from test script. +* Fixes lint warnings. ## 4.1.3 diff --git a/packages/flutter_image/lib/network.dart b/packages/flutter_image/lib/network.dart index cbbdee1d8d..109634dc2e 100644 --- a/packages/flutter_image/lib/network.dart +++ b/packages/flutter_image/lib/network.dart @@ -227,8 +227,9 @@ class NetworkImageWithRetry extends ImageProvider { if (other.runtimeType != runtimeType) { return false; } - final NetworkImageWithRetry typedOther = other; - return url == typedOther.url && scale == typedOther.scale; + return other is NetworkImageWithRetry && + url == other.url && + scale == other.scale; } @override diff --git a/packages/flutter_image/pubspec.yaml b/packages/flutter_image/pubspec.yaml index 6e8c362407..3fa9421758 100644 --- a/packages/flutter_image/pubspec.yaml +++ b/packages/flutter_image/pubspec.yaml @@ -3,7 +3,7 @@ description: > Image utilities for Flutter: improved network providers, effects, etc. repository: https://github.com/flutter/packages/tree/main/packages/flutter_image issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+flutter_image%22 -version: 4.1.3 +version: 4.1.4 environment: sdk: ">=2.12.0 <3.0.0" diff --git a/packages/flutter_image/test/network_test.dart b/packages/flutter_image/test/network_test.dart index f559ca2645..ecffd29270 100644 --- a/packages/flutter_image/test/network_test.dart +++ b/packages/flutter_image/test/network_test.dart @@ -85,7 +85,7 @@ void main() { }); test('retries 6 times then gives up', () async { - final dynamic maxAttemptCountReached = expectAsync0(() {}); + final VoidCallback maxAttemptCountReached = expectAsync0(() {}); int attemptCount = 0; Future onAttempt() async { diff --git a/packages/flutter_markdown/CHANGELOG.md b/packages/flutter_markdown/CHANGELOG.md index d85c36b4d8..c3dc2ccd07 100644 --- a/packages/flutter_markdown/CHANGELOG.md +++ b/packages/flutter_markdown/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.6.10+5 + +* Fixes lint warnings. + ## 0.6.10+4 * Updates text theme parameters to avoid deprecation issues. diff --git a/packages/flutter_markdown/example/lib/demos/basic_markdown_demo.dart b/packages/flutter_markdown/example/lib/demos/basic_markdown_demo.dart index 76557f65b2..58553ecc1c 100644 --- a/packages/flutter_markdown/example/lib/demos/basic_markdown_demo.dart +++ b/packages/flutter_markdown/example/lib/demos/basic_markdown_demo.dart @@ -43,6 +43,8 @@ Since GitHub Flavored is the default extension set, it is the initial setting for the formatted Markdown view in the demo. """; +// TODO(goderbauer): Restructure the examples to avoid this ignore, https://github.com/flutter/flutter/issues/110208. +// ignore: avoid_implementing_value_types class BasicMarkdownDemo extends StatefulWidget implements MarkdownDemoWidget { const BasicMarkdownDemo({Key? key}) : super(key: key); @@ -63,7 +65,7 @@ class BasicMarkdownDemo extends StatefulWidget implements MarkdownDemoWidget { Future get notes => Future.value(_notes); @override - _BasicMarkdownDemoState createState() => _BasicMarkdownDemoState(); + State createState() => _BasicMarkdownDemoState(); } class _BasicMarkdownDemoState extends State { diff --git a/packages/flutter_markdown/example/lib/demos/centered_header_demo.dart b/packages/flutter_markdown/example/lib/demos/centered_header_demo.dart index be5c157f0d..3b344c4f64 100644 --- a/packages/flutter_markdown/example/lib/demos/centered_header_demo.dart +++ b/packages/flutter_markdown/example/lib/demos/centered_header_demo.dart @@ -25,6 +25,8 @@ This example demonstrates how to implement a centered headline using a custom bu '''; +// TODO(goderbauer): Restructure the examples to avoid this ignore, https://github.com/flutter/flutter/issues/110208. +// ignore: avoid_implementing_value_types class CenteredHeaderDemo extends StatelessWidget implements MarkdownDemoWidget { const CenteredHeaderDemo({Key? key}) : super(key: key); diff --git a/packages/flutter_markdown/example/lib/demos/extended_emoji_demo.dart b/packages/flutter_markdown/example/lib/demos/extended_emoji_demo.dart index 61b217b27a..4b55c58c5c 100644 --- a/packages/flutter_markdown/example/lib/demos/extended_emoji_demo.dart +++ b/packages/flutter_markdown/example/lib/demos/extended_emoji_demo.dart @@ -46,6 +46,8 @@ class ExtendedEmojiSyntax extends md.EmojiSyntax { ``` """; +// TODO(goderbauer): Restructure the examples to avoid this ignore, https://github.com/flutter/flutter/issues/110208. +// ignore: avoid_implementing_value_types class ExtendedEmojiDemo extends StatelessWidget implements MarkdownDemoWidget { const ExtendedEmojiDemo({Key? key}) : super(key: key); diff --git a/packages/flutter_markdown/example/lib/demos/markdown_body_shrink_wrap_demo.dart b/packages/flutter_markdown/example/lib/demos/markdown_body_shrink_wrap_demo.dart index 97c3daa59f..d2de056e7d 100644 --- a/packages/flutter_markdown/example/lib/demos/markdown_body_shrink_wrap_demo.dart +++ b/packages/flutter_markdown/example/lib/demos/markdown_body_shrink_wrap_demo.dart @@ -2,6 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// TODO(goderbauer): Restructure the examples to avoid this ignore, https://github.com/flutter/flutter/issues/110208. +// ignore_for_file: avoid_implementing_value_types + import 'package:flutter/material.dart'; import 'package:flutter_markdown/flutter_markdown.dart'; import '../shared/dropdown_menu.dart'; diff --git a/packages/flutter_markdown/example/lib/demos/minimal_markdown_demo.dart b/packages/flutter_markdown/example/lib/demos/minimal_markdown_demo.dart index 9cedd61750..cd97424fd0 100644 --- a/packages/flutter_markdown/example/lib/demos/minimal_markdown_demo.dart +++ b/packages/flutter_markdown/example/lib/demos/minimal_markdown_demo.dart @@ -2,6 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// TODO(goderbauer): Restructure the examples to avoid this ignore, https://github.com/flutter/flutter/issues/110208. +// ignore_for_file: avoid_implementing_value_types + import 'package:flutter/material.dart'; import 'package:flutter_markdown/flutter_markdown.dart'; import '../shared/markdown_demo_widget.dart'; diff --git a/packages/flutter_markdown/example/lib/demos/original_demo.dart b/packages/flutter_markdown/example/lib/demos/original_demo.dart index f0fd09a70c..e623b97890 100644 --- a/packages/flutter_markdown/example/lib/demos/original_demo.dart +++ b/packages/flutter_markdown/example/lib/demos/original_demo.dart @@ -2,6 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// TODO(goderbauer): Restructure the examples to avoid this ignore, https://github.com/flutter/flutter/issues/110208. +// ignore_for_file: avoid_implementing_value_types + import 'package:flutter/material.dart'; import 'package:flutter_markdown/flutter_markdown.dart'; import '../shared/markdown_demo_widget.dart'; diff --git a/packages/flutter_markdown/example/lib/demos/subscript_syntax_demo.dart b/packages/flutter_markdown/example/lib/demos/subscript_syntax_demo.dart index 372168c37b..5a6e539a7a 100644 --- a/packages/flutter_markdown/example/lib/demos/subscript_syntax_demo.dart +++ b/packages/flutter_markdown/example/lib/demos/subscript_syntax_demo.dart @@ -2,6 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// TODO(goderbauer): Restructure the examples to avoid this ignore, https://github.com/flutter/flutter/issues/110208. +// ignore_for_file: avoid_implementing_value_types + import 'package:flutter/material.dart'; import 'package:flutter_markdown/flutter_markdown.dart'; import 'package:markdown/markdown.dart' as md; diff --git a/packages/flutter_markdown/example/lib/demos/wrap_alignment_demo.dart b/packages/flutter_markdown/example/lib/demos/wrap_alignment_demo.dart index c3ca3664bf..da4cbc89bd 100644 --- a/packages/flutter_markdown/example/lib/demos/wrap_alignment_demo.dart +++ b/packages/flutter_markdown/example/lib/demos/wrap_alignment_demo.dart @@ -28,6 +28,8 @@ spacing parameter. The Markdown widget lays out block elements in a column using spacing parameter sets the height of the **SizedBox**. '''; +// TODO(goderbauer): Restructure the examples to avoid this ignore, https://github.com/flutter/flutter/issues/110208. +// ignore: avoid_implementing_value_types class WrapAlignmentDemo extends StatefulWidget implements MarkdownDemoWidget { const WrapAlignmentDemo({Key? key}) : super(key: key); @@ -48,7 +50,7 @@ class WrapAlignmentDemo extends StatefulWidget implements MarkdownDemoWidget { Future get notes => Future.value(_notes); @override - _WrapAlignmentDemoState createState() => _WrapAlignmentDemoState(); + State createState() => _WrapAlignmentDemoState(); } class _WrapAlignmentDemoState extends State { diff --git a/packages/flutter_markdown/example/lib/shared/dropdown_menu.dart b/packages/flutter_markdown/example/lib/shared/dropdown_menu.dart index 3d0af773c3..48388efd1d 100644 --- a/packages/flutter_markdown/example/lib/shared/dropdown_menu.dart +++ b/packages/flutter_markdown/example/lib/shared/dropdown_menu.dart @@ -65,11 +65,11 @@ class DropdownMenu extends StatelessWidget { items: >[ for (String item in items.keys) DropdownMenuItem( + value: items[item], child: Container( padding: const EdgeInsets.only(left: 4), child: Text(item), ), - value: items[item], ), ], onChanged: (T? value) => onChanged!(value), diff --git a/packages/flutter_markdown/example/pubspec.yaml b/packages/flutter_markdown/example/pubspec.yaml index 5454129c6a..9cb6fabb0f 100644 --- a/packages/flutter_markdown/example/pubspec.yaml +++ b/packages/flutter_markdown/example/pubspec.yaml @@ -9,10 +9,11 @@ environment: dependencies: flutter: sdk: flutter - -dev_dependencies: flutter_markdown: path: ../ + markdown: 5.0.0 + +dev_dependencies: flutter_test: sdk: flutter diff --git a/packages/flutter_markdown/lib/src/_functions_io.dart b/packages/flutter_markdown/lib/src/_functions_io.dart index eb7119bcc4..7c35ba4853 100644 --- a/packages/flutter_markdown/lib/src/_functions_io.dart +++ b/packages/flutter_markdown/lib/src/_functions_io.dart @@ -60,6 +60,7 @@ final MarkdownStyleSheet Function(BuildContext, MarkdownStyleSheetBaseTheme?) MarkdownStyleSheet.fromCupertinoTheme(CupertinoTheme.of(context)); break; case MarkdownStyleSheetBaseTheme.material: + // ignore: no_default_cases default: result = MarkdownStyleSheet.fromTheme(Theme.of(context)); } diff --git a/packages/flutter_markdown/lib/src/_functions_web.dart b/packages/flutter_markdown/lib/src/_functions_web.dart index 1c34867293..a58a9cea37 100644 --- a/packages/flutter_markdown/lib/src/_functions_web.dart +++ b/packages/flutter_markdown/lib/src/_functions_web.dart @@ -63,7 +63,7 @@ final MarkdownStyleSheet Function(BuildContext, MarkdownStyleSheetBaseTheme?) MarkdownStyleSheet.fromCupertinoTheme(CupertinoTheme.of(context)); break; case MarkdownStyleSheetBaseTheme.material: - default: + default: // ignore: no_default_cases result = MarkdownStyleSheet.fromTheme(Theme.of(context)); } diff --git a/packages/flutter_markdown/lib/src/builder.dart b/packages/flutter_markdown/lib/src/builder.dart index fe7ab32485..8c2becff35 100644 --- a/packages/flutter_markdown/lib/src/builder.dart +++ b/packages/flutter_markdown/lib/src/builder.dart @@ -209,8 +209,9 @@ class MarkdownBuilder implements md.NodeVisitor { _addAnonymousBlockIfNeeded(); if (_isListTag(tag)) { _listIndents.add(tag); - if (element.attributes['start'] != null) + if (element.attributes['start'] != null) { start = int.parse(element.attributes['start']!) - 1; + } } else if (tag == 'blockquote') { _isInBlockquote = true; } else if (tag == 'table') { @@ -278,7 +279,7 @@ class MarkdownBuilder implements md.NodeVisitor { ? element.children! .map((md.Node e) => e is md.Text ? e.text : extractTextFromElement(e)) - .join('') + .join() : (element is md.Element && (element.attributes.isNotEmpty) ? element.attributes['alt'] : ''); @@ -298,13 +299,13 @@ class MarkdownBuilder implements md.NodeVisitor { String trimText(String text) { // The leading spaces pattern is used to identify spaces // at the beginning of a line of text. - final RegExp _leadingSpacesPattern = RegExp(r'^ *'); + final RegExp leadingSpacesPattern = RegExp(r'^ *'); // The soft line break is used to identify the spaces at the end of a line // of text and the leading spaces in the immediately following the line // of text. These spaces are removed in accordance with the Markdown // specification on soft line breaks when lines of text are joined. - final RegExp _softLineBreak = RegExp(r' ?\n *'); + final RegExp softLineBreakPattern = RegExp(r' ?\n *'); // Leading spaces following a hard line break are ignored. // https://github.github.com/gfm/#example-657 @@ -312,13 +313,13 @@ class MarkdownBuilder implements md.NodeVisitor { // https://github.github.com/gfm/#example-192 // https://github.github.com/gfm/#example-236 if (const ['ul', 'ol', 'p', 'br'].contains(_lastVisitedTag)) { - text = text.replaceAll(_leadingSpacesPattern, ''); + text = text.replaceAll(leadingSpacesPattern, ''); } if (softLineBreak) { return text; } - return text.replaceAll(_softLineBreak, ' '); + return text.replaceAll(softLineBreakPattern, ' '); } Widget? child; @@ -530,7 +531,7 @@ class MarkdownBuilder implements md.NodeVisitor { if (_linkHandlers.isNotEmpty) { final TapGestureRecognizer recognizer = _linkHandlers.last as TapGestureRecognizer; - return GestureDetector(child: child, onTap: recognizer.onTap); + return GestureDetector(onTap: recognizer.onTap, child: child); } else { return child; } @@ -648,8 +649,8 @@ class MarkdownBuilder implements md.NodeVisitor { ); final Wrap wrap = Wrap( crossAxisAlignment: WrapCrossAlignment.center, - children: mergedInlines, alignment: blockAlignment, + children: mergedInlines, ); if (textPadding == EdgeInsets.zero) { @@ -757,9 +758,13 @@ class MarkdownBuilder implements md.NodeVisitor { case 'pre': return styleSheet.codeblockAlign; case 'hr': + // TODO(goderbauer): We shouldn't be printing here, https://github.com/flutter/flutter/issues/110209 + // ignore: avoid_print print('Markdown did not handle hr for alignment'); break; case 'li': + // TODO(goderbauer): We shouldn't be printing here, https://github.com/flutter/flutter/issues/110209 + // ignore: avoid_print print('Markdown did not handle li for alignment'); break; } diff --git a/packages/flutter_markdown/lib/src/style_sheet.dart b/packages/flutter_markdown/lib/src/style_sheet.dart index f9feee0182..31ecc3e5d6 100644 --- a/packages/flutter_markdown/lib/src/style_sheet.dart +++ b/packages/flutter_markdown/lib/src/style_sheet.dart @@ -123,7 +123,6 @@ class MarkdownStyleSheet { tableHeadAlign: TextAlign.center, tableBorder: TableBorder.all( color: theme.dividerColor, - width: 1, ), tableColumnWidth: const FlexColumnWidth(), tableCellsPadding: const EdgeInsets.fromLTRB(16, 8, 16, 8), @@ -253,7 +252,6 @@ class MarkdownStyleSheet { color: theme.brightness == Brightness.dark ? CupertinoColors.systemGrey4.darkColor : CupertinoColors.systemGrey4.color, - width: 1, ), ), ), @@ -660,57 +658,57 @@ class MarkdownStyleSheet { if (other.runtimeType != MarkdownStyleSheet) { return false; } - final MarkdownStyleSheet typedOther = other; - return typedOther.a == a && - typedOther.p == p && - typedOther.pPadding == pPadding && - typedOther.code == code && - typedOther.h1 == h1 && - typedOther.h1Padding == h1Padding && - typedOther.h2 == h2 && - typedOther.h2Padding == h2Padding && - typedOther.h3 == h3 && - typedOther.h3Padding == h3Padding && - typedOther.h4 == h4 && - typedOther.h4Padding == h4Padding && - typedOther.h5 == h5 && - typedOther.h5Padding == h5Padding && - typedOther.h6 == h6 && - typedOther.h6Padding == h6Padding && - typedOther.em == em && - typedOther.strong == strong && - typedOther.del == del && - typedOther.blockquote == blockquote && - typedOther.img == img && - typedOther.checkbox == checkbox && - typedOther.blockSpacing == blockSpacing && - typedOther.listIndent == listIndent && - typedOther.listBullet == listBullet && - typedOther.listBulletPadding == listBulletPadding && - typedOther.tableHead == tableHead && - typedOther.tableBody == tableBody && - typedOther.tableHeadAlign == tableHeadAlign && - typedOther.tableBorder == tableBorder && - typedOther.tableColumnWidth == tableColumnWidth && - typedOther.tableCellsPadding == tableCellsPadding && - typedOther.tableCellsDecoration == tableCellsDecoration && - typedOther.blockquotePadding == blockquotePadding && - typedOther.blockquoteDecoration == blockquoteDecoration && - typedOther.codeblockPadding == codeblockPadding && - typedOther.codeblockDecoration == codeblockDecoration && - typedOther.horizontalRuleDecoration == horizontalRuleDecoration && - typedOther.textAlign == textAlign && - typedOther.h1Align == h1Align && - typedOther.h2Align == h2Align && - typedOther.h3Align == h3Align && - typedOther.h4Align == h4Align && - typedOther.h5Align == h5Align && - typedOther.h6Align == h6Align && - typedOther.unorderedListAlign == unorderedListAlign && - typedOther.orderedListAlign == orderedListAlign && - typedOther.blockquoteAlign == blockquoteAlign && - typedOther.codeblockAlign == codeblockAlign && - typedOther.textScaleFactor == textScaleFactor; + return other is MarkdownStyleSheet && + other.a == a && + other.p == p && + other.pPadding == pPadding && + other.code == code && + other.h1 == h1 && + other.h1Padding == h1Padding && + other.h2 == h2 && + other.h2Padding == h2Padding && + other.h3 == h3 && + other.h3Padding == h3Padding && + other.h4 == h4 && + other.h4Padding == h4Padding && + other.h5 == h5 && + other.h5Padding == h5Padding && + other.h6 == h6 && + other.h6Padding == h6Padding && + other.em == em && + other.strong == strong && + other.del == del && + other.blockquote == blockquote && + other.img == img && + other.checkbox == checkbox && + other.blockSpacing == blockSpacing && + other.listIndent == listIndent && + other.listBullet == listBullet && + other.listBulletPadding == listBulletPadding && + other.tableHead == tableHead && + other.tableBody == tableBody && + other.tableHeadAlign == tableHeadAlign && + other.tableBorder == tableBorder && + other.tableColumnWidth == tableColumnWidth && + other.tableCellsPadding == tableCellsPadding && + other.tableCellsDecoration == tableCellsDecoration && + other.blockquotePadding == blockquotePadding && + other.blockquoteDecoration == blockquoteDecoration && + other.codeblockPadding == codeblockPadding && + other.codeblockDecoration == codeblockDecoration && + other.horizontalRuleDecoration == horizontalRuleDecoration && + other.textAlign == textAlign && + other.h1Align == h1Align && + other.h2Align == h2Align && + other.h3Align == h3Align && + other.h4Align == h4Align && + other.h5Align == h5Align && + other.h6Align == h6Align && + other.unorderedListAlign == unorderedListAlign && + other.orderedListAlign == orderedListAlign && + other.blockquoteAlign == blockquoteAlign && + other.codeblockAlign == codeblockAlign && + other.textScaleFactor == textScaleFactor; } @override diff --git a/packages/flutter_markdown/lib/src/widget.dart b/packages/flutter_markdown/lib/src/widget.dart index 6a0c28a372..17f74066f5 100644 --- a/packages/flutter_markdown/lib/src/widget.dart +++ b/packages/flutter_markdown/lib/src/widget.dart @@ -7,9 +7,9 @@ import 'dart:convert'; import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; -import 'package:flutter_markdown/flutter_markdown.dart'; import 'package:markdown/markdown.dart' as md; +import '../flutter_markdown.dart'; import '_functions_io.dart' if (dart.library.html) '_functions_web.dart'; /// Signature for callbacks used by [MarkdownWidget] when the user taps a link. @@ -271,7 +271,7 @@ abstract class MarkdownWidget extends StatefulWidget { Widget build(BuildContext context, List? children); @override - _MarkdownWidgetState createState() => _MarkdownWidgetState(); + State createState() => _MarkdownWidgetState(); } class _MarkdownWidgetState extends State @@ -348,8 +348,9 @@ class _MarkdownWidgetState extends State final List localRecognizers = List.from(_recognizers); _recognizers.clear(); - for (final GestureRecognizer recognizer in localRecognizers) + for (final GestureRecognizer recognizer in localRecognizers) { recognizer.dispose(); + } } @override diff --git a/packages/flutter_markdown/pubspec.yaml b/packages/flutter_markdown/pubspec.yaml index 8aefa93765..e6e8ac4c8b 100644 --- a/packages/flutter_markdown/pubspec.yaml +++ b/packages/flutter_markdown/pubspec.yaml @@ -4,7 +4,7 @@ description: A Markdown renderer for Flutter. Create rich text output, formatted with simple Markdown tags. repository: https://github.com/flutter/packages/tree/main/packages/flutter_markdown issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+flutter_markdown%22 -version: 0.6.10+4 +version: 0.6.10+5 environment: sdk: ">=2.12.0 <3.0.0" diff --git a/packages/flutter_markdown/test/html_test.dart b/packages/flutter_markdown/test/html_test.dart index aa11952708..11525d5e1b 100644 --- a/packages/flutter_markdown/test/html_test.dart +++ b/packages/flutter_markdown/test/html_test.dart @@ -29,7 +29,7 @@ void defineTests() { ); testWidgets( - 'doesn\'t convert & to & when parsing', + "doesn't convert & to & when parsing", (WidgetTester tester) async { await tester.pumpWidget( boilerplate( @@ -41,7 +41,7 @@ void defineTests() { ); testWidgets( - 'doesn\'t convert < to < when parsing', + "doesn't convert < to < when parsing", (WidgetTester tester) async { await tester.pumpWidget( boilerplate( @@ -53,7 +53,7 @@ void defineTests() { ); testWidgets( - 'doesn\'t convert existing HTML entities when parsing', + "doesn't convert existing HTML entities when parsing", (WidgetTester tester) async { await tester.pumpWidget( boilerplate( diff --git a/packages/flutter_markdown/test/image_test_mocks.dart b/packages/flutter_markdown/test/image_test_mocks.dart index 8888361e85..3aab6e8ff6 100644 --- a/packages/flutter_markdown/test/image_test_mocks.dart +++ b/packages/flutter_markdown/test/image_test_mocks.dart @@ -21,7 +21,7 @@ MockHttpClient createMockImageHttpClient(SecurityContext? _) { final MockHttpClientResponse response = MockHttpClientResponse(); final MockHttpHeaders headers = MockHttpHeaders(); - final List _transparentImage = getTestImageData(); + final List transparentImage = getTestImageData(); when(client.getUrl(any)) .thenAnswer((_) => Future.value(request)); @@ -33,7 +33,7 @@ MockHttpClient createMockImageHttpClient(SecurityContext? _) { when(client.autoUncompress = any).thenAnswer((_) => null); - when(response.contentLength).thenReturn(_transparentImage.length); + when(response.contentLength).thenReturn(transparentImage.length); when(response.statusCode).thenReturn(HttpStatus.ok); @@ -49,8 +49,7 @@ MockHttpClient createMockImageHttpClient(SecurityContext? _) { invocation.namedArguments[#onError]; final bool? cancelOnError = invocation.namedArguments[#cancelOnError]; - return Stream>.fromIterable(>[_transparentImage]) - .listen( + return Stream>.fromIterable(>[transparentImage]).listen( onData, onError: onError, onDone: onDone, @@ -94,6 +93,7 @@ List getTestImageData() { /// Define the "fake" data types to be used in mock data type definitions. These /// fake data types are important in the definition of the return values of the /// properties and methods of the mock data types for null safety. +// ignore: avoid_implementing_value_types class _FakeDuration extends Fake implements Duration {} class _FakeHttpClientRequest extends Fake implements HttpClientRequest {} @@ -123,8 +123,8 @@ class MockHttpClient extends Mock implements HttpClient { returnValue: _FakeDuration()) as Duration; @override - set idleTimeout(Duration? _idleTimeout) => - super.noSuchMethod(Invocation.setter(#idleTimeout, _idleTimeout)); + set idleTimeout(Duration? idleTimeout) => + super.noSuchMethod(Invocation.setter(#idleTimeout, idleTimeout)); @override bool get autoUncompress => @@ -132,8 +132,8 @@ class MockHttpClient extends Mock implements HttpClient { as bool; @override - set autoUncompress(bool? _autoUncompress) => - super.noSuchMethod(Invocation.setter(#autoUncompress, _autoUncompress)); + set autoUncompress(bool? autoUncompress) => + super.noSuchMethod(Invocation.setter(#autoUncompress, autoUncompress)); @override Future open( @@ -259,8 +259,8 @@ class MockHttpClientRequest extends Mock implements HttpClientRequest { returnValue: false) as bool; @override - set persistentConnection(bool? _persistentConnection) => super.noSuchMethod( - Invocation.setter(#persistentConnection, _persistentConnection)); + set persistentConnection(bool? persistentConnection) => super.noSuchMethod( + Invocation.setter(#persistentConnection, persistentConnection)); @override bool get followRedirects => super @@ -268,8 +268,8 @@ class MockHttpClientRequest extends Mock implements HttpClientRequest { as bool; @override - set followRedirects(bool? _followRedirects) => - super.noSuchMethod(Invocation.setter(#followRedirects, _followRedirects)); + set followRedirects(bool? followRedirects) => + super.noSuchMethod(Invocation.setter(#followRedirects, followRedirects)); @override int get maxRedirects => @@ -277,8 +277,8 @@ class MockHttpClientRequest extends Mock implements HttpClientRequest { as int; @override - set maxRedirects(int? _maxRedirects) => - super.noSuchMethod(Invocation.setter(#maxRedirects, _maxRedirects)); + set maxRedirects(int? maxRedirects) => + super.noSuchMethod(Invocation.setter(#maxRedirects, maxRedirects)); @override int get contentLength => @@ -286,8 +286,8 @@ class MockHttpClientRequest extends Mock implements HttpClientRequest { as int; @override - set contentLength(int? _contentLength) => - super.noSuchMethod(Invocation.setter(#contentLength, _contentLength)); + set contentLength(int? contentLength) => + super.noSuchMethod(Invocation.setter(#contentLength, contentLength)); @override bool get bufferOutput => @@ -295,8 +295,8 @@ class MockHttpClientRequest extends Mock implements HttpClientRequest { as bool; @override - set bufferOutput(bool? _bufferOutput) => - super.noSuchMethod(Invocation.setter(#bufferOutput, _bufferOutput)); + set bufferOutput(bool? bufferOutput) => + super.noSuchMethod(Invocation.setter(#bufferOutput, bufferOutput)); @override String get method => @@ -428,8 +428,8 @@ class MockHttpHeaders extends Mock implements HttpHeaders { as int; @override - set contentLength(int? _contentLength) => - super.noSuchMethod(Invocation.setter(#contentLength, _contentLength)); + set contentLength(int? contentLength) => + super.noSuchMethod(Invocation.setter(#contentLength, contentLength)); @override bool get persistentConnection => @@ -437,8 +437,8 @@ class MockHttpHeaders extends Mock implements HttpHeaders { returnValue: false) as bool; @override - set persistentConnection(bool? _persistentConnection) => super.noSuchMethod( - Invocation.setter(#persistentConnection, _persistentConnection)); + set persistentConnection(bool? persistentConnection) => super.noSuchMethod( + Invocation.setter(#persistentConnection, persistentConnection)); @override bool get chunkedTransferEncoding => @@ -446,9 +446,9 @@ class MockHttpHeaders extends Mock implements HttpHeaders { returnValue: false) as bool; @override - set chunkedTransferEncoding(bool? _chunkedTransferEncoding) => - super.noSuchMethod(Invocation.setter( - #chunkedTransferEncoding, _chunkedTransferEncoding)); + set chunkedTransferEncoding(bool? chunkedTransferEncoding) => + super.noSuchMethod( + Invocation.setter(#chunkedTransferEncoding, chunkedTransferEncoding)); @override List? operator [](String? name) => diff --git a/packages/flutter_markdown/test/link_test.dart b/packages/flutter_markdown/test/link_test.dart index fca6a26732..3ddab99fc3 100644 --- a/packages/flutter_markdown/test/link_test.dart +++ b/packages/flutter_markdown/test/link_test.dart @@ -702,7 +702,7 @@ void defineTests() { // Example 513b from GFM. 'link title in single quotes', (WidgetTester tester) async { - const String data = '[link](/url \'title\')'; + const String data = "[link](/url 'title')"; MarkdownLink? linkTapResults; await tester.pumpWidget( boilerplate( @@ -1202,7 +1202,7 @@ void defineTests() { testWidgets( // Example 531 from GFM. - 'brackets that aren\'t part of links do not take precedence', + "brackets that aren't part of links do not take precedence", (WidgetTester tester) async { const String data = '*foo [bar* baz]'; await tester.pumpWidget( diff --git a/packages/flutter_markdown/test/markdown_body_shrink_wrap_test.dart b/packages/flutter_markdown/test/markdown_body_shrink_wrap_test.dart index 4cf2afcd86..8cb89a20be 100644 --- a/packages/flutter_markdown/test/markdown_body_shrink_wrap_test.dart +++ b/packages/flutter_markdown/test/markdown_body_shrink_wrap_test.dart @@ -22,7 +22,6 @@ void defineTests() { alignment: Alignment.bottomCenter, child: MarkdownBody( data: 'This is a [link](https://flutter.dev/)', - shrinkWrap: true, ), ), ], diff --git a/packages/flutter_markdown/test/scrollable_test.dart b/packages/flutter_markdown/test/scrollable_test.dart index e7ace8a957..a0cdfe94f4 100644 --- a/packages/flutter_markdown/test/scrollable_test.dart +++ b/packages/flutter_markdown/test/scrollable_test.dart @@ -15,7 +15,7 @@ void defineTests() { 'code block', (WidgetTester tester) async { const String data = - '```\nvoid main() {\n print(\'Hello World!\');\n}\n```'; + "```\nvoid main() {\n print('Hello World!');\n}\n```"; await tester.pumpWidget( boilerplate( diff --git a/packages/flutter_markdown/test/utils.dart b/packages/flutter_markdown/test/utils.dart index 3286260614..f4ebb95891 100644 --- a/packages/flutter_markdown/test/utils.dart +++ b/packages/flutter_markdown/test/utils.dart @@ -10,10 +10,9 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; -final TextTheme textTheme = - Typography.material2018(platform: TargetPlatform.android) - .black - .merge(const TextTheme(bodyMedium: TextStyle(fontSize: 12.0))); +final TextTheme textTheme = Typography.material2018() + .black + .merge(const TextTheme(bodyMedium: TextStyle(fontSize: 12.0))); void expectWidgetTypes(Iterable widgets, List expected) { final List actual = widgets.map((Widget w) => w.runtimeType).toList(); @@ -182,7 +181,7 @@ class TestAssetBundle extends CachingAssetBundle { // verses 'flutter test test/*_test.dart'. Adjust the root directory // to access the assets directory. final io.Directory rootDirectory = - io.Directory.current.path.endsWith(io.Platform.pathSeparator + 'test') + io.Directory.current.path.endsWith('${io.Platform.pathSeparator}test') ? io.Directory.current.parent : io.Directory.current; final io.File file = @@ -194,7 +193,7 @@ class TestAssetBundle extends CachingAssetBundle { } return asset; } else { - throw 'Unknown asset key: $key'; + throw ArgumentError('Unknown asset key: $key'); } } } diff --git a/packages/fuchsia_ctl/CHANGELOG.md b/packages/fuchsia_ctl/CHANGELOG.md index b6d5db838f..25aacf79f3 100644 --- a/packages/fuchsia_ctl/CHANGELOG.md +++ b/packages/fuchsia_ctl/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.0.25+1 + +- Fixes lint warnings. + + ## 0.0.25 - Fix `unnecessary_import` lint errors. diff --git a/packages/fuchsia_ctl/bin/main.dart b/packages/fuchsia_ctl/bin/main.dart index ca7f8f91d1..95d27121f6 100644 --- a/packages/fuchsia_ctl/bin/main.dart +++ b/packages/fuchsia_ctl/bin/main.dart @@ -182,7 +182,7 @@ Future ssh( final OperationResult result = await sshClient.runCommand( targetIp, identityFilePath: identityFile, - command: args['command'].split(' '), + command: (args['command'] as String).split(' '), timeoutMs: Duration(milliseconds: int.parse(args['timeout-seconds']) * 1000), logFilePath: outputFile, @@ -203,7 +203,6 @@ Future pave( ) async { const ImagePaver paver = ImagePaver(); const RetryOptions r = RetryOptions( - maxDelay: Duration(seconds: 30), maxAttempts: 3, ); return r.retry(() async { @@ -268,7 +267,7 @@ Future pushPackages( final String repositoryBase = path.join(repo.path, 'amber-files'); stdout.writeln('Serving $repositoryBase to $targetIp'); - await server.serveRepo(repositoryBase, port: 0); + await server.serveRepo(repositoryBase); await amberCtl.addSrc(server.serverPort); stdout.writeln('Pushing packages $packages to $targetIp'); @@ -335,7 +334,7 @@ Future test( return result; } } - await server.serveRepo(repo.path, port: 0); + await server.serveRepo(repo.path); await amberCtl.addSrc(server.serverPort); for (final String farFile in farFiles) { diff --git a/packages/fuchsia_ctl/lib/src/amber_ctl.dart b/packages/fuchsia_ctl/lib/src/amber_ctl.dart index 8124cd09be..1b79f50353 100644 --- a/packages/fuchsia_ctl/lib/src/amber_ctl.dart +++ b/packages/fuchsia_ctl/lib/src/amber_ctl.dart @@ -4,10 +4,11 @@ import 'dart:io'; -import 'package:fuchsia_ctl/fuchsia_ctl.dart'; import 'package:meta/meta.dart'; import 'package:uuid/uuid.dart'; +import '../fuchsia_ctl.dart'; + const SshClient _kSsh = SshClient(); /// Wrapper for amberctl utility for commands executed on the target device. diff --git a/packages/fuchsia_ctl/lib/src/emulator.dart b/packages/fuchsia_ctl/lib/src/emulator.dart index 9ab5aff9d3..5d7f792f3e 100644 --- a/packages/fuchsia_ctl/lib/src/emulator.dart +++ b/packages/fuchsia_ctl/lib/src/emulator.dart @@ -180,7 +180,7 @@ class Emulator { '-device', 'virtio-blk-pci,drive=vdisk', '-append', // TODO(chillers): Generate entropy mixin. - '\'TERM=xterm-256color kernel.serial=legacy kernel.entropy-mixin=660486b6b20b4ace3fb5c81b0002abf5271289185c6a5620707606c55b377562 kernel.halt-on-panic=true\'', + "'TERM=xterm-256color kernel.serial=legacy kernel.entropy-mixin=660486b6b20b4ace3fb5c81b0002abf5271289185c6a5620707606c55b377562 kernel.halt-on-panic=true'", ]; await cli.start(aemuCommand); diff --git a/packages/fuchsia_ctl/lib/src/image_paver.dart b/packages/fuchsia_ctl/lib/src/image_paver.dart index 02cded0d93..7129b48e0e 100644 --- a/packages/fuchsia_ctl/lib/src/image_paver.dart +++ b/packages/fuchsia_ctl/lib/src/image_paver.dart @@ -26,7 +26,7 @@ class ImagePaver { const ImagePaver({ this.processManager = const LocalProcessManager(), this.fs = const LocalFileSystem(), - this.tar = const SystemTar(processManager: LocalProcessManager()), + this.tar = const SystemTar(), this.sshKeyManagerProvider = SystemSshKeyManager.defaultProvider, }) : assert(processManager != null), assert(fs != null), diff --git a/packages/fuchsia_ctl/lib/src/operation_result.dart b/packages/fuchsia_ctl/lib/src/operation_result.dart index 637e3a6e76..0bf49dccbb 100644 --- a/packages/fuchsia_ctl/lib/src/operation_result.dart +++ b/packages/fuchsia_ctl/lib/src/operation_result.dart @@ -24,7 +24,7 @@ class OperationResult { String info = '', }) { assert(info != null); - return OperationResult._(true, info: info, error: ''); + return OperationResult._(true, info: info); } /// A failing operation result with a non-null but potentially empty error, diff --git a/packages/fuchsia_ctl/lib/src/package_server.dart b/packages/fuchsia_ctl/lib/src/package_server.dart index 96f8d4f440..6476ef619a 100644 --- a/packages/fuchsia_ctl/lib/src/package_server.dart +++ b/packages/fuchsia_ctl/lib/src/package_server.dart @@ -8,11 +8,12 @@ import 'dart:io'; import 'package:file/file.dart'; import 'package:file/local.dart'; -import 'package:fuchsia_ctl/fuchsia_ctl.dart'; import 'package:path/path.dart' as path; import 'package:process/process.dart'; import 'package:uuid/uuid.dart'; +import '../fuchsia_ctl.dart'; + /// A wrapper around the Fuchsia SDK `pm` tool. class PackageServer { /// Creates a new package server. diff --git a/packages/fuchsia_ctl/lib/src/ssh_client.dart b/packages/fuchsia_ctl/lib/src/ssh_client.dart index 33b87e2b18..12e188190e 100644 --- a/packages/fuchsia_ctl/lib/src/ssh_client.dart +++ b/packages/fuchsia_ctl/lib/src/ssh_client.dart @@ -8,10 +8,10 @@ import 'dart:io'; import 'package:file/file.dart'; import 'package:file/local.dart'; -import 'package:fuchsia_ctl/src/logger.dart'; import 'package:meta/meta.dart'; import 'package:process/process.dart'; +import 'logger.dart'; import 'operation_result.dart'; /// A client for running SSH based commands on a Fuchsia device. diff --git a/packages/fuchsia_ctl/pubspec.yaml b/packages/fuchsia_ctl/pubspec.yaml index 16e1a34d44..1cacbc34c1 100644 --- a/packages/fuchsia_ctl/pubspec.yaml +++ b/packages/fuchsia_ctl/pubspec.yaml @@ -6,7 +6,7 @@ description: > publish_to: none repository: https://github.com/flutter/packages/tree/main/packages/fuchsia_ctl issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+fuchsia_ctl%22 -version: 0.0.25 +version: 0.0.25+1 environment: sdk: ">=2.4.0 <3.0.0" diff --git a/packages/fuchsia_ctl/test/emulator_test.dart b/packages/fuchsia_ctl/test/emulator_test.dart index 8af8a00451..dc5c3e9645 100644 --- a/packages/fuchsia_ctl/test/emulator_test.dart +++ b/packages/fuchsia_ctl/test/emulator_test.dart @@ -23,7 +23,7 @@ void main() { group('Emulator', () { setUp(() { mockCli = MockCommandLine(); - fs = MemoryFileSystem(style: FileSystemStyle.posix); + fs = MemoryFileSystem(); fs.file(aemuPath).createSync(); fs.file(fuchsiaImagePath) ..createSync() diff --git a/packages/fuchsia_ctl/test/image_paver_test.dart b/packages/fuchsia_ctl/test/image_paver_test.dart index d57e237fc2..d4a6360b8b 100644 --- a/packages/fuchsia_ctl/test/image_paver_test.dart +++ b/packages/fuchsia_ctl/test/image_paver_test.dart @@ -17,7 +17,7 @@ import 'fakes.dart'; void main() { const String deviceName = 'some-name-to-use'; FakeSshKeyManager sshKeyManager; - final MemoryFileSystem fs = MemoryFileSystem(style: FileSystemStyle.posix); + final MemoryFileSystem fs = MemoryFileSystem(); FakeTar tar; MockProcessManager processManager; SshKeyManagerProvider sshKeyManagerProvider; diff --git a/packages/fuchsia_ctl/test/logger_test.dart b/packages/fuchsia_ctl/test/logger_test.dart index 6223276cac..bffaacf543 100644 --- a/packages/fuchsia_ctl/test/logger_test.dart +++ b/packages/fuchsia_ctl/test/logger_test.dart @@ -43,7 +43,7 @@ void main() { final MemoryFileSystem fs = MemoryFileSystem(); fs.file('log.txt').createSync(); final IOSink data = fs.file('log.txt').openWrite(); - final PrintLogger logger = PrintLogger(out: data, level: LogLevel.info); + final PrintLogger logger = PrintLogger(out: data); logger.debug('abc'); logger.info('cdf'); logger.warning('gh'); diff --git a/packages/fuchsia_ctl/test/package_server_test.dart b/packages/fuchsia_ctl/test/package_server_test.dart index 7413292264..5b111d92ff 100644 --- a/packages/fuchsia_ctl/test/package_server_test.dart +++ b/packages/fuchsia_ctl/test/package_server_test.dart @@ -109,7 +109,6 @@ void main() { await server.serveRepo( repoPath, - port: 0, portFilePath: portFile.path, ); expect(server.serving, true); diff --git a/packages/go_router/CHANGELOG.md b/packages/go_router/CHANGELOG.md index be1fbcade4..b97be1bbea 100644 --- a/packages/go_router/CHANGELOG.md +++ b/packages/go_router/CHANGELOG.md @@ -1,6 +1,7 @@ -## NEXT +## 4.2.9 * Updates text theme parameters to avoid deprecation issues. +* Fixes lint warnings. ## 4.2.8 diff --git a/packages/go_router/example/lib/books/src/screens/books.dart b/packages/go_router/example/lib/books/src/screens/books.dart index 76f77b431b..ea86848851 100644 --- a/packages/go_router/example/lib/books/src/screens/books.dart +++ b/packages/go_router/example/lib/books/src/screens/books.dart @@ -17,7 +17,7 @@ class BooksScreen extends StatefulWidget { final String kind; @override - _BooksScreenState createState() => _BooksScreenState(); + State createState() => _BooksScreenState(); } class _BooksScreenState extends State diff --git a/packages/go_router/example/lib/books/src/screens/settings.dart b/packages/go_router/example/lib/books/src/screens/settings.dart index a376ce2ee4..71bd0f8513 100644 --- a/packages/go_router/example/lib/books/src/screens/settings.dart +++ b/packages/go_router/example/lib/books/src/screens/settings.dart @@ -14,7 +14,7 @@ class SettingsScreen extends StatefulWidget { const SettingsScreen({Key? key}) : super(key: key); @override - _SettingsScreenState createState() => _SettingsScreenState(); + State createState() => _SettingsScreenState(); } class _SettingsScreenState extends State { diff --git a/packages/go_router/example/lib/books/src/screens/sign_in.dart b/packages/go_router/example/lib/books/src/screens/sign_in.dart index 1f833bf312..533322bd55 100644 --- a/packages/go_router/example/lib/books/src/screens/sign_in.dart +++ b/packages/go_router/example/lib/books/src/screens/sign_in.dart @@ -28,7 +28,7 @@ class SignInScreen extends StatefulWidget { final ValueChanged onSignIn; @override - _SignInScreenState createState() => _SignInScreenState(); + State createState() => _SignInScreenState(); } class _SignInScreenState extends State { diff --git a/packages/go_router/example/lib/named_routes.dart b/packages/go_router/example/lib/named_routes.dart index a8f9ce3f74..adb21e71c9 100644 --- a/packages/go_router/example/lib/named_routes.dart +++ b/packages/go_router/example/lib/named_routes.dart @@ -2,6 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// TODO(goderbauer): Refactor the examples to remove this ignore, https://github.com/flutter/flutter/issues/110210 +// ignore_for_file: avoid_dynamic_calls + import 'dart:convert'; import 'package:flutter/material.dart'; diff --git a/packages/go_router/example/lib/others/extra_param.dart b/packages/go_router/example/lib/others/extra_param.dart index 7917bbb6ef..3b6ca0ea4e 100644 --- a/packages/go_router/example/lib/others/extra_param.dart +++ b/packages/go_router/example/lib/others/extra_param.dart @@ -2,6 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// TODO(goderbauer): Refactor the examples to remove this ignore, https://github.com/flutter/flutter/issues/110210 +// ignore_for_file: avoid_dynamic_calls + import 'dart:convert'; import 'package:flutter/material.dart'; diff --git a/packages/go_router/example/lib/path_and_query_parameters.dart b/packages/go_router/example/lib/path_and_query_parameters.dart index 38af018735..fe9b8baa83 100755 --- a/packages/go_router/example/lib/path_and_query_parameters.dart +++ b/packages/go_router/example/lib/path_and_query_parameters.dart @@ -2,6 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// TODO(goderbauer): Refactor the examples to remove this ignore, https://github.com/flutter/flutter/issues/110210 +// ignore_for_file: avoid_dynamic_calls + import 'dart:convert'; import 'package:flutter/material.dart'; diff --git a/packages/go_router/lib/go_router.dart b/packages/go_router/lib/go_router.dart index efb52fd550..431bf3dcb7 100644 --- a/packages/go_router/lib/go_router.dart +++ b/packages/go_router/lib/go_router.dart @@ -6,7 +6,7 @@ /// deep linking, data-driven routes and more. library go_router; -export 'src/configuration.dart' show GoRouterState, GoRoute; +export 'src/configuration.dart' show GoRoute, GoRouterState; export 'src/misc/extensions.dart'; export 'src/misc/inherited_router.dart'; export 'src/misc/refresh_stream.dart'; diff --git a/packages/go_router/lib/src/information_provider.dart b/packages/go_router/lib/src/information_provider.dart index 0afeee561a..3011d133df 100644 --- a/packages/go_router/lib/src/information_provider.dart +++ b/packages/go_router/lib/src/information_provider.dart @@ -115,6 +115,5 @@ class GoRouteInformationProvider extends RouteInformationProvider /// in use with the [GoRouteInformationParser]. class DebugGoRouteInformation extends RouteInformation { /// Creates a [DebugGoRouteInformation]. - DebugGoRouteInformation({String? location, Object? state}) - : super(location: location, state: state); + DebugGoRouteInformation({super.location, super.state}); } diff --git a/packages/go_router/lib/src/matching.dart b/packages/go_router/lib/src/matching.dart index 755aed6707..6135cff1c1 100644 --- a/packages/go_router/lib/src/matching.dart +++ b/packages/go_router/lib/src/matching.dart @@ -100,8 +100,7 @@ class RouteMatchList { /// An error that occurred during matching. class MatcherError extends Error { /// Constructs a [MatcherError]. - MatcherError(String message, this.location) - : message = message + ': $location'; + MatcherError(String message, this.location) : message = '$message: $location'; /// The error message. final String message; diff --git a/packages/go_router/lib/src/misc/error_screen.dart b/packages/go_router/lib/src/misc/error_screen.dart index 4572b977de..1d0884ca5f 100644 --- a/packages/go_router/lib/src/misc/error_screen.dart +++ b/packages/go_router/lib/src/misc/error_screen.dart @@ -9,7 +9,7 @@ import 'extensions.dart'; /// Default error page implementation for WidgetsApp. class ErrorScreen extends StatelessWidget { /// Provide an exception to this page for it to be displayed. - const ErrorScreen(this.error, {Key? key}) : super(key: key); + const ErrorScreen(this.error, {super.key}); /// The exception to be displayed. final Exception? error; @@ -46,8 +46,7 @@ class _Button extends StatefulWidget { const _Button({ required this.onPressed, required this.child, - Key? key, - }) : super(key: key); + }); final VoidCallback onPressed; diff --git a/packages/go_router/lib/src/misc/inherited_router.dart b/packages/go_router/lib/src/misc/inherited_router.dart index 3aec90220c..abc5a9de89 100644 --- a/packages/go_router/lib/src/misc/inherited_router.dart +++ b/packages/go_router/lib/src/misc/inherited_router.dart @@ -14,10 +14,10 @@ import '../router.dart'; class InheritedGoRouter extends InheritedWidget { /// Default constructor for the inherited go router. const InheritedGoRouter({ - required Widget child, + required super.child, required this.goRouter, - Key? key, - }) : super(child: child, key: key); + super.key, + }); /// The [GoRouter] that is made available to the widget tree. final GoRouter goRouter; diff --git a/packages/go_router/lib/src/pages/cupertino.dart b/packages/go_router/lib/src/pages/cupertino.dart index 6c9d1a97ab..2532b549d6 100644 --- a/packages/go_router/lib/src/pages/cupertino.dart +++ b/packages/go_router/lib/src/pages/cupertino.dart @@ -30,7 +30,7 @@ CupertinoPage pageBuilderForCupertinoApp({ /// Default error page implementation for Cupertino. class CupertinoErrorScreen extends StatelessWidget { /// Provide an exception to this page for it to be displayed. - const CupertinoErrorScreen(this.error, {Key? key}) : super(key: key); + const CupertinoErrorScreen(this.error, {super.key}); /// The exception to be displayed. final Exception? error; diff --git a/packages/go_router/lib/src/pages/custom_transition_page.dart b/packages/go_router/lib/src/pages/custom_transition_page.dart index ab0c8e54fa..431df30ad4 100644 --- a/packages/go_router/lib/src/pages/custom_transition_page.dart +++ b/packages/go_router/lib/src/pages/custom_transition_page.dart @@ -23,16 +23,11 @@ class CustomTransitionPage extends Page { this.barrierDismissible = false, this.barrierColor, this.barrierLabel, - LocalKey? key, - String? name, - Object? arguments, - String? restorationId, - }) : super( - key: key, - name: name, - arguments: arguments, - restorationId: restorationId, - ); + super.key, + super.name, + super.arguments, + super.restorationId, + }); /// The content to be shown in the Route created by this page. final Widget child; @@ -160,19 +155,14 @@ class _CustomTransitionPageRoute extends PageRoute { class NoTransitionPage extends CustomTransitionPage { /// Constructor for a page with no transition functionality. const NoTransitionPage({ - required Widget child, - String? name, - Object? arguments, - String? restorationId, - LocalKey? key, + required super.child, + super.name, + super.arguments, + super.restorationId, + super.key, }) : super( transitionsBuilder: _transitionsBuilder, - transitionDuration: const Duration(microseconds: 1), // hack for #205 - key: key, - name: name, - arguments: arguments, - restorationId: restorationId, - child: child, + transitionDuration: const Duration(microseconds: 1), ); static Widget _transitionsBuilder( diff --git a/packages/go_router/lib/src/pages/material.dart b/packages/go_router/lib/src/pages/material.dart index 3eb656b4a3..ae56763969 100644 --- a/packages/go_router/lib/src/pages/material.dart +++ b/packages/go_router/lib/src/pages/material.dart @@ -31,7 +31,7 @@ MaterialPage pageBuilderForMaterialApp({ /// Default error page implementation for Material. class MaterialErrorScreen extends StatelessWidget { /// Provide an exception to this page for it to be displayed. - const MaterialErrorScreen(this.error, {Key? key}) : super(key: key); + const MaterialErrorScreen(this.error, {super.key}); /// The exception to be displayed. final Exception? error; diff --git a/packages/go_router/lib/src/path_utils.dart b/packages/go_router/lib/src/path_utils.dart index b10a6cc107..804e0ee2da 100644 --- a/packages/go_router/lib/src/path_utils.dart +++ b/packages/go_router/lib/src/path_utils.dart @@ -66,7 +66,7 @@ String _escapeGroup(String group, String name) { /// 2. Call [patternToPath] with the `pathParameters` from the first step and /// the original `pattern` used for generating the [RegExp]. String patternToPath(String pattern, Map pathParameters) { - final StringBuffer buffer = StringBuffer(''); + final StringBuffer buffer = StringBuffer(); int start = 0; for (final RegExpMatch match in _parameterRegExp.allMatches(pattern)) { if (match.start > start) { diff --git a/packages/go_router/lib/src/redirection.dart b/packages/go_router/lib/src/redirection.dart index 400ef8b7d5..0abeb52b8e 100644 --- a/packages/go_router/lib/src/redirection.dart +++ b/packages/go_router/lib/src/redirection.dart @@ -111,13 +111,10 @@ class RedirectionError extends Error implements UnsupportedError { final Uri location; @override - String toString() => - super.toString() + - ' ' + - [ + String toString() => '${super.toString()} ${[ ...matches.map( (RouteMatchList routeMatches) => routeMatches.location.toString()), - ].join(' => '); + ].join(' => ')}'; } /// Adds the redirect to [redirects] if it is valid. diff --git a/packages/go_router/lib/src/route_data.dart b/packages/go_router/lib/src/route_data.dart index 0f9f7b50f9..ec150858a0 100644 --- a/packages/go_router/lib/src/route_data.dart +++ b/packages/go_router/lib/src/route_data.dart @@ -55,7 +55,7 @@ abstract class GoRouteData { .replace( queryParameters: // Avoid `?` in generated location if `queryParams` is empty - queryParams?.isNotEmpty == true ? queryParams : null, + queryParams?.isNotEmpty ?? false ? queryParams : null, ) .toString(); diff --git a/packages/go_router/pubspec.yaml b/packages/go_router/pubspec.yaml index 44cda90e94..2a54b88c3e 100644 --- a/packages/go_router/pubspec.yaml +++ b/packages/go_router/pubspec.yaml @@ -1,7 +1,7 @@ name: go_router description: A declarative router for Flutter based on Navigation 2 supporting deep linking, data-driven routes and more -version: 4.2.8 +version: 4.2.9 repository: https://github.com/flutter/packages/tree/main/packages/go_router issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+go_router%22 diff --git a/packages/go_router/test/cupertino_test.dart b/packages/go_router/test/cupertino_test.dart index 4413d6a3dd..323aea3e02 100644 --- a/packages/go_router/test/cupertino_test.dart +++ b/packages/go_router/test/cupertino_test.dart @@ -93,7 +93,7 @@ void main() { } class DummyStatefulWidget extends StatefulWidget { - const DummyStatefulWidget({Key? key}) : super(key: key); + const DummyStatefulWidget({super.key}); @override State createState() => _DummyStatefulWidgetState(); diff --git a/packages/go_router/test/custom_transition_page_test.dart b/packages/go_router/test/custom_transition_page_test.dart index 28c622ae5d..5845be6dd0 100644 --- a/packages/go_router/test/custom_transition_page_test.dart +++ b/packages/go_router/test/custom_transition_page_test.dart @@ -89,7 +89,7 @@ void main() { } class HomeScreen extends StatelessWidget { - const HomeScreen({Key? key}) : super(key: key); + const HomeScreen({super.key}); @override Widget build(BuildContext context) { @@ -102,7 +102,7 @@ class HomeScreen extends StatelessWidget { } class LoginScreen extends StatelessWidget { - const LoginScreen({Key? key}) : super(key: key); + const LoginScreen({super.key}); @override Widget build(BuildContext context) { diff --git a/packages/go_router/test/delegate_test.dart b/packages/go_router/test/delegate_test.dart index b4a417368e..75025a9825 100644 --- a/packages/go_router/test/delegate_test.dart +++ b/packages/go_router/test/delegate_test.dart @@ -241,7 +241,7 @@ class FakeRefreshListenable extends ChangeNotifier { } class DummyStatefulWidget extends StatefulWidget { - const DummyStatefulWidget({Key? key}) : super(key: key); + const DummyStatefulWidget({super.key}); @override State createState() => _DummyStatefulWidgetState(); diff --git a/packages/go_router/test/error_page_test.dart b/packages/go_router/test/error_page_test.dart index 5028dcc7af..071cc962e7 100644 --- a/packages/go_router/test/error_page_test.dart +++ b/packages/go_router/test/error_page_test.dart @@ -53,7 +53,7 @@ Widget widgetsAppBuilder({required Widget home}) { } class DummyStatefulWidget extends StatefulWidget { - const DummyStatefulWidget({Key? key}) : super(key: key); + const DummyStatefulWidget({super.key}); @override State createState() => _DummyStatefulWidgetState(); diff --git a/packages/go_router/test/go_router_test.dart b/packages/go_router/test/go_router_test.dart index 5758a580aa..e1b4000f46 100644 --- a/packages/go_router/test/go_router_test.dart +++ b/packages/go_router/test/go_router_test.dart @@ -19,8 +19,9 @@ const bool enableLogs = true; final Logger log = Logger('GoRouter tests'); void main() { - if (enableLogs) + if (enableLogs) { Logger.root.onRecord.listen((LogRecord e) => debugPrint('$e')); + } group('path routes', () { testWidgets('match home route', (WidgetTester tester) async { @@ -178,7 +179,6 @@ void main() { final GoRouter router = await createRouter(routes, tester); router.go('/login/'); final List matches = router.routerDelegate.matches.matches; - print(matches); expect(matches, hasLength(1)); expect(matches.first.subloc, '/login'); expect(router.screenFor(matches.first).runtimeType, LoginScreen); @@ -1290,7 +1290,6 @@ void main() { final GoRouter router = await createRouter( routes, tester, - initialLocation: '/', ); expect(router.routeInformationProvider.value.location, '/dummy'); TestWidgetsFlutterBinding diff --git a/packages/go_router/test/inherited_test.dart b/packages/go_router/test/inherited_test.dart index 216b93cfe3..2592eedad8 100644 --- a/packages/go_router/test/inherited_test.dart +++ b/packages/go_router/test/inherited_test.dart @@ -71,7 +71,7 @@ void main() { expect(properties.properties.first.value, goRouter); }); - testWidgets('mediates Widget\'s access to GoRouter.', + testWidgets("mediates Widget's access to GoRouter.", (WidgetTester tester) async { final MockGoRouter router = MockGoRouter(); await tester.pumpWidget(MaterialApp( @@ -99,21 +99,21 @@ bool setupInheritedGoRouterChange({ } class Page1 extends StatelessWidget { - const Page1({Key? key}) : super(key: key); + const Page1({super.key}); @override Widget build(BuildContext context) => Container(); } class Page2 extends StatelessWidget { - const Page2({Key? key}) : super(key: key); + const Page2({super.key}); @override Widget build(BuildContext context) => Container(); } class _MyWidget extends StatelessWidget { - const _MyWidget({Key? key}) : super(key: key); + const _MyWidget(); @override Widget build(BuildContext context) { diff --git a/packages/go_router/test/logging_test.dart b/packages/go_router/test/logging_test.dart index 585ccc0b62..527366015f 100644 --- a/packages/go_router/test/logging_test.dart +++ b/packages/go_router/test/logging_test.dart @@ -9,11 +9,10 @@ import 'package:logging/logging.dart'; void main() { // Reset the logger before each test. setUp(() { - setLogging(enabled: false); + setLogging(); }); test('setLogging enables log messages on the logger', () { - log.onRecord - .listen(expectAsync1((LogRecord r) {}, count: 1)); + log.onRecord.listen(expectAsync1((LogRecord r) {})); setLogging(enabled: true); log.info('message'); @@ -23,7 +22,7 @@ void main() { log.onRecord .listen(expectAsync1((LogRecord r) {}, count: 0)); - setLogging(enabled: false); + setLogging(); log.info('message'); }); } diff --git a/packages/go_router/test/material_test.dart b/packages/go_router/test/material_test.dart index 15e4ee0829..4da273ea7b 100644 --- a/packages/go_router/test/material_test.dart +++ b/packages/go_router/test/material_test.dart @@ -92,7 +92,7 @@ void main() { } class DummyStatefulWidget extends StatefulWidget { - const DummyStatefulWidget({Key? key}) : super(key: key); + const DummyStatefulWidget({super.key}); @override State createState() => _DummyStatefulWidgetState(); diff --git a/packages/go_router/test/parser_test.dart b/packages/go_router/test/parser_test.dart index 8d119b2dcb..b943f12fff 100644 --- a/packages/go_router/test/parser_test.dart +++ b/packages/go_router/test/parser_test.dart @@ -100,10 +100,7 @@ void main() { expect(configuration.namedLocation('SNAKE_CASE'), '/hij'); // With query parameters - expect( - configuration - .namedLocation('lowercase', queryParams: const {}), - '/abc'); + expect(configuration.namedLocation('lowercase'), '/abc'); expect( configuration.namedLocation('lowercase', queryParams: const {'q': '1'}), diff --git a/packages/go_router/test/path_utils_test.dart b/packages/go_router/test/path_utils_test.dart index 5c519e0294..1c883c4515 100644 --- a/packages/go_router/test/path_utils_test.dart +++ b/packages/go_router/test/path_utils_test.dart @@ -74,32 +74,32 @@ void main() { }); test('concatenatePaths', () { - void _verify(String pathA, String pathB, String expected) { + void verify(String pathA, String pathB, String expected) { final String result = concatenatePaths(pathA, pathB); expect(result, expected); } - void _verifyThrows(String pathA, String pathB) { + void verifyThrows(String pathA, String pathB) { expect( () => concatenatePaths(pathA, pathB), throwsA(isA())); } - _verify('/a', 'b/c', '/a/b/c'); - _verify('/', 'b', '/b'); - _verifyThrows('/a', '/b'); - _verifyThrows('/a', '/'); - _verifyThrows('/', '/'); - _verifyThrows('/', ''); - _verifyThrows('', ''); + verify('/a', 'b/c', '/a/b/c'); + verify('/', 'b', '/b'); + verifyThrows('/a', '/b'); + verifyThrows('/a', '/'); + verifyThrows('/', '/'); + verifyThrows('/', ''); + verifyThrows('', ''); }); test('canonicalUri', () { - void _verify(String path, String expected) => + void verify(String path, String expected) => expect(canonicalUri(path), expected); - _verify('/a', '/a'); - _verify('/a/', '/a'); - _verify('/', '/'); - _verify('/a/b/', '/a/b'); + verify('/a', '/a'); + verify('/a/', '/a'); + verify('/', '/'); + verify('/a/b/', '/a/b'); expect(() => canonicalUri('::::'), throwsA(isA())); expect(() => canonicalUri(''), throwsA(anything)); diff --git a/packages/go_router/test/test_helpers.dart b/packages/go_router/test/test_helpers.dart index 5361ceff76..f0592a676b 100644 --- a/packages/go_router/test/test_helpers.dart +++ b/packages/go_router/test/test_helpers.dart @@ -4,8 +4,6 @@ // ignore_for_file: cascade_invocations, diagnostic_describe_all_properties -import 'dart:async'; - import 'package:flutter/material.dart'; import 'package:flutter/src/foundation/diagnostics.dart'; import 'package:flutter_test/flutter_test.dart'; @@ -43,8 +41,7 @@ Widget fakeNavigationBuilder( child; class GoRouterNamedLocationSpy extends GoRouter { - GoRouterNamedLocationSpy({required List routes}) - : super(routes: routes); + GoRouterNamedLocationSpy({required super.routes}); String? name; Map? params; @@ -64,7 +61,7 @@ class GoRouterNamedLocationSpy extends GoRouter { } class GoRouterGoSpy extends GoRouter { - GoRouterGoSpy({required List routes}) : super(routes: routes); + GoRouterGoSpy({required super.routes}); String? myLocation; Object? extra; @@ -77,7 +74,7 @@ class GoRouterGoSpy extends GoRouter { } class GoRouterGoNamedSpy extends GoRouter { - GoRouterGoNamedSpy({required List routes}) : super(routes: routes); + GoRouterGoNamedSpy({required super.routes}); String? name; Map? params; @@ -99,7 +96,7 @@ class GoRouterGoNamedSpy extends GoRouter { } class GoRouterPushSpy extends GoRouter { - GoRouterPushSpy({required List routes}) : super(routes: routes); + GoRouterPushSpy({required super.routes}); String? myLocation; Object? extra; @@ -112,7 +109,7 @@ class GoRouterPushSpy extends GoRouter { } class GoRouterPushNamedSpy extends GoRouter { - GoRouterPushNamedSpy({required List routes}) : super(routes: routes); + GoRouterPushNamedSpy({required super.routes}); String? name; Map? params; @@ -134,7 +131,7 @@ class GoRouterPushNamedSpy extends GoRouter { } class GoRouterPopSpy extends GoRouter { - GoRouterPopSpy({required List routes}) : super(routes: routes); + GoRouterPopSpy({required super.routes}); bool popped = false; @@ -146,9 +143,8 @@ class GoRouterPopSpy extends GoRouter { class GoRouterRefreshStreamSpy extends GoRouterRefreshStream { GoRouterRefreshStreamSpy( - Stream stream, - ) : notifyCount = 0, - super(stream); + super.stream, + ) : notifyCount = 0; late int notifyCount; @@ -173,7 +169,6 @@ Future createRouter( redirectLimit: redirectLimit, errorBuilder: (BuildContext context, GoRouterState state) => TestErrorScreen(state.error!), - debugLogDiagnostics: false, ); await tester.pumpWidget( MaterialApp.router( @@ -186,44 +181,44 @@ Future createRouter( } class TestErrorScreen extends DummyScreen { - const TestErrorScreen(this.ex, {Key? key}) : super(key: key); + const TestErrorScreen(this.ex, {super.key}); final Exception ex; } class HomeScreen extends DummyScreen { - const HomeScreen({Key? key}) : super(key: key); + const HomeScreen({super.key}); } class Page1Screen extends DummyScreen { - const Page1Screen({Key? key}) : super(key: key); + const Page1Screen({super.key}); } class Page2Screen extends DummyScreen { - const Page2Screen({Key? key}) : super(key: key); + const Page2Screen({super.key}); } class LoginScreen extends DummyScreen { - const LoginScreen({Key? key}) : super(key: key); + const LoginScreen({super.key}); } class FamilyScreen extends DummyScreen { - const FamilyScreen(this.fid, {Key? key}) : super(key: key); + const FamilyScreen(this.fid, {super.key}); final String fid; } class FamiliesScreen extends DummyScreen { - const FamiliesScreen({required this.selectedFid, Key? key}) : super(key: key); + const FamiliesScreen({required this.selectedFid, super.key}); final String selectedFid; } class PersonScreen extends DummyScreen { - const PersonScreen(this.fid, this.pid, {Key? key}) : super(key: key); + const PersonScreen(this.fid, this.pid, {super.key}); final String fid; final String pid; } class DummyScreen extends StatelessWidget { - const DummyScreen({Key? key}) : super(key: key); + const DummyScreen({super.key}); @override Widget build(BuildContext context) => const Placeholder(); @@ -336,7 +331,7 @@ class DummyBuildContext implements BuildContext { } class DummyStatefulWidget extends StatefulWidget { - const DummyStatefulWidget({Key? key}) : super(key: key); + const DummyStatefulWidget({super.key}); @override State createState() => DummyStatefulWidgetState(); diff --git a/packages/go_router_builder/CHANGELOG.md b/packages/go_router_builder/CHANGELOG.md index fe290f83be..c8033e6b2c 100644 --- a/packages/go_router_builder/CHANGELOG.md +++ b/packages/go_router_builder/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.0.9 + +* Fixes lint warnings. + ## 1.0.8 * Updates `analyzer` to 4.4.0. diff --git a/packages/go_router_builder/lib/src/route_config.dart b/packages/go_router_builder/lib/src/route_config.dart index 47e1b52411..49ebc5d22a 100644 --- a/packages/go_router_builder/lib/src/route_config.dart +++ b/packages/go_router_builder/lib/src/route_config.dart @@ -219,7 +219,7 @@ GoRoute get $_routeGetterName => ${_routeDefinition()}; 'Token ($e) of type ${e.runtimeType} is not supported.', ); }); - return "'${pathItems.join('')}'"; + return "'${pathItems.join()}'"; } late final Set _pathParams = Set.unmodifiable(_parsedPath @@ -249,7 +249,7 @@ GoRoute get $_routeGetterName => ${_routeDefinition()}; final String routesBit = _children.isEmpty ? '' : ''' -routes: [${_children.map((RouteConfig e) => '${e._routeDefinition()},').join('')}], +routes: [${_children.map((RouteConfig e) => '${e._routeDefinition()},').join()}], '''; return ''' diff --git a/packages/go_router_builder/pubspec.yaml b/packages/go_router_builder/pubspec.yaml index 420e0a971a..a466ea1f1f 100644 --- a/packages/go_router_builder/pubspec.yaml +++ b/packages/go_router_builder/pubspec.yaml @@ -2,7 +2,7 @@ name: go_router_builder description: >- A builder that supports generated strongly-typed route helpers for package:go_router -version: 1.0.8 +version: 1.0.9 repository: https://github.com/flutter/packages/tree/main/packages/go_router_builder issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+go_router_builder%22 diff --git a/packages/imitation_game/CHANGELOG.md b/packages/imitation_game/CHANGELOG.md index 9a0072ccd8..5487796f33 100644 --- a/packages/imitation_game/CHANGELOG.md +++ b/packages/imitation_game/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.0.2+1 + +* Fixes lint warnings. + ## 0.0.2 * Migrate to null safety. diff --git a/packages/imitation_game/bin/imitation_game.dart b/packages/imitation_game/bin/imitation_game.dart index 175a20d2c6..26d535b933 100644 --- a/packages/imitation_game/bin/imitation_game.dart +++ b/packages/imitation_game/bin/imitation_game.dart @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// ignore_for_file: avoid_print, avoid_dynamic_calls + import 'dart:async'; import 'dart:convert'; import 'dart:io'; diff --git a/packages/imitation_game/imitation_tests/smiley/flutter/smiley/lib/main.dart b/packages/imitation_game/imitation_tests/smiley/flutter/smiley/lib/main.dart index 5de3137a33..627dd5a66e 100644 --- a/packages/imitation_game/imitation_tests/smiley/flutter/smiley/lib/main.dart +++ b/packages/imitation_game/imitation_tests/smiley/flutter/smiley/lib/main.dart @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// ignore_for_file: avoid_print + import 'dart:convert' show jsonEncode; import 'dart:io'; @@ -73,7 +75,7 @@ class MyHomePage extends StatefulWidget { const MyHomePage({Key key}) : super(key: key); @override - _MyHomePageState createState() => _MyHomePageState(); + State createState() => _MyHomePageState(); } class _MyHomePageState extends State { @@ -83,7 +85,7 @@ class _MyHomePageState extends State { @override void initState() { _image - .resolve(const ImageConfiguration()) + .resolve(ImageConfiguration.empty) .addListener(ImageStreamListener((_, __) { if (mounted) { setState(() { @@ -91,8 +93,8 @@ class _MyHomePageState extends State { // This should get called when the image has actually been drawn to the screen. WidgetsBinding.instance.addPostFrameCallback((_) async { final DateTime renderTime = DateTime.now(); - final PollIosStats _poller = PollIosStats(); - final StartupTime startupTime = await _poller.pollStartupTime(); + final PollIosStats poller = PollIosStats(); + final StartupTime startupTime = await poller.pollStartupTime(); final Duration diff = renderTime.difference( DateTime.fromMicrosecondsSinceEpoch(startupTime.startupTime)); _sendResult(diff.inMicroseconds / 1000000.0); diff --git a/packages/imitation_game/pubspec.yaml b/packages/imitation_game/pubspec.yaml index 38ae95c3f7..3b10ce687b 100644 --- a/packages/imitation_game/pubspec.yaml +++ b/packages/imitation_game/pubspec.yaml @@ -2,7 +2,7 @@ name: imitation_game description: Testing framework for comparing multiple frameworks' performance. repository: https://github.com/flutter/packages/tree/main/packages/imitation_game issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+imitation_game%22 -version: 0.0.2 +version: 0.0.2+1 environment: sdk: '>=2.12.0 <3.0.0' diff --git a/packages/metrics_center/CHANGELOG.md b/packages/metrics_center/CHANGELOG.md index ec99e057db..6628b71347 100644 --- a/packages/metrics_center/CHANGELOG.md +++ b/packages/metrics_center/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.0.6 + +- Fixes lint warnings. + ## 1.0.5 - Fix JSON parsing issue when running in sound null-safety mode. diff --git a/packages/metrics_center/lib/src/gcs_lock.dart b/packages/metrics_center/lib/src/gcs_lock.dart index ca64f648c3..5e6b2dfdca 100644 --- a/packages/metrics_center/lib/src/gcs_lock.dart +++ b/packages/metrics_center/lib/src/gcs_lock.dart @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// ignore_for_file: avoid_print + import 'package:googleapis/storage/v1.dart'; import 'package:googleapis_auth/googleapis_auth.dart'; diff --git a/packages/metrics_center/lib/src/google_benchmark.dart b/packages/metrics_center/lib/src/google_benchmark.dart index feb1f36228..90ddef750c 100644 --- a/packages/metrics_center/lib/src/google_benchmark.dart +++ b/packages/metrics_center/lib/src/google_benchmark.dart @@ -74,8 +74,9 @@ void _parseAnItem( try { rawValue = item[subResult] as num?; } catch (e) { + // ignore: avoid_print print( - '$subResult: ${item[subResult]} (${item[subResult].runtimeType}) is not a number'); + '$subResult: ${item[subResult]} (${(item[subResult] as Object?).runtimeType}) is not a number'); rethrow; } diff --git a/packages/metrics_center/lib/src/skiaperf.dart b/packages/metrics_center/lib/src/skiaperf.dart index 01f5ed93be..1e30e63558 100644 --- a/packages/metrics_center/lib/src/skiaperf.dart +++ b/packages/metrics_center/lib/src/skiaperf.dart @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// ignore_for_file: avoid_dynamic_calls + import 'dart:convert'; import 'package:gcloud/storage.dart'; @@ -82,8 +84,9 @@ class SkiaPerfPoint extends MetricPoint { final String? name = p.tags[kNameKey]; if (githubRepo == null || gitHash == null || name == null) { - throw '$kGithubRepoKey, $kGitRevisionKey, $kNameKey must be set in' - ' the tags of $p.'; + throw StateError( + '$kGithubRepoKey, $kGitRevisionKey, $kNameKey must be set in' + ' the tags of $p.'); } final String subResult = p.tags[kSubResultKey] ?? kSkiaPerfValueKey; @@ -382,7 +385,7 @@ class SkiaPerfDestination extends MetricDestination { final Storage storage = Storage(client, projectId); final String bucketName = isTesting ? kTestBucketName : kBucketName; if (!await storage.bucketExists(bucketName)) { - throw 'Bucket $bucketName does not exist.'; + throw StateError('Bucket $bucketName does not exist.'); } final SkiaPerfGcsAdaptor adaptor = SkiaPerfGcsAdaptor(storage.bucket(bucketName)); diff --git a/packages/metrics_center/pubspec.yaml b/packages/metrics_center/pubspec.yaml index 617eaddd99..874d8373c4 100644 --- a/packages/metrics_center/pubspec.yaml +++ b/packages/metrics_center/pubspec.yaml @@ -1,5 +1,5 @@ name: metrics_center -version: 1.0.5 +version: 1.0.6 description: Support multiple performance metrics sources/formats and destinations. repository: https://github.com/flutter/packages/tree/main/packages/metrics_center diff --git a/packages/metrics_center/test/common.dart b/packages/metrics_center/test/common.dart index 07f2f6fb0d..bab9663770 100644 --- a/packages/metrics_center/test/common.dart +++ b/packages/metrics_center/test/common.dart @@ -22,6 +22,8 @@ void tryToDelete(Directory directory) { try { directory.deleteSync(recursive: true); } on FileSystemException catch (error) { + // TODO(goderbauer): We should not be printing from a test util function. + // ignore: avoid_print print('Failed to delete ${directory.path}: $error'); } } diff --git a/packages/metrics_center/test/gcs_lock_test.dart b/packages/metrics_center/test/gcs_lock_test.dart index b5228bf8f0..bc84ac1d84 100644 --- a/packages/metrics_center/test/gcs_lock_test.dart +++ b/packages/metrics_center/test/gcs_lock_test.dart @@ -45,6 +45,8 @@ void main() { runFinished.catchError((dynamic e) { final AssertionError error = e as AssertionError; expect(error.message, 'Stop!'); + // TODO(goderbauer): We should not be printing from a test. + // ignore: avoid_print print('${error.message}'); }); fakeAsync.elapse(const Duration(seconds: 20)); diff --git a/packages/multicast_dns/CHANGELOG.md b/packages/multicast_dns/CHANGELOG.md index a20e590491..76837a4eb7 100644 --- a/packages/multicast_dns/CHANGELOG.md +++ b/packages/multicast_dns/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.3.2+2 + +* Fixes lints warnings. + ## 0.3.2+1 * Migrates from `ui.hash*` to `Object.hash*`. diff --git a/packages/multicast_dns/example/main.dart b/packages/multicast_dns/example/main.dart index 588bcb22be..2fdb57a6ec 100644 --- a/packages/multicast_dns/example/main.dart +++ b/packages/multicast_dns/example/main.dart @@ -5,6 +5,8 @@ // Example script to illustrate how to use the mdns package to discover the port // of a Dart observatory over mDNS. +// ignore_for_file: avoid_print + import 'package:multicast_dns/multicast_dns.dart'; Future main() async { diff --git a/packages/multicast_dns/example/mdns_resolve.dart b/packages/multicast_dns/example/mdns_resolve.dart index a7c35a88fd..5246997c17 100644 --- a/packages/multicast_dns/example/mdns_resolve.dart +++ b/packages/multicast_dns/example/mdns_resolve.dart @@ -5,6 +5,8 @@ // Example script to illustrate how to use the mdns package to lookup names // on the local network. +// ignore_for_file: avoid_print + import 'package:multicast_dns/multicast_dns.dart'; Future main(List args) async { diff --git a/packages/multicast_dns/example/mdns_sd.dart b/packages/multicast_dns/example/mdns_sd.dart index 5b5fb6ea36..50b46ebf91 100644 --- a/packages/multicast_dns/example/mdns_sd.dart +++ b/packages/multicast_dns/example/mdns_sd.dart @@ -5,6 +5,8 @@ // Example script to illustrate how to use the mdns package to discover services // on the local network. +// ignore_for_file: avoid_print + import 'package:multicast_dns/multicast_dns.dart'; Future main(List args) async { diff --git a/packages/multicast_dns/lib/multicast_dns.dart b/packages/multicast_dns/lib/multicast_dns.dart index 5aeeab420a..336ac42793 100644 --- a/packages/multicast_dns/lib/multicast_dns.dart +++ b/packages/multicast_dns/lib/multicast_dns.dart @@ -5,11 +5,11 @@ import 'dart:async'; import 'dart:io'; -import 'package:multicast_dns/src/constants.dart'; -import 'package:multicast_dns/src/lookup_resolver.dart'; -import 'package:multicast_dns/src/native_protocol_client.dart'; -import 'package:multicast_dns/src/packet.dart'; -import 'package:multicast_dns/src/resource_record.dart'; +import 'src/constants.dart'; +import 'src/lookup_resolver.dart'; +import 'src/native_protocol_client.dart'; +import 'src/packet.dart'; +import 'src/resource_record.dart'; export 'package:multicast_dns/src/resource_record.dart'; diff --git a/packages/multicast_dns/lib/src/lookup_resolver.dart b/packages/multicast_dns/lib/src/lookup_resolver.dart index 6f2eea75c4..addae7d334 100644 --- a/packages/multicast_dns/lib/src/lookup_resolver.dart +++ b/packages/multicast_dns/lib/src/lookup_resolver.dart @@ -5,7 +5,7 @@ import 'dart:async'; import 'dart:collection'; -import 'package:multicast_dns/src/resource_record.dart'; +import 'resource_record.dart'; /// Class for maintaining state about pending mDNS requests. class PendingRequest extends LinkedListEntry { diff --git a/packages/multicast_dns/lib/src/native_protocol_client.dart b/packages/multicast_dns/lib/src/native_protocol_client.dart index aa2eb5c207..b754519066 100644 --- a/packages/multicast_dns/lib/src/native_protocol_client.dart +++ b/packages/multicast_dns/lib/src/native_protocol_client.dart @@ -4,7 +4,7 @@ import 'dart:collection'; -import 'package:multicast_dns/src/resource_record.dart'; +import 'resource_record.dart'; /// Cache for resource records that have been received. /// diff --git a/packages/multicast_dns/lib/src/packet.dart b/packages/multicast_dns/lib/src/packet.dart index 514cd141d9..dcf1402a04 100644 --- a/packages/multicast_dns/lib/src/packet.dart +++ b/packages/multicast_dns/lib/src/packet.dart @@ -6,8 +6,8 @@ import 'dart:convert'; import 'dart:io'; import 'dart:typed_data'; -import 'package:multicast_dns/src/constants.dart'; -import 'package:multicast_dns/src/resource_record.dart'; +import 'constants.dart'; +import 'resource_record.dart'; // Offsets into the header. See https://tools.ietf.org/html/rfc1035. const int _kIdOffset = 0; diff --git a/packages/multicast_dns/lib/src/resource_record.dart b/packages/multicast_dns/lib/src/resource_record.dart index 46e5731528..65320d5e9a 100644 --- a/packages/multicast_dns/lib/src/resource_record.dart +++ b/packages/multicast_dns/lib/src/resource_record.dart @@ -7,8 +7,8 @@ import 'dart:io'; import 'dart:typed_data'; import 'package:meta/meta.dart'; -import 'package:multicast_dns/src/constants.dart'; -import 'package:multicast_dns/src/packet.dart'; +import 'constants.dart'; +import 'packet.dart'; /// Enumeration of support resource record types. abstract class ResourceRecordType { diff --git a/packages/multicast_dns/pubspec.yaml b/packages/multicast_dns/pubspec.yaml index c43df34949..04ed3aa19e 100644 --- a/packages/multicast_dns/pubspec.yaml +++ b/packages/multicast_dns/pubspec.yaml @@ -2,7 +2,7 @@ name: multicast_dns description: Dart package for performing mDNS queries (e.g. Bonjour, Avahi). repository: https://github.com/flutter/packages/tree/main/packages/multicast_dns issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+multicast_dns%22 -version: 0.3.2+1 +version: 0.3.2+2 environment: sdk: ">=2.14.0 <3.0.0" diff --git a/packages/multicast_dns/test/decode_test.dart b/packages/multicast_dns/test/decode_test.dart index 442d59946b..32d7c2fd0c 100644 --- a/packages/multicast_dns/test/decode_test.dart +++ b/packages/multicast_dns/test/decode_test.dart @@ -178,7 +178,7 @@ void testValidPackages() { TxtResourceRecord( '______________________.____________.____._____', result[1].validUntil, - text: (')' * 129) + '\n', + text: '${')' * 129}\n', ), ]); }); diff --git a/packages/multicast_dns/tool/packet_gen.dart b/packages/multicast_dns/tool/packet_gen.dart index 4845b1600e..6e1e278b9c 100644 --- a/packages/multicast_dns/tool/packet_gen.dart +++ b/packages/multicast_dns/tool/packet_gen.dart @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// ignore_for_file: avoid_print + // Support code to generate the hex-lists in test/decode_test.dart from // a hex-stream. import 'dart:io'; @@ -51,7 +53,7 @@ void hexDumpList(List package) { } void dumpDatagram(Datagram datagram) { - String _toHex(List ints) { + String toHex(List ints) { final StringBuffer buffer = StringBuffer(); for (int i = 0; i < ints.length; i++) { buffer.write(ints[i].toRadixString(16).padLeft(2, '0')); @@ -65,6 +67,6 @@ void dumpDatagram(Datagram datagram) { } print('${datagram.address.address}:${datagram.port}:'); - print(_toHex(datagram.data)); + print(toHex(datagram.data)); print(''); } diff --git a/packages/palette_generator/CHANGELOG.md b/packages/palette_generator/CHANGELOG.md index 0e5193ccbe..9475317b1b 100644 --- a/packages/palette_generator/CHANGELOG.md +++ b/packages/palette_generator/CHANGELOG.md @@ -1,7 +1,8 @@ -## NEXT +## 0.3.3+2 * Ignores lint warnings from new changes in Flutter master. * Suppresses deprecation warnings for changes to Flutter master. +* Fixes lint warnings. ## 0.3.3+1 diff --git a/packages/palette_generator/example/lib/main.dart b/packages/palette_generator/example/lib/main.dart index 33bfbf4ad8..94fd962825 100644 --- a/packages/palette_generator/example/lib/main.dart +++ b/packages/palette_generator/example/lib/main.dart @@ -59,7 +59,7 @@ class ImageColors extends StatefulWidget { final Size? imageSize; @override - _ImageColorsState createState() { + State createState() { return _ImageColorsState(); } } @@ -149,9 +149,6 @@ class _ImageColorsState extends State { title: Text(widget.title ?? ''), ), body: Column( - mainAxisSize: MainAxisSize.max, - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.center, children: [ Padding( padding: const EdgeInsets.all(20.0), @@ -175,9 +172,7 @@ class _ImageColorsState extends State { decoration: BoxDecoration( color: _kSelectionRectangleBackground, border: Border.all( - width: 1.0, color: _kSelectionRectangleBorder, - style: BorderStyle.solid, )), )), ]), @@ -218,7 +213,6 @@ class PaletteSwatches extends StatelessWidget { return Column( mainAxisAlignment: MainAxisAlignment.center, mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.center, children: [ Wrap( children: swatches, @@ -280,13 +274,11 @@ class PaletteSwatch extends StatelessWidget { fallbackWidth: 34.0, fallbackHeight: 20.0, color: Color(0xff404040), - strokeWidth: 2.0, ) : Container( decoration: BoxDecoration( color: color, border: Border.all( - width: 1.0, color: _kPlaceholderColor, style: colorDistance < 0.2 ? BorderStyle.solid @@ -301,7 +293,6 @@ class PaletteSwatch extends StatelessWidget { swatch = ConstrainedBox( constraints: const BoxConstraints(maxWidth: 130.0, minWidth: 130.0), child: Row( - mainAxisAlignment: MainAxisAlignment.start, children: [ swatch, Container(width: 5.0), diff --git a/packages/palette_generator/lib/palette_generator.dart b/packages/palette_generator/lib/palette_generator.dart index 4f56e2013b..3619773846 100644 --- a/packages/palette_generator/lib/palette_generator.dart +++ b/packages/palette_generator/lib/palette_generator.dart @@ -15,7 +15,7 @@ import 'dart:ui' as ui; import 'dart:ui' show Color, ImageByteFormat; import 'package:collection/collection.dart' - show PriorityQueue, HeapPriorityQueue; + show HeapPriorityQueue, PriorityQueue; import 'package:flutter/foundation.dart'; import 'package:flutter/painting.dart'; @@ -192,10 +192,9 @@ class PaletteGenerator with Diagnosticable { ], List targets = const [], }) async { - final ByteData? imageData = - await image.toByteData(format: ui.ImageByteFormat.rawRgba); + final ByteData? imageData = await image.toByteData(); if (imageData == null) { - throw 'Failed to encode the image.'; + throw StateError('Failed to encode the image.'); } return PaletteGenerator.fromByteData( @@ -518,7 +517,6 @@ class PaletteTarget with Diagnosticable { static const double _targetLightLightness = 0.74; static const double _minNormalLightness = 0.3; - static const double _targetNormalLightness = 0.5; static const double _maxNormalLightness = 0.7; static const double _targetMutedSaturation = 0.3; @@ -548,7 +546,6 @@ class PaletteTarget with Diagnosticable { /// One of the base set of `targets` for [PaletteGenerator.fromImage], in [baseTargets]. static final PaletteTarget vibrant = PaletteTarget( minimumLightness: _minNormalLightness, - targetLightness: _targetNormalLightness, maximumLightness: _maxNormalLightness, minimumSaturation: _minVibrantSaturation, targetSaturation: _targetVibrantSaturation, @@ -582,7 +579,6 @@ class PaletteTarget with Diagnosticable { /// One of the base set of `targets` for [PaletteGenerator.fromImage], in [baseTargets]. static final PaletteTarget muted = PaletteTarget( minimumLightness: _minNormalLightness, - targetLightness: _targetNormalLightness, maximumLightness: _maxNormalLightness, targetSaturation: _targetMutedSaturation, maximumSaturation: _maxMutedSaturation, @@ -883,18 +879,18 @@ typedef PaletteFilter = bool Function(HSLColor color); /// See also: /// * [PaletteGenerator], a class for selecting color palettes from images. bool avoidRedBlackWhitePaletteFilter(HSLColor color) { - bool _isBlack(HSLColor hslColor) { - const double _blackMaxLightness = 0.05; - return hslColor.lightness <= _blackMaxLightness; + bool isBlack(HSLColor hslColor) { + const double blackMaxLightness = 0.05; + return hslColor.lightness <= blackMaxLightness; } - bool _isWhite(HSLColor hslColor) { - const double _whiteMinLightness = 0.95; - return hslColor.lightness >= _whiteMinLightness; + bool isWhite(HSLColor hslColor) { + const double whiteMinLightness = 0.95; + return hslColor.lightness >= whiteMinLightness; } // Returns true if the color is close to the red side of the I line. - bool _isNearRedILine(HSLColor hslColor) { + bool isNearRedILine(HSLColor hslColor) { const double redLineMinHue = 10.0; const double redLineMaxHue = 37.0; const double redLineMaxSaturation = 0.82; @@ -903,7 +899,7 @@ bool avoidRedBlackWhitePaletteFilter(HSLColor color) { hslColor.saturation <= redLineMaxSaturation; } - return !_isWhite(color) && !_isBlack(color) && !_isNearRedILine(color); + return !isWhite(color) && !isBlack(color) && !isNearRedILine(color); } enum _ColorComponent { diff --git a/packages/palette_generator/palette_generator.iml b/packages/palette_generator/palette_generator.iml deleted file mode 100644 index c9ef74cfcd..0000000000 --- a/packages/palette_generator/palette_generator.iml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/packages/palette_generator/pubspec.yaml b/packages/palette_generator/pubspec.yaml index cadb3658c7..16bf6822f2 100644 --- a/packages/palette_generator/pubspec.yaml +++ b/packages/palette_generator/pubspec.yaml @@ -2,7 +2,7 @@ name: palette_generator description: Flutter package for generating palette colors from a source image. repository: https://github.com/flutter/packages/tree/main/packages/palette_generator issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+palette_generator%22 -version: 0.3.3+1 +version: 0.3.3+2 environment: sdk: ">=2.14.0 <3.0.0" diff --git a/packages/palette_generator/test/palette_generator_test.dart b/packages/palette_generator/test/palette_generator_test.dart index f5514b86de..5e2e810a0d 100644 --- a/packages/palette_generator/test/palette_generator_test.dart +++ b/packages/palette_generator/test/palette_generator_test.dart @@ -6,7 +6,7 @@ import 'dart:io'; // TODO(a14n): remove this import once Flutter 3.1 or later reaches stable (including flutter/flutter#104231) // ignore: unnecessary_import import 'dart:typed_data'; -import 'dart:ui' as ui show Image, Codec, FrameInfo, instantiateImageCodec; +import 'dart:ui' as ui show Codec, FrameInfo, Image, instantiateImageCodec; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; diff --git a/packages/pigeon/CHANGELOG.md b/packages/pigeon/CHANGELOG.md index c0842075d3..057857e9ba 100644 --- a/packages/pigeon/CHANGELOG.md +++ b/packages/pigeon/CHANGELOG.md @@ -1,3 +1,7 @@ +## 4.0.2 + +* Fixes lint warnings. + ## 4.0.1 * Exposes `SwiftOptions`. diff --git a/packages/pigeon/e2e_tests/test_objc/lib/dartle.dart b/packages/pigeon/e2e_tests/test_objc/lib/dartle.dart index 12104ac312..d321f40ade 100644 --- a/packages/pigeon/e2e_tests/test_objc/lib/dartle.dart +++ b/packages/pigeon/e2e_tests/test_objc/lib/dartle.dart @@ -7,9 +7,9 @@ // ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name, unnecessary_import // @dart = 2.12 import 'dart:async'; -import 'dart:typed_data' show Uint8List, Int32List, Int64List, Float64List; +import 'dart:typed_data' show Float64List, Int32List, Int64List, Uint8List; -import 'package:flutter/foundation.dart' show WriteBuffer, ReadBuffer; +import 'package:flutter/foundation.dart' show ReadBuffer, WriteBuffer; import 'package:flutter/services.dart'; enum MessageRequestState { diff --git a/packages/pigeon/lib/ast.dart b/packages/pigeon/lib/ast.dart index faffc7bcd3..ade2287941 100644 --- a/packages/pigeon/lib/ast.dart +++ b/packages/pigeon/lib/ast.dart @@ -6,7 +6,9 @@ import 'package:collection/collection.dart' show ListEquality; import 'package:meta/meta.dart'; import 'pigeon_lib.dart'; -final Function _listEquals = const ListEquality().equals; +typedef _ListEquals = bool Function(List, List); + +final _ListEquals _listEquals = const ListEquality().equals; /// Enum that represents where an [Api] is located, on the host or Flutter. enum ApiLocation { diff --git a/packages/pigeon/lib/cpp_generator.dart b/packages/pigeon/lib/cpp_generator.dart index 8de2c5a7ba..ca2c9647af 100644 --- a/packages/pigeon/lib/cpp_generator.dart +++ b/packages/pigeon/lib/cpp_generator.dart @@ -2,9 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'package:pigeon/functional.dart'; - import 'ast.dart'; +import 'functional.dart'; import 'generator_tools.dart'; import 'pigeon_lib.dart' show Error; @@ -576,7 +575,7 @@ const flutter::StandardMessageCodec& ${api.name}::GetCodec() { }); } - String _wrapResponse(String reply, TypeDeclaration returnType) { + String wrapResponse(String reply, TypeDeclaration returnType) { String elseBody = ''; final String ifCondition; final String errorGetter; @@ -637,7 +636,7 @@ $prefix\t}${indent.newline}'''; if (method.isAsynchronous) { methodArgument.add( '[&wrapped, &reply]($returnTypeName&& output) {${indent.newline}' - '${_wrapResponse('\treply(wrapped);${indent.newline}', method.returnType)}' + '${wrapResponse('\treply(wrapped);${indent.newline}', method.returnType)}' '}', ); } @@ -647,7 +646,7 @@ $prefix\t}${indent.newline}'''; indent.format('$call;'); } else { indent.writeln('$returnTypeName output = $call;'); - indent.format(_wrapResponse('', method.returnType)); + indent.format(wrapResponse('', method.returnType)); } }); indent.write('catch (const std::exception& exception) '); @@ -676,7 +675,7 @@ String _getArgumentName(int count, NamedType argument) => /// Returns an argument name that can be used in a context where it is possible to collide. String _getSafeArgumentName(int count, NamedType argument) => - _getArgumentName(count, argument) + '_arg'; + '${_getArgumentName(count, argument)}_arg'; void _writeFlutterApiHeader(Indent indent, Api api) { assert(api.location == ApiLocation.flutter); @@ -953,10 +952,11 @@ String _nullSafeCppTypeForDartType(TypeDeclaration type, } else { String typeName = _baseCppTypeForDartType(type); if (_isReferenceType(typeName)) { - if (considerReference) + if (considerReference) { typeName = 'const $typeName&'; - else + } else { typeName = 'std::unique_ptr<$typeName>'; + } } return typeName; } @@ -970,7 +970,7 @@ String _getGuardName(String? headerFileName, String? namespace) { if (namespace != null) { guardName += '${namespace.toUpperCase()}_'; } - return guardName + 'H_'; + return '${guardName}H_'; } void _writeSystemHeaderIncludeBlock(Indent indent, List headers) { @@ -1147,7 +1147,7 @@ List validateCpp(CppOptions options, Root root) { // TODO(gaaclarke): Add line number and filename. result.add(Error( message: - 'Nullable enum types aren\'t supported in C++ arguments in method:${api.name}.${method.name} argument:(${arg.type.baseName} ${arg.name}).')); + "Nullable enum types aren't supported in C++ arguments in method:${api.name}.${method.name} argument:(${arg.type.baseName} ${arg.name}).")); } } } diff --git a/packages/pigeon/lib/dart_generator.dart b/packages/pigeon/lib/dart_generator.dart index a81fe5f9d6..f13c7e7607 100644 --- a/packages/pigeon/lib/dart_generator.dart +++ b/packages/pigeon/lib/dart_generator.dart @@ -118,7 +118,7 @@ String _makeGenericCastCall(TypeDeclaration type) { /// Returns an argument name that can be used in a context where it is possible to collide. String _getSafeArgumentName(int count, NamedType field) => - field.name.isEmpty ? 'arg$count' : 'arg_' + field.name; + field.name.isEmpty ? 'arg$count' : 'arg_${field.name}'; /// Generates an argument name if one isn't defined. String _getArgumentName(int count, NamedType field) => @@ -199,12 +199,12 @@ final BinaryMessenger? _binaryMessenger; 'final BasicMessageChannel channel = BasicMessageChannel('); indent.nest(2, () { indent.writeln( - '\'$channelName\', codec, binaryMessenger: _binaryMessenger);', + "'$channelName', codec, binaryMessenger: _binaryMessenger);", ); }); final String returnType = _makeGenericTypeArguments(func.returnType); final String castCall = _makeGenericCastCall(func.returnType); - const String accessor = 'replyMap[\'${Keys.result}\']'; + const String accessor = "replyMap['${Keys.result}']"; final String nullHandler = func.returnType.isNullable ? (castCall.isEmpty ? '' : '?') : '!'; final String returnStatement = func.returnType.isVoid @@ -293,7 +293,7 @@ void _writeFlutterApi( : channelNameFunc(func); indent.nest(2, () { indent.writeln( - '\'$channelName\', codec, binaryMessenger: binaryMessenger);', + "'$channelName', codec, binaryMessenger: binaryMessenger);", ); }); final String messageHandlerSetter = @@ -322,7 +322,7 @@ void _writeFlutterApi( call = 'api.${func.name}()'; } else { indent.writeln( - 'assert(message != null, \'Argument for $channelName was null.\');', + "assert(message != null, 'Argument for $channelName was null.');", ); const String argsArray = 'args'; indent.writeln( @@ -340,7 +340,7 @@ void _writeFlutterApi( 'final $argType? $argName = ($argsArray[$count] as $genericArgType?)${castCall.isEmpty ? '' : '?$castCall'};'); if (!arg.type.isNullable) { indent.writeln( - 'assert($argName != null, \'Argument for $channelName was null, expected non-null $argType.\');'); + "assert($argName != null, 'Argument for $channelName was null, expected non-null $argType.');"); } }); final Iterable argNames = @@ -365,7 +365,7 @@ void _writeFlutterApi( } const String returnExpression = 'output'; final String returnStatement = isMockHandler - ? 'return {\'${Keys.result}\': $returnExpression};' + ? "return {'${Keys.result}': $returnExpression};" : 'return $returnExpression;'; indent.writeln(returnStatement); } @@ -443,14 +443,14 @@ void generateDart(DartOptions opt, Root root, StringSink sink) { } void writeImports() { - indent.writeln('import \'dart:async\';'); + indent.writeln("import 'dart:async';"); indent.writeln( - 'import \'dart:typed_data\' show Uint8List, Int32List, Int64List, Float64List;', + "import 'dart:typed_data' show Float64List, Int32List, Int64List, Uint8List;", ); indent.addln(''); indent.writeln( - 'import \'package:flutter/foundation.dart\' show WriteBuffer, ReadBuffer;'); - indent.writeln('import \'package:flutter/services.dart\';'); + "import 'package:flutter/foundation.dart' show ReadBuffer, WriteBuffer;"); + indent.writeln("import 'package:flutter/services.dart';"); } void writeDataClass(Class klass) { @@ -471,7 +471,7 @@ void generateDart(DartOptions opt, Root root, StringSink sink) { 'final Map pigeonMap = {};', ); for (final NamedType field in klass.fields) { - indent.write('pigeonMap[\'${field.name}\'] = '); + indent.write("pigeonMap['${field.name}'] = "); final String conditional = field.type.isNullable ? '?' : ''; if (customClassNames.contains(field.type.baseName)) { indent.addln( @@ -520,17 +520,17 @@ pigeonMap['${field.name}'] != null final String castCall = _makeGenericCastCall(field.type); final String castCallPrefix = field.type.isNullable ? '?' : '!'; indent.add( - '(pigeonMap[\'${field.name}\'] as $genericType?)$castCallPrefix$castCall', + "(pigeonMap['${field.name}'] as $genericType?)$castCallPrefix$castCall", ); } else { final String genericdType = _addGenericTypesNullable(field.type); if (field.type.isNullable) { indent.add( - 'pigeonMap[\'${field.name}\'] as $genericdType', + "pigeonMap['${field.name}'] as $genericdType", ); } else { indent.add( - 'pigeonMap[\'${field.name}\']! as $genericdType', + "pigeonMap['${field.name}']! as $genericdType", ); } } @@ -630,7 +630,7 @@ String? _deducePackageName(String mainDartFile) { try { final String text = File(pubspecPath).readAsStringSync(); - return (yaml.loadYaml(text) as Map)['name']; + return (yaml.loadYaml(text) as Map)['name'] as String?; } catch (_) { return null; } @@ -663,14 +663,14 @@ void generateTestDart( '// ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, unnecessary_import', ); indent.writeln('// ignore_for_file: avoid_relative_lib_imports'); - indent.writeln('import \'dart:async\';'); + indent.writeln("import 'dart:async';"); indent.writeln( - 'import \'dart:typed_data\' show Uint8List, Int32List, Int64List, Float64List;', + "import 'dart:typed_data' show Float64List, Int32List, Int64List, Uint8List;", ); indent.writeln( - 'import \'package:flutter/foundation.dart\' show WriteBuffer, ReadBuffer;'); - indent.writeln('import \'package:flutter/services.dart\';'); - indent.writeln('import \'package:flutter_test/flutter_test.dart\';'); + "import 'package:flutter/foundation.dart' show ReadBuffer, WriteBuffer;"); + indent.writeln("import 'package:flutter/services.dart';"); + indent.writeln("import 'package:flutter_test/flutter_test.dart';"); indent.writeln(''); final String relativeDartPath = path.Context(style: path.Style.posix).relative( @@ -684,7 +684,7 @@ void generateTestDart( // certain (older) versions of Dart. // TODO(gaaclarke): We should add a command-line parameter to override this import. indent.writeln( - 'import \'${_escapeForDartSingleQuotedString(relativeDartPath)}\';'); + "import '${_escapeForDartSingleQuotedString(relativeDartPath)}';"); } else { final String path = relativeDartPath.replaceFirst(RegExp(r'^.*/lib/'), ''); indent.writeln("import 'package:$packageName/$path';"); diff --git a/packages/pigeon/lib/functional.dart b/packages/pigeon/lib/functional.dart index 9c50ce6bd2..8e23950e9e 100644 --- a/packages/pigeon/lib/functional.dart +++ b/packages/pigeon/lib/functional.dart @@ -32,7 +32,7 @@ Iterable map2( yield func(itt.current, itu.current); } if (itu.moveNext() || itt.moveNext()) { - throw ArgumentError('Iterables aren\'t of equal length.'); + throw ArgumentError("Iterables aren't of equal length."); } } @@ -47,7 +47,7 @@ Iterable map3(Iterable ts, Iterable us, Iterable ws, yield func(itt.current, itu.current, itw.current); } if (itu.moveNext() || itt.moveNext() || itw.moveNext()) { - throw ArgumentError('Iterables aren\'t of equal length.'); + throw ArgumentError("Iterables aren't of equal length."); } } diff --git a/packages/pigeon/lib/generator_tools.dart b/packages/pigeon/lib/generator_tools.dart index 6a32c2c277..3c89473150 100644 --- a/packages/pigeon/lib/generator_tools.dart +++ b/packages/pigeon/lib/generator_tools.dart @@ -9,7 +9,7 @@ import 'dart:mirrors'; import 'ast.dart'; /// The current version of pigeon. This must match the version in pubspec.yaml. -const String pigeonVersion = '4.0.1'; +const String pigeonVersion = '4.0.2'; /// Read all the content from [stdin] to a String. String readStdin() { @@ -37,9 +37,7 @@ class Indent { String get newline { if (debugGenerators) { final List frames = StackTrace.current.toString().split('\n'); - return ' //' + - frames.firstWhere((String x) => x.contains('_generator.dart')) + - '\n'; + return ' //${frames.firstWhere((String x) => x.contains('_generator.dart'))}\n'; } else { return '\n'; } @@ -119,7 +117,7 @@ class Indent { /// indentation will be incremented by the given amount. void nest(int count, Function func) { inc(count); - func(); + func(); // ignore: avoid_dynamic_calls dec(count); } @@ -423,7 +421,7 @@ Iterable getCodecClasses(Api api, Root root) sync* { const int maxCustomClassesPerApi = 255 - _minimumCodecFieldKey; if (sortedNames.length > maxCustomClassesPerApi) { throw Exception( - 'Pigeon doesn\'t support more than $maxCustomClassesPerApi referenced custom classes per API, try splitting up your APIs.'); + "Pigeon doesn't support more than $maxCustomClassesPerApi referenced custom classes per API, try splitting up your APIs."); } for (final String name in sortedNames) { yield EnumeratedClass(name, enumeration); diff --git a/packages/pigeon/lib/java_generator.dart b/packages/pigeon/lib/java_generator.dart index e5a3e08220..e414d366e1 100644 --- a/packages/pigeon/lib/java_generator.dart +++ b/packages/pigeon/lib/java_generator.dart @@ -306,7 +306,7 @@ String _getArgumentName(int count, NamedType argument) => /// Returns an argument name that can be used in a context where it is possible to collide. String _getSafeArgumentName(int count, NamedType argument) => - _getArgumentName(count, argument) + 'Arg'; + '${_getArgumentName(count, argument)}Arg'; /// Writes the code for a flutter [Api], [api]. /// Example: @@ -503,7 +503,7 @@ void generateJava(JavaOptions options, Root root, StringSink sink) { indent.writeln('import java.util.HashMap;'); } - String _camelToSnake(String camelCase) { + String camelToSnake(String camelCase) { final RegExp regex = RegExp('([a-z])([A-Z]+)'); return camelCase .replaceAllMapped(regex, (Match m) => '${m[1]}_${m[2]}') @@ -516,7 +516,7 @@ void generateJava(JavaOptions options, Root root, StringSink sink) { int index = 0; for (final String member in anEnum.members) { indent.writeln( - '${_camelToSnake(member)}($index)${index == anEnum.members.length - 1 ? ';' : ','}'); + '${camelToSnake(member)}($index)${index == anEnum.members.length - 1 ? ';' : ','}'); index++; } indent.writeln(''); diff --git a/packages/pigeon/lib/objc_generator.dart b/packages/pigeon/lib/objc_generator.dart index 84dc5cd8f7..088f9e42ad 100644 --- a/packages/pigeon/lib/objc_generator.dart +++ b/packages/pigeon/lib/objc_generator.dart @@ -2,11 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'package:pigeon/functional.dart'; -import 'package:pigeon/pigeon_lib.dart' show TaskQueueType, Error; - import 'ast.dart'; +import 'functional.dart'; import 'generator_tools.dart'; +import 'pigeon_lib.dart' show Error, TaskQueueType; /// Options that control how Objective-C code will be generated. class ObjcOptions { @@ -446,14 +445,15 @@ void _writeHostApiDeclaration( !func.isAsynchronous) { indent.writeln('/// @return `nil` only when `error != nil`.'); } - indent.writeln(_makeObjcSignature( - func: func, - options: options, - returnType: returnType, - lastArgName: lastArgName, - lastArgType: lastArgType, - isEnum: (TypeDeclaration t) => isEnum(root, t)) + - ';'); + final String signature = _makeObjcSignature( + func: func, + options: options, + returnType: returnType, + lastArgName: lastArgName, + lastArgType: lastArgType, + isEnum: (TypeDeclaration t) => isEnum(root, t), + ); + indent.writeln('$signature;'); } indent.writeln('@end'); indent.writeln(''); @@ -480,15 +480,14 @@ void _writeFlutterApiDeclaration( final _ObjcPtr returnType = _objcTypeForDartType(options.prefix, func.returnType); final String callbackType = _callbackForType(func.returnType, returnType); - indent.writeln(_makeObjcSignature( - func: func, - options: options, - returnType: 'void', - lastArgName: 'completion', - lastArgType: callbackType, - isEnum: (TypeDeclaration t) => isEnum(root, t), - ) + - ';'); + indent.writeln('${_makeObjcSignature( + func: func, + options: options, + returnType: 'void', + lastArgName: 'completion', + lastArgType: callbackType, + isEnum: (TypeDeclaration t) => isEnum(root, t), + )};'); } indent.writeln('@end'); } @@ -593,7 +592,7 @@ String _dictValue( } String _getSelector(Method func, String lastSelectorComponent) => - _getSelectorComponents(func, lastSelectorComponent).join(':') + ':'; + '${_getSelectorComponents(func, lastSelectorComponent).join(':')}:'; /// Returns an argument name that can be used in a context where it is possible to collide. String _getSafeArgName(int count, NamedType arg) => @@ -990,7 +989,7 @@ List validateObjc(ObjcOptions options, Root root) { // TODO(gaaclarke): Add line number. errors.add(Error( message: - 'Nullable enum types aren\'t support in ObjC arguments in method:${api.name}.${method.name} argument:(${arg.type.baseName} ${arg.name}).')); + "Nullable enum types aren't support in ObjC arguments in method:${api.name}.${method.name} argument:(${arg.type.baseName} ${arg.name}).")); } } } diff --git a/packages/pigeon/lib/pigeon.dart b/packages/pigeon/lib/pigeon.dart index 737954bd50..d4875c3d1e 100644 --- a/packages/pigeon/lib/pigeon.dart +++ b/packages/pigeon/lib/pigeon.dart @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -export 'dart:typed_data' show Uint8List, Int32List, Int64List, Float64List; +export 'dart:typed_data' show Float64List, Int32List, Int64List, Uint8List; export 'cpp_generator.dart' show CppOptions; export 'dart_generator.dart' show DartOptions; diff --git a/packages/pigeon/lib/pigeon_cl.dart b/packages/pigeon/lib/pigeon_cl.dart index 633ec32aa4..69c3d81ef3 100644 --- a/packages/pigeon/lib/pigeon_cl.dart +++ b/packages/pigeon/lib/pigeon_cl.dart @@ -3,7 +3,7 @@ // found in the LICENSE file. import 'dart:async'; -import 'package:pigeon/pigeon_lib.dart'; +import 'pigeon_lib.dart'; /// This is the main entrypoint for the command-line tool. [args] are the /// commmand line arguments and there is an optional [packageConfig] to diff --git a/packages/pigeon/lib/pigeon_lib.dart b/packages/pigeon/lib/pigeon_lib.dart index 9ac5c6842d..0e282c64da 100644 --- a/packages/pigeon/lib/pigeon_lib.dart +++ b/packages/pigeon/lib/pigeon_lib.dart @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// ignore_for_file: avoid_print + import 'dart:convert'; import 'dart:io'; import 'dart:mirrors'; @@ -19,23 +21,23 @@ import 'package:analyzer/dart/ast/visitor.dart' as dart_ast_visitor; import 'package:analyzer/error/error.dart' show AnalysisError; import 'package:args/args.dart'; import 'package:path/path.dart' as path; -import 'package:pigeon/cpp_generator.dart'; -import 'package:pigeon/generator_tools.dart'; -import 'package:pigeon/java_generator.dart'; -import 'package:pigeon/swift_generator.dart'; import 'ast.dart'; import 'ast_generator.dart'; +import 'cpp_generator.dart'; import 'dart_generator.dart'; +import 'generator_tools.dart'; import 'generator_tools.dart' as generator_tools; +import 'java_generator.dart'; import 'objc_generator.dart'; +import 'swift_generator.dart'; class _Asynchronous { const _Asynchronous(); } /// Metadata to annotate a Api method as asynchronous -const _Asynchronous async = _Asynchronous(); +const Object async = _Asynchronous(); /// Metadata annotation used to configure how Pigeon will generate code. class ConfigurePigeon { @@ -809,7 +811,7 @@ class _RootBuilder extends dart_ast_visitor.RecursiveAstVisitor { if (node.uri.stringValue != 'package:pigeon/pigeon.dart') { _errors.add(Error( message: - 'Unsupported import ${node.uri}, only imports of \'package:pigeon/pigeon.dart\' are supported.', + "Unsupported import ${node.uri}, only imports of 'package:pigeon/pigeon.dart' are supported.", lineNumber: _calculateLineNumber(source, node.offset), )); } @@ -1011,7 +1013,7 @@ class _RootBuilder extends dart_ast_visitor.RecursiveAstVisitor { if (node.isStatic) { _errors.add(Error( message: - 'Pigeon doesn\'t support static fields ("${node.toString()}"), consider using enums.', + 'Pigeon doesn\'t support static fields ("$node"), consider using enums.', lineNumber: _calculateLineNumber(source, node.offset))); } else if (type is dart_ast.NamedType) { final _FindInitializer findInitializerVisitor = _FindInitializer(); @@ -1033,7 +1035,7 @@ class _RootBuilder extends dart_ast_visitor.RecursiveAstVisitor { } } else { _errors.add(Error( - message: 'Expected a named type but found "${node.toString()}".', + message: 'Expected a named type but found "$node".', lineNumber: _calculateLineNumber(source, node.offset))); } } else if (_currentApi != null) { @@ -1140,15 +1142,13 @@ class Pigeon { /// String that describes how the tool is used. static String get usage { return ''' - Pigeon is a tool for generating type-safe communication code between Flutter and the host platform. usage: pigeon --input --dart_out [option]* options: -''' + - _argParser.usage; +${_argParser.usage}'''; } static final ArgParser _argParser = ArgParser() @@ -1182,14 +1182,13 @@ options: help: 'Path to file with copyright header to be prepended to generated code.') ..addFlag('one_language', - help: 'Allow Pigeon to only generate code for one language.', - defaultsTo: false) + help: 'Allow Pigeon to only generate code for one language.') ..addOption('ast_out', help: 'Path to generated AST debugging info. (Warning: format subject to change)') ..addFlag('debug_generators', - help: 'Print the line number of the generator in comments at newlines.', - defaultsTo: false); + help: + 'Print the line number of the generator in comments at newlines.'); /// Convert command-line arguments to [PigeonOptions]. static PigeonOptions parseArgs(List args) { @@ -1239,7 +1238,7 @@ options: declaration.parameters[0].type == reflectClass(PigeonOptions)) { library.invoke(declaration.simpleName, [options]); } else { - print('warning: invalid \'configurePigeon\' method defined.'); + print("warning: invalid 'configurePigeon' method defined."); } } } diff --git a/packages/pigeon/lib/swift_generator.dart b/packages/pigeon/lib/swift_generator.dart index 8be42784d2..43e2eef5ea 100644 --- a/packages/pigeon/lib/swift_generator.dart +++ b/packages/pigeon/lib/swift_generator.dart @@ -2,9 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'package:pigeon/functional.dart'; - import 'ast.dart'; +import 'functional.dart'; import 'generator_tools.dart'; /// Options that control how Swift code will be generated. @@ -243,7 +242,7 @@ String _getArgumentName(int count, NamedType argument) => /// Returns an argument name that can be used in a context where it is possible to collide. String _getSafeArgumentName(int count, NamedType argument) => - _getArgumentName(count, argument) + 'Arg'; + '${_getArgumentName(count, argument)}Arg'; String _camelCase(String text) { final String pascal = text.split('_').map((String part) { @@ -407,7 +406,7 @@ void generateSwift(SwiftOptions options, Root root, StringSink sink) { root.enums.map((Enum x) => x.name).toSet(); final Indent indent = Indent(sink); - HostDatatype _getHostDatatype(NamedType field) { + HostDatatype getHostDatatype(NamedType field) { return getFieldHostDatatype(field, root.classes, root.enums, (TypeDeclaration x) => _swiftTypeForBuiltinDartType(x)); } @@ -454,7 +453,7 @@ void generateSwift(SwiftOptions options, Root root, StringSink sink) { indent.write('return '); indent.scoped('[', ']', () { for (final NamedType field in klass.fields) { - final HostDatatype hostDatatype = _getHostDatatype(field); + final HostDatatype hostDatatype = getHostDatatype(field); String toWriteValue = ''; final String fieldName = field.name; final String nullsafe = field.type.isNullable ? '?' : ''; @@ -483,7 +482,7 @@ void generateSwift(SwiftOptions options, Root root, StringSink sink) { indent.scoped('{', '}', () { for (final NamedType field in klass.fields) { - final HostDatatype hostDatatype = _getHostDatatype(field); + final HostDatatype hostDatatype = getHostDatatype(field); final String mapValue = 'map["${field.name}"]'; final String fieldType = _swiftTypeForDartType(field.type); diff --git a/packages/pigeon/mock_handler_tester/test/message.dart b/packages/pigeon/mock_handler_tester/test/message.dart index 12104ac312..d321f40ade 100644 --- a/packages/pigeon/mock_handler_tester/test/message.dart +++ b/packages/pigeon/mock_handler_tester/test/message.dart @@ -7,9 +7,9 @@ // ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name, unnecessary_import // @dart = 2.12 import 'dart:async'; -import 'dart:typed_data' show Uint8List, Int32List, Int64List, Float64List; +import 'dart:typed_data' show Float64List, Int32List, Int64List, Uint8List; -import 'package:flutter/foundation.dart' show WriteBuffer, ReadBuffer; +import 'package:flutter/foundation.dart' show ReadBuffer, WriteBuffer; import 'package:flutter/services.dart'; enum MessageRequestState { diff --git a/packages/pigeon/mock_handler_tester/test/test.dart b/packages/pigeon/mock_handler_tester/test/test.dart index 3d4dbebe01..f0640c2af2 100644 --- a/packages/pigeon/mock_handler_tester/test/test.dart +++ b/packages/pigeon/mock_handler_tester/test/test.dart @@ -8,8 +8,8 @@ // ignore_for_file: avoid_relative_lib_imports // @dart = 2.12 import 'dart:async'; -import 'dart:typed_data' show Uint8List, Int32List, Int64List, Float64List; -import 'package:flutter/foundation.dart' show WriteBuffer, ReadBuffer; +import 'dart:typed_data' show Float64List, Int32List, Int64List, Uint8List; +import 'package:flutter/foundation.dart' show ReadBuffer, WriteBuffer; import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; diff --git a/packages/pigeon/pigeons/all_datatypes.dart b/packages/pigeon/pigeons/all_datatypes.dart index 8a260d25c6..ddc693b3af 100644 --- a/packages/pigeon/pigeons/all_datatypes.dart +++ b/packages/pigeon/pigeons/all_datatypes.dart @@ -13,9 +13,9 @@ class Everything { Int32List? a4ByteArray; Int64List? a8ByteArray; Float64List? aFloatArray; - // ignore: always_specify_types + // ignore: always_specify_types, strict_raw_type List? aList; - // ignore: always_specify_types + // ignore: always_specify_types, strict_raw_type Map? aMap; List?>? nestedList; Map? mapWithAnnotations; diff --git a/packages/pigeon/pigeons/flutter_unittests.dart b/packages/pigeon/pigeons/flutter_unittests.dart index acde4833ac..8858ad26cb 100644 --- a/packages/pigeon/pigeons/flutter_unittests.dart +++ b/packages/pigeon/pigeons/flutter_unittests.dart @@ -14,12 +14,12 @@ class FlutterSearchReply { } class FlutterSearchRequests { - // ignore: always_specify_types + // ignore: always_specify_types, strict_raw_type List? requests; } class FlutterSearchReplies { - // ignore: always_specify_types + // ignore: always_specify_types, strict_raw_type List? replies; } diff --git a/packages/pigeon/pigeons/list.dart b/packages/pigeon/pigeons/list.dart index 11359e7623..c813f74560 100644 --- a/packages/pigeon/pigeons/list.dart +++ b/packages/pigeon/pigeons/list.dart @@ -5,7 +5,7 @@ import 'package:pigeon/pigeon.dart'; class TestMessage { - // ignore: always_specify_types + // ignore: always_specify_types, strict_raw_type List? testList; } diff --git a/packages/pigeon/pigeons/primitive.dart b/packages/pigeon/pigeons/primitive.dart index cc8eea5cc4..a333c624ef 100644 --- a/packages/pigeon/pigeons/primitive.dart +++ b/packages/pigeon/pigeons/primitive.dart @@ -10,9 +10,9 @@ abstract class PrimitiveHostApi { bool aBool(bool value); String aString(String value); double aDouble(double value); - // ignore: always_specify_types + // ignore: always_specify_types, strict_raw_type Map aMap(Map value); - // ignore: always_specify_types + // ignore: always_specify_types, strict_raw_type List aList(List value); Int32List anInt32List(Int32List value); List aBoolList(List value); @@ -25,9 +25,9 @@ abstract class PrimitiveFlutterApi { bool aBool(bool value); String aString(String value); double aDouble(double value); - // ignore: always_specify_types + // ignore: always_specify_types, strict_raw_type Map aMap(Map value); - // ignore: always_specify_types + // ignore: always_specify_types, strict_raw_type List aList(List value); Int32List anInt32List(Int32List value); List aBoolList(List value); diff --git a/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/all_datatypes.dart b/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/all_datatypes.dart index 61fe409748..fa0e4b8fe9 100644 --- a/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/all_datatypes.dart +++ b/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/all_datatypes.dart @@ -7,9 +7,9 @@ // ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name, unnecessary_import // @dart = 2.12 import 'dart:async'; -import 'dart:typed_data' show Uint8List, Int32List, Int64List, Float64List; +import 'dart:typed_data' show Float64List, Int32List, Int64List, Uint8List; -import 'package:flutter/foundation.dart' show WriteBuffer, ReadBuffer; +import 'package:flutter/foundation.dart' show ReadBuffer, WriteBuffer; import 'package:flutter/services.dart'; class Everything { diff --git a/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/multiple_arity.gen.dart b/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/multiple_arity.gen.dart index 397a65a46c..e75d34c9e1 100644 --- a/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/multiple_arity.gen.dart +++ b/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/multiple_arity.gen.dart @@ -7,9 +7,9 @@ // ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name // @dart = 2.12 import 'dart:async'; -import 'dart:typed_data' show Uint8List, Int32List, Int64List, Float64List; +import 'dart:typed_data' show Float64List, Int32List, Int64List, Uint8List; -import 'package:flutter/foundation.dart' show WriteBuffer, ReadBuffer; +import 'package:flutter/foundation.dart' show ReadBuffer, WriteBuffer; import 'package:flutter/services.dart'; class _MultipleArityHostApiCodec extends StandardMessageCodec { diff --git a/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/non_null_fields.gen.dart b/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/non_null_fields.gen.dart index 6062fb8bbe..9cb1e526fc 100644 --- a/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/non_null_fields.gen.dart +++ b/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/non_null_fields.gen.dart @@ -7,9 +7,9 @@ // ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name, unnecessary_import // @dart = 2.12 import 'dart:async'; -import 'dart:typed_data' show Uint8List, Int32List, Int64List, Float64List; +import 'dart:typed_data' show Float64List, Int32List, Int64List, Uint8List; -import 'package:flutter/foundation.dart' show WriteBuffer, ReadBuffer; +import 'package:flutter/foundation.dart' show ReadBuffer, WriteBuffer; import 'package:flutter/services.dart'; enum ReplyType { diff --git a/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/null_fields.gen.dart b/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/null_fields.gen.dart index 495f4976db..4e6c96b6b7 100644 --- a/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/null_fields.gen.dart +++ b/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/null_fields.gen.dart @@ -7,9 +7,9 @@ // ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name, unnecessary_import // @dart = 2.12 import 'dart:async'; -import 'dart:typed_data' show Uint8List, Int32List, Int64List, Float64List; +import 'dart:typed_data' show Float64List, Int32List, Int64List, Uint8List; -import 'package:flutter/foundation.dart' show WriteBuffer, ReadBuffer; +import 'package:flutter/foundation.dart' show ReadBuffer, WriteBuffer; import 'package:flutter/services.dart'; enum NullFieldsSearchReplyType { diff --git a/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/null_safe_pigeon.dart b/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/null_safe_pigeon.dart index fabd6eab80..25425f8791 100644 --- a/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/null_safe_pigeon.dart +++ b/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/null_safe_pigeon.dart @@ -7,9 +7,9 @@ // ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name, unnecessary_import // @dart = 2.12 import 'dart:async'; -import 'dart:typed_data' show Uint8List, Int32List, Int64List, Float64List; +import 'dart:typed_data' show Float64List, Int32List, Int64List, Uint8List; -import 'package:flutter/foundation.dart' show WriteBuffer, ReadBuffer; +import 'package:flutter/foundation.dart' show ReadBuffer, WriteBuffer; import 'package:flutter/services.dart'; class FlutterSearchRequest { diff --git a/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/nullable_returns.gen.dart b/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/nullable_returns.gen.dart index 70793585d5..efdff1c805 100644 --- a/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/nullable_returns.gen.dart +++ b/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/nullable_returns.gen.dart @@ -7,9 +7,9 @@ // ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name // @dart = 2.12 import 'dart:async'; -import 'dart:typed_data' show Uint8List, Int32List, Int64List, Float64List; +import 'dart:typed_data' show Float64List, Int32List, Int64List, Uint8List; -import 'package:flutter/foundation.dart' show WriteBuffer, ReadBuffer; +import 'package:flutter/foundation.dart' show ReadBuffer, WriteBuffer; import 'package:flutter/services.dart'; class _NullableReturnHostApiCodec extends StandardMessageCodec { diff --git a/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/primitive.dart b/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/primitive.dart index 7aa576a797..806478f450 100644 --- a/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/primitive.dart +++ b/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/lib/primitive.dart @@ -7,9 +7,9 @@ // ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name // @dart = 2.12 import 'dart:async'; -import 'dart:typed_data' show Uint8List, Int32List, Int64List, Float64List; +import 'dart:typed_data' show Float64List, Int32List, Int64List, Uint8List; -import 'package:flutter/foundation.dart' show WriteBuffer, ReadBuffer; +import 'package:flutter/foundation.dart' show ReadBuffer, WriteBuffer; import 'package:flutter/services.dart'; class _PrimitiveHostApiCodec extends StandardMessageCodec { diff --git a/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/test/null_fields_test.dart b/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/test/null_fields_test.dart index 11eddac227..7cb73be22c 100644 --- a/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/test/null_fields_test.dart +++ b/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/test/null_fields_test.dart @@ -27,19 +27,13 @@ void main() { test('test request constructor with nulls', () { final NullFieldsSearchRequest request = - NullFieldsSearchRequest(query: null, identifier: 1); + NullFieldsSearchRequest(identifier: 1); expect(request.query, isNull); }); test('test reply constructor with nulls', () { - final NullFieldsSearchReply reply = NullFieldsSearchReply( - result: null, - error: null, - indices: null, - request: null, - type: null, - ); + final NullFieldsSearchReply reply = NullFieldsSearchReply(); expect(reply.result, isNull); expect(reply.error, isNull); @@ -117,7 +111,7 @@ void main() { test('test request encode with null', () { final NullFieldsSearchRequest request = - NullFieldsSearchRequest(query: null, identifier: 1); + NullFieldsSearchRequest(identifier: 1); expect(request.encode(), { 'query': null, @@ -147,13 +141,7 @@ void main() { }); test('test reply encode with nulls', () { - final NullFieldsSearchReply reply = NullFieldsSearchReply( - result: null, - error: null, - indices: null, - request: null, - type: null, - ); + final NullFieldsSearchReply reply = NullFieldsSearchReply(); expect(reply.encode(), { 'result': null, diff --git a/packages/pigeon/pubspec.yaml b/packages/pigeon/pubspec.yaml index c453ffb290..984a5e7d5e 100644 --- a/packages/pigeon/pubspec.yaml +++ b/packages/pigeon/pubspec.yaml @@ -2,7 +2,7 @@ name: pigeon description: Code generator tool to make communication between Flutter and the host platform type-safe and easier. repository: https://github.com/flutter/packages/tree/main/packages/pigeon issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3Apigeon -version: 4.0.1 # This must match the version in lib/generator_tools.dart +version: 4.0.2 # This must match the version in lib/generator_tools.dart environment: sdk: ">=2.12.0 <3.0.0" diff --git a/packages/pigeon/test/ast_generator_test.dart b/packages/pigeon/test/ast_generator_test.dart index c9b795dc96..0718c94895 100644 --- a/packages/pigeon/test/ast_generator_test.dart +++ b/packages/pigeon/test/ast_generator_test.dart @@ -16,8 +16,7 @@ void main() { baseName: 'dataType1', isNullable: true, ), - name: 'field1', - offset: null), + name: 'field1'), ], ); final Root root = Root( diff --git a/packages/pigeon/test/cpp_generator_test.dart b/packages/pigeon/test/cpp_generator_test.dart index b8dd3afecb..14b09e9468 100644 --- a/packages/pigeon/test/cpp_generator_test.dart +++ b/packages/pigeon/test/cpp_generator_test.dart @@ -19,12 +19,10 @@ void main() { baseName: 'Input', isNullable: false, ), - name: 'input', - offset: null) + name: 'input') ], returnType: const TypeDeclaration(baseName: 'Output', isNullable: false), - isAsynchronous: false, ) ]) ], classes: [ @@ -34,8 +32,7 @@ void main() { baseName: 'String', isNullable: true, ), - name: 'input', - offset: null) + name: 'input') ]), Class(name: 'Output', fields: [ NamedType( @@ -43,8 +40,7 @@ void main() { baseName: 'String', isNullable: true, ), - name: 'output', - offset: null) + name: 'output') ]) ], enums: []); { @@ -79,12 +75,10 @@ void main() { baseName: 'Input', isNullable: false, ), - name: 'someInput', - offset: null) + name: 'someInput') ], returnType: const TypeDeclaration(baseName: 'Output', isNullable: false), - isAsynchronous: false, ) ]) ], classes: [ @@ -94,8 +88,7 @@ void main() { baseName: 'bool', isNullable: false, ), - name: 'inputField', - offset: null) + name: 'inputField') ]), Class(name: 'Output', fields: [ NamedType( @@ -103,8 +96,7 @@ void main() { baseName: 'bool', isNullable: false, ), - name: 'outputField', - offset: null) + name: 'outputField') ]) ], enums: []); { @@ -144,11 +136,9 @@ void main() { baseName: 'int', isNullable: false, ), - name: 'someInput', - offset: null) + name: 'someInput') ], returnType: const TypeDeclaration(baseName: 'int', isNullable: false), - isAsynchronous: false, ) ]) ], classes: [], enums: []); @@ -186,11 +176,9 @@ void main() { baseName: 'int', isNullable: false, ), - name: 'someInput', - offset: null) + name: 'someInput') ], returnType: const TypeDeclaration(baseName: 'int', isNullable: false), - isAsynchronous: false, ) ]) ], classes: [], enums: []); @@ -224,12 +212,10 @@ void main() { baseName: 'Input', isNullable: false, ), - name: 'input', - offset: null) + name: 'input') ], returnType: const TypeDeclaration(baseName: 'Output', isNullable: false), - isAsynchronous: false, ) ]) ], classes: [ @@ -239,8 +225,7 @@ void main() { baseName: 'String', isNullable: true, ), - name: 'input', - offset: null) + name: 'input') ]), Class(name: 'Output', fields: [ NamedType( @@ -248,8 +233,7 @@ void main() { baseName: 'String', isNullable: true, ), - name: 'output', - offset: null) + name: 'output') ]) ], enums: []); { @@ -279,11 +263,9 @@ void main() { baseName: 'String', isNullable: true, ), - name: 'input', - offset: null) + name: 'input') ], returnType: const TypeDeclaration(baseName: 'int', isNullable: false), - isAsynchronous: false, ) ]) ], classes: [], enums: []); @@ -332,11 +314,9 @@ void main() { baseName: 'String', isNullable: true, ), - name: 'input', - offset: null) + name: 'input') ], returnType: const TypeDeclaration(baseName: 'int', isNullable: false), - isAsynchronous: false, ) ]) ], classes: [], enums: []); @@ -367,11 +347,9 @@ void main() { baseName: 'Input', isNullable: false, ), - name: 'someInput', - offset: null) + name: 'someInput') ], returnType: const TypeDeclaration.voidDeclaration(), - isAsynchronous: false, ) ]) ], classes: [ @@ -381,8 +359,7 @@ void main() { baseName: 'bool', isNullable: true, ), - name: 'nestedValue', - offset: null), + name: 'nestedValue'), ]), Class(name: 'Input', fields: [ NamedType( @@ -390,29 +367,25 @@ void main() { baseName: 'bool', isNullable: true, ), - name: 'nullableBool', - offset: null), + name: 'nullableBool'), NamedType( type: const TypeDeclaration( baseName: 'int', isNullable: true, ), - name: 'nullableInt', - offset: null), + name: 'nullableInt'), NamedType( type: const TypeDeclaration( baseName: 'String', isNullable: true, ), - name: 'nullableString', - offset: null), + name: 'nullableString'), NamedType( type: const TypeDeclaration( baseName: 'Nested', isNullable: true, ), - name: 'nullableNested', - offset: null), + name: 'nullableNested'), ]), ], enums: []); { @@ -506,11 +479,9 @@ void main() { baseName: 'Input', isNullable: false, ), - name: 'someInput', - offset: null) + name: 'someInput') ], returnType: const TypeDeclaration.voidDeclaration(), - isAsynchronous: false, ) ]) ], classes: [ @@ -520,8 +491,7 @@ void main() { baseName: 'bool', isNullable: false, ), - name: 'nestedValue', - offset: null), + name: 'nestedValue'), ]), Class(name: 'Input', fields: [ NamedType( @@ -529,29 +499,25 @@ void main() { baseName: 'bool', isNullable: false, ), - name: 'nonNullableBool', - offset: null), + name: 'nonNullableBool'), NamedType( type: const TypeDeclaration( baseName: 'int', isNullable: false, ), - name: 'nonNullableInt', - offset: null), + name: 'nonNullableInt'), NamedType( type: const TypeDeclaration( baseName: 'String', isNullable: false, ), - name: 'nonNullableString', - offset: null), + name: 'nonNullableString'), NamedType( type: const TypeDeclaration( baseName: 'Nested', isNullable: false, ), - name: 'nonNullableNested', - offset: null), + name: 'nonNullableNested'), ]), ], enums: []); { @@ -615,7 +581,6 @@ void main() { baseName: 'bool', isNullable: true, ), - isAsynchronous: false, ), Method( name: 'returnNullableInt', @@ -624,7 +589,6 @@ void main() { baseName: 'int', isNullable: true, ), - isAsynchronous: false, ), Method( name: 'returnNullableString', @@ -633,7 +597,6 @@ void main() { baseName: 'String', isNullable: true, ), - isAsynchronous: false, ), Method( name: 'returnNullableList', @@ -648,7 +611,6 @@ void main() { ], isNullable: true, ), - isAsynchronous: false, ), Method( name: 'returnNullableMap', @@ -667,7 +629,6 @@ void main() { ], isNullable: true, ), - isAsynchronous: false, ), Method( name: 'returnNullableDataClass', @@ -676,7 +637,6 @@ void main() { baseName: 'ReturnData', isNullable: true, ), - isAsynchronous: false, ), ]) ], classes: [ @@ -686,8 +646,7 @@ void main() { baseName: 'bool', isNullable: false, ), - name: 'aValue', - offset: null), + name: 'aValue'), ]), ], enums: []); { @@ -727,7 +686,6 @@ void main() { baseName: 'bool', isNullable: false, ), - isAsynchronous: false, ), Method( name: 'returnInt', @@ -736,7 +694,6 @@ void main() { baseName: 'int', isNullable: false, ), - isAsynchronous: false, ), Method( name: 'returnString', @@ -745,7 +702,6 @@ void main() { baseName: 'String', isNullable: false, ), - isAsynchronous: false, ), Method( name: 'returnList', @@ -760,7 +716,6 @@ void main() { ], isNullable: false, ), - isAsynchronous: false, ), Method( name: 'returnMap', @@ -779,7 +734,6 @@ void main() { ], isNullable: false, ), - isAsynchronous: false, ), Method( name: 'returnDataClass', @@ -788,7 +742,6 @@ void main() { baseName: 'ReturnData', isNullable: false, ), - isAsynchronous: false, ), ]) ], classes: [ @@ -798,8 +751,7 @@ void main() { baseName: 'bool', isNullable: false, ), - name: 'aValue', - offset: null), + name: 'aValue'), ]), ], enums: []); { @@ -866,7 +818,6 @@ void main() { )), ], returnType: const TypeDeclaration.voidDeclaration(), - isAsynchronous: false, ), ]) ], classes: [ @@ -876,8 +827,7 @@ void main() { baseName: 'bool', isNullable: false, ), - name: 'aValue', - offset: null), + name: 'aValue'), ]), ], enums: []); { @@ -986,7 +936,6 @@ void main() { )), ], returnType: const TypeDeclaration.voidDeclaration(), - isAsynchronous: false, ), ]) ], classes: [ @@ -996,8 +945,7 @@ void main() { baseName: 'bool', isNullable: false, ), - name: 'aValue', - offset: null), + name: 'aValue'), ]), ], enums: []); { @@ -1064,7 +1012,6 @@ void main() { )), ], returnType: const TypeDeclaration.voidDeclaration(), - isAsynchronous: false, ), ]) ], classes: [], enums: []); diff --git a/packages/pigeon/test/dart_generator_test.dart b/packages/pigeon/test/dart_generator_test.dart index 4d37cdf234..ba30219c3c 100644 --- a/packages/pigeon/test/dart_generator_test.dart +++ b/packages/pigeon/test/dart_generator_test.dart @@ -20,8 +20,7 @@ void main() { baseName: 'dataType1', isNullable: true, ), - name: 'field1', - offset: null), + name: 'field1'), ], ); final Root root = Root( @@ -68,12 +67,10 @@ void main() { baseName: 'Input', isNullable: false, ), - name: 'input', - offset: null) + name: 'input') ], returnType: const TypeDeclaration(baseName: 'Output', isNullable: false), - isAsynchronous: false, ) ]) ], classes: [ @@ -83,8 +80,7 @@ void main() { baseName: 'String', isNullable: true, ), - name: 'input', - offset: null) + name: 'input') ]), Class(name: 'Output', fields: [ NamedType( @@ -92,8 +88,7 @@ void main() { baseName: 'String', isNullable: true, ), - name: 'output', - offset: null) + name: 'output') ]) ], enums: []); final StringBuffer sink = StringBuffer(); @@ -119,7 +114,6 @@ void main() { const TypeDeclaration(isNullable: false, baseName: 'int')), ], returnType: const TypeDeclaration(baseName: 'int', isNullable: false), - isAsynchronous: false, ) ]) ], classes: [], enums: []); @@ -147,7 +141,6 @@ void main() { const TypeDeclaration(isNullable: false, baseName: 'int')), ], returnType: const TypeDeclaration(baseName: 'int', isNullable: false), - isAsynchronous: false, ) ]) ], classes: [], enums: []); @@ -173,8 +166,7 @@ void main() { baseName: 'String', isNullable: true, ), - name: 'input', - offset: null) + name: 'input') ], ), Class( @@ -185,8 +177,7 @@ void main() { baseName: 'Input', isNullable: true, ), - name: 'nested', - offset: null) + name: 'nested') ], ) ], enums: []); @@ -196,13 +187,13 @@ void main() { expect( code, contains( - 'pigeonMap[\'nested\'] = nested?.encode()', + "pigeonMap['nested'] = nested?.encode()", ), ); expect( code.replaceAll('\n', ' ').replaceAll(' ', ''), contains( - 'nested: pigeonMap[\'nested\'] != null ? Input.decode(pigeonMap[\'nested\']!) : null', + "nested: pigeonMap['nested'] != null ? Input.decode(pigeonMap['nested']!) : null", ), ); }); @@ -217,8 +208,7 @@ void main() { baseName: 'String', isNullable: false, ), - name: 'input', - offset: null) + name: 'input') ], ), Class( @@ -229,8 +219,7 @@ void main() { baseName: 'Input', isNullable: false, ), - name: 'nested', - offset: null) + name: 'nested') ], ) ], enums: []); @@ -240,13 +229,13 @@ void main() { expect( code, contains( - 'pigeonMap[\'nested\'] = nested.encode()', + "pigeonMap['nested'] = nested.encode()", ), ); expect( code.replaceAll('\n', ' ').replaceAll(' ', ''), contains( - 'nested: Input.decode(pigeonMap[\'nested\']!)', + "nested: Input.decode(pigeonMap['nested']!)", ), ); }); @@ -262,12 +251,10 @@ void main() { baseName: 'Input', isNullable: false, ), - name: 'input', - offset: null) + name: 'input') ], returnType: const TypeDeclaration(baseName: 'Output', isNullable: false), - isAsynchronous: false, ) ]) ], classes: [ @@ -277,8 +264,7 @@ void main() { baseName: 'String', isNullable: true, ), - name: 'input', - offset: null) + name: 'input') ]), Class(name: 'Output', fields: [ NamedType( @@ -286,8 +272,7 @@ void main() { baseName: 'String', isNullable: true, ), - name: 'output', - offset: null) + name: 'output') ]) ], enums: []); final StringBuffer sink = StringBuffer(); @@ -309,11 +294,9 @@ void main() { baseName: 'Input', isNullable: false, ), - name: '', - offset: null) + name: '') ], returnType: const TypeDeclaration.voidDeclaration(), - isAsynchronous: false, ) ]) ], classes: [ @@ -323,8 +306,7 @@ void main() { baseName: 'String', isNullable: true, ), - name: 'input', - offset: null) + name: 'input') ]), ], enums: []); final StringBuffer sink = StringBuffer(); @@ -345,11 +327,9 @@ void main() { baseName: 'Input', isNullable: false, ), - name: '', - offset: null) + name: '') ], returnType: const TypeDeclaration.voidDeclaration(), - isAsynchronous: false, ) ]) ], classes: [ @@ -359,8 +339,7 @@ void main() { baseName: 'String', isNullable: true, ), - name: 'input', - offset: null) + name: 'input') ]), ], enums: []); final StringBuffer sink = StringBuffer(); @@ -381,7 +360,6 @@ void main() { arguments: [], returnType: const TypeDeclaration(baseName: 'Output', isNullable: false), - isAsynchronous: false, ) ]) ], classes: [ @@ -391,8 +369,7 @@ void main() { baseName: 'String', isNullable: true, ), - name: 'output', - offset: null) + name: 'output') ]), ], enums: []); final StringBuffer sink = StringBuffer(); @@ -413,12 +390,10 @@ void main() { baseName: 'EnumClass', isNullable: false, ), - name: '', - offset: null) + name: '') ], returnType: const TypeDeclaration(baseName: 'EnumClass', isNullable: false), - isAsynchronous: false, ) ]) ], classes: [ @@ -428,8 +403,7 @@ void main() { baseName: 'Enum', isNullable: true, ), - name: 'enum1', - offset: null) + name: 'enum1') ]), ], enums: [ Enum( @@ -443,8 +417,8 @@ void main() { final StringBuffer sink = StringBuffer(); generateDart(const DartOptions(), root, sink); final String code = sink.toString(); - expect(code, contains('pigeonMap[\'enum1\'] = enum1?.index;')); - expect(code, contains('? Enum.values[pigeonMap[\'enum1\']! as int]')); + expect(code, contains("pigeonMap['enum1'] = enum1?.index;")); + expect(code, contains("? Enum.values[pigeonMap['enum1']! as int]")); expect(code, contains('EnumClass doSomething(EnumClass arg0);')); }); @@ -483,12 +457,10 @@ void main() { baseName: 'EnumClass', isNullable: false, ), - name: '', - offset: null) + name: '') ], returnType: const TypeDeclaration(baseName: 'EnumClass', isNullable: false), - isAsynchronous: false, ) ]) ], classes: [ @@ -498,8 +470,7 @@ void main() { baseName: 'Enum', isNullable: false, ), - name: 'enum1', - offset: null) + name: 'enum1') ]), ], enums: [ Enum( @@ -513,8 +484,8 @@ void main() { final StringBuffer sink = StringBuffer(); generateDart(const DartOptions(), root, sink); final String code = sink.toString(); - expect(code, contains('pigeonMap[\'enum1\'] = enum1.index;')); - expect(code, contains('enum1: Enum.values[pigeonMap[\'enum1\']! as int]')); + expect(code, contains("pigeonMap['enum1'] = enum1.index;")); + expect(code, contains("enum1: Enum.values[pigeonMap['enum1']! as int]")); }); test('host void argument', () { @@ -525,7 +496,6 @@ void main() { arguments: [], returnType: const TypeDeclaration(baseName: 'Output', isNullable: false), - isAsynchronous: false, ) ]) ], classes: [ @@ -535,8 +505,7 @@ void main() { baseName: 'String', isNullable: true, ), - name: 'output', - offset: null) + name: 'output') ]), ], enums: []); final StringBuffer sink = StringBuffer(); @@ -560,12 +529,10 @@ void main() { baseName: 'Input', isNullable: false, ), - name: '', - offset: null) + name: '') ], returnType: const TypeDeclaration(baseName: 'Output', isNullable: false), - isAsynchronous: false, ), Method( name: 'voidReturner', @@ -575,11 +542,9 @@ void main() { baseName: 'Input', isNullable: false, ), - name: '', - offset: null) + name: '') ], returnType: const TypeDeclaration.voidDeclaration(), - isAsynchronous: false, ) ]) ], classes: [ @@ -589,8 +554,7 @@ void main() { baseName: 'String', isNullable: true, ), - name: 'input', - offset: null) + name: 'input') ]), Class(name: 'Output', fields: [ NamedType( @@ -598,19 +562,18 @@ void main() { baseName: 'String', isNullable: true, ), - name: 'output', - offset: null) + name: 'output') ]) ], enums: []); final StringBuffer mainCodeSink = StringBuffer(); final StringBuffer testCodeSink = StringBuffer(); generateDart(const DartOptions(), root, mainCodeSink); final String mainCode = mainCodeSink.toString(); - expect(mainCode, isNot(contains('import \'fo\\\'o.dart\';'))); + expect(mainCode, isNot(contains(r"import 'fo\'o.dart';"))); expect(mainCode, contains('class Api {')); expect(mainCode, isNot(contains('abstract class ApiMock'))); expect(mainCode, isNot(contains('.ApiMock.doSomething'))); - expect(mainCode, isNot(contains('\'${Keys.result}\': output'))); + expect(mainCode, isNot(contains("'${Keys.result}': output"))); expect(mainCode, isNot(contains('return {};'))); generateTestDart( const DartOptions(), @@ -620,11 +583,11 @@ void main() { testOutPath: 'test.dart', ); final String testCode = testCodeSink.toString(); - expect(testCode, contains('import \'fo\\\'o.dart\';')); + expect(testCode, contains(r"import 'fo\'o.dart';")); expect(testCode, isNot(contains('class Api {'))); expect(testCode, contains('abstract class ApiMock')); expect(testCode, isNot(contains('.ApiMock.doSomething'))); - expect(testCode, contains('\'${Keys.result}\': output')); + expect(testCode, contains("'${Keys.result}': output")); expect(testCode, contains('return {};')); }); @@ -639,8 +602,7 @@ void main() { baseName: 'Input', isNullable: false, ), - name: '', - offset: null) + name: '') ], returnType: const TypeDeclaration(baseName: 'Output', isNullable: false), @@ -654,8 +616,7 @@ void main() { baseName: 'String', isNullable: true, ), - name: 'input', - offset: null) + name: 'input') ]), Class(name: 'Output', fields: [ NamedType( @@ -663,8 +624,7 @@ void main() { baseName: 'String', isNullable: true, ), - name: 'output', - offset: null) + name: 'output') ]) ], enums: []); final StringBuffer sink = StringBuffer(); @@ -687,8 +647,7 @@ void main() { baseName: 'Input', isNullable: false, ), - name: '', - offset: null) + name: '') ], returnType: const TypeDeclaration.voidDeclaration(), isAsynchronous: true, @@ -701,8 +660,7 @@ void main() { baseName: 'String', isNullable: true, ), - name: 'input', - offset: null) + name: 'input') ]), Class(name: 'Output', fields: [ NamedType( @@ -710,8 +668,7 @@ void main() { baseName: 'String', isNullable: true, ), - name: 'output', - offset: null) + name: 'output') ]) ], enums: []); final StringBuffer sink = StringBuffer(); @@ -733,8 +690,7 @@ void main() { baseName: 'Input', isNullable: false, ), - name: '', - offset: null) + name: '') ], returnType: const TypeDeclaration(baseName: 'Output', isNullable: false), @@ -748,8 +704,7 @@ void main() { baseName: 'String', isNullable: true, ), - name: 'input', - offset: null) + name: 'input') ]), Class(name: 'Output', fields: [ NamedType( @@ -757,8 +712,7 @@ void main() { baseName: 'String', isNullable: true, ), - name: 'output', - offset: null) + name: 'output') ]) ], enums: []); final StringBuffer sink = StringBuffer(); @@ -786,8 +740,7 @@ void main() { baseName: 'String', isNullable: true, ), - name: 'output', - offset: null) + name: 'output') ]), ], enums: []); final StringBuffer sink = StringBuffer(); @@ -796,7 +749,7 @@ void main() { expect(code, matches('channel.send[(]null[)]')); }); - Iterable _makeIterable(String string) sync* { + Iterable makeIterable(String string) sync* { yield string; } @@ -804,7 +757,7 @@ void main() { final Root root = Root(apis: [], classes: [], enums: []); final StringBuffer sink = StringBuffer(); generateDart( - DartOptions(copyrightHeader: _makeIterable('hello world')), + DartOptions(copyrightHeader: makeIterable('hello world')), root, sink, ); @@ -823,8 +776,7 @@ void main() { typeArguments: [ TypeDeclaration(baseName: 'int', isNullable: true) ]), - name: 'field1', - offset: null), + name: 'field1'), ], ); final Root root = Root( @@ -851,8 +803,7 @@ void main() { TypeDeclaration(baseName: 'String', isNullable: true), TypeDeclaration(baseName: 'int', isNullable: true), ]), - name: 'field1', - offset: null), + name: 'field1'), ], ); final Root root = Root( @@ -882,8 +833,7 @@ void main() { typeArguments: [ TypeDeclaration(baseName: 'int', isNullable: true) ]), - name: 'arg', - offset: null) + name: 'arg') ]) ]) ], @@ -911,8 +861,7 @@ void main() { typeArguments: [ TypeDeclaration(baseName: 'int', isNullable: true) ]), - name: 'arg', - offset: null) + name: 'arg') ]) ]) ], @@ -950,7 +899,7 @@ void main() { expect( code, contains( - 'return (replyMap[\'result\'] as List?)!.cast();')); + "return (replyMap['result'] as List?)!.cast();")); }); test('flutter generics argument non void return', () { @@ -973,8 +922,7 @@ void main() { typeArguments: [ TypeDeclaration(baseName: 'int', isNullable: true) ]), - name: 'foo', - offset: null) + name: 'foo') ]) ]) ], @@ -1012,7 +960,7 @@ void main() { generateDart(const DartOptions(), root, sink); final String code = sink.toString(); expect(code, contains('Future doit()')); - expect(code, contains('return (replyMap[\'result\'] as int?);')); + expect(code, contains("return (replyMap['result'] as int?);")); }); test('return nullable collection host', () { @@ -1040,7 +988,7 @@ void main() { expect( code, contains( - 'return (replyMap[\'result\'] as List?)?.cast();')); + "return (replyMap['result'] as List?)?.cast();")); }); test('return nullable async host', () { @@ -1064,7 +1012,7 @@ void main() { generateDart(const DartOptions(), root, sink); final String code = sink.toString(); expect(code, contains('Future doit()')); - expect(code, contains('return (replyMap[\'result\'] as int?);')); + expect(code, contains("return (replyMap['result'] as int?);")); }); test('return nullable flutter', () { diff --git a/packages/pigeon/test/generator_tools_test.dart b/packages/pigeon/test/generator_tools_test.dart index a2fa402621..8c391446a6 100644 --- a/packages/pigeon/test/generator_tools_test.dart +++ b/packages/pigeon/test/generator_tools_test.dart @@ -80,7 +80,6 @@ void main() { ], ), name: '', - offset: null, ) ], returnType: @@ -113,7 +112,6 @@ void main() { NamedType( type: const TypeDeclaration(baseName: 'Output', isNullable: false), name: '', - offset: null, ) ], returnType: const TypeDeclaration( @@ -151,12 +149,10 @@ void main() { NamedType( type: const TypeDeclaration(baseName: 'Foo', isNullable: false), name: '', - offset: null, ), NamedType( type: const TypeDeclaration(baseName: 'Bar', isNullable: false), name: '', - offset: null, ), ], returnType: const TypeDeclaration( @@ -199,7 +195,6 @@ void main() { ])), ], returnType: const TypeDeclaration.voidDeclaration(), - isAsynchronous: false, ) ]) ], classes: [ @@ -248,7 +243,6 @@ void main() { ])), ], returnType: const TypeDeclaration.voidDeclaration(), - isAsynchronous: false, ) ], ), @@ -284,7 +278,6 @@ void main() { isNullable: false, baseName: 'Foo')), ], returnType: const TypeDeclaration.voidDeclaration(), - isAsynchronous: false, ) ], ), @@ -301,7 +294,6 @@ void main() { isNullable: false, baseName: 'Foo')), ], returnType: const TypeDeclaration.voidDeclaration(), - isAsynchronous: false, ) ], ) diff --git a/packages/pigeon/test/java_generator_test.dart b/packages/pigeon/test/java_generator_test.dart index 947634b4eb..b2eca32da3 100644 --- a/packages/pigeon/test/java_generator_test.dart +++ b/packages/pigeon/test/java_generator_test.dart @@ -17,8 +17,7 @@ void main() { baseName: 'int', isNullable: true, ), - name: 'field1', - offset: null), + name: 'field1'), ], ); final Root root = Root( @@ -72,8 +71,7 @@ void main() { baseName: 'int', isNullable: true, ), - name: 'field1', - offset: null) + name: 'field1') ], ); final Root root = Root( @@ -101,12 +99,10 @@ void main() { baseName: 'Input', isNullable: false, ), - name: '', - offset: null) + name: '') ], returnType: const TypeDeclaration(baseName: 'Output', isNullable: false), - isAsynchronous: false, ) ]) ], classes: [ @@ -116,8 +112,7 @@ void main() { baseName: 'String', isNullable: true, ), - name: 'input', - offset: null) + name: 'input') ]), Class(name: 'Output', fields: [ NamedType( @@ -125,8 +120,7 @@ void main() { baseName: 'String', isNullable: true, ), - name: 'output', - offset: null) + name: 'output') ]) ], enums: []); final StringBuffer sink = StringBuffer(); @@ -146,57 +140,49 @@ void main() { baseName: 'bool', isNullable: true, ), - name: 'aBool', - offset: null), + name: 'aBool'), NamedType( type: const TypeDeclaration( baseName: 'int', isNullable: true, ), - name: 'aInt', - offset: null), + name: 'aInt'), NamedType( type: const TypeDeclaration( baseName: 'double', isNullable: true, ), - name: 'aDouble', - offset: null), + name: 'aDouble'), NamedType( type: const TypeDeclaration( baseName: 'String', isNullable: true, ), - name: 'aString', - offset: null), + name: 'aString'), NamedType( type: const TypeDeclaration( baseName: 'Uint8List', isNullable: true, ), - name: 'aUint8List', - offset: null), + name: 'aUint8List'), NamedType( type: const TypeDeclaration( baseName: 'Int32List', isNullable: true, ), - name: 'aInt32List', - offset: null), + name: 'aInt32List'), NamedType( type: const TypeDeclaration( baseName: 'Int64List', isNullable: true, ), - name: 'aInt64List', - offset: null), + name: 'aInt64List'), NamedType( type: const TypeDeclaration( baseName: 'Float64List', isNullable: true, ), - name: 'aFloat64List', - offset: null), + name: 'aFloat64List'), ]), ], enums: []); @@ -225,12 +211,10 @@ void main() { baseName: 'Input', isNullable: false, ), - name: '', - offset: null) + name: '') ], returnType: const TypeDeclaration(baseName: 'Output', isNullable: false), - isAsynchronous: false, ) ]) ], classes: [ @@ -240,8 +224,7 @@ void main() { baseName: 'String', isNullable: true, ), - name: 'input', - offset: null) + name: 'input') ]), Class(name: 'Output', fields: [ NamedType( @@ -249,8 +232,7 @@ void main() { baseName: 'String', isNullable: true, ), - name: 'output', - offset: null) + name: 'output') ]) ], enums: []); final StringBuffer sink = StringBuffer(); @@ -272,11 +254,9 @@ void main() { baseName: 'Input', isNullable: false, ), - name: '', - offset: null) + name: '') ], returnType: const TypeDeclaration.voidDeclaration(), - isAsynchronous: false, ) ]) ], classes: [ @@ -286,8 +266,7 @@ void main() { baseName: 'String', isNullable: true, ), - name: 'input', - offset: null) + name: 'input') ]), ], enums: []); final StringBuffer sink = StringBuffer(); @@ -309,11 +288,9 @@ void main() { baseName: 'Input', isNullable: false, ), - name: '', - offset: null) + name: '') ], returnType: const TypeDeclaration.voidDeclaration(), - isAsynchronous: false, ) ]) ], classes: [ @@ -323,8 +300,7 @@ void main() { baseName: 'String', isNullable: true, ), - name: 'input', - offset: null) + name: 'input') ]), ], enums: []); final StringBuffer sink = StringBuffer(); @@ -343,7 +319,6 @@ void main() { arguments: [], returnType: const TypeDeclaration(baseName: 'Output', isNullable: false), - isAsynchronous: false, ) ]) ], classes: [ @@ -353,8 +328,7 @@ void main() { baseName: 'String', isNullable: true, ), - name: 'output', - offset: null) + name: 'output') ]), ], enums: []); final StringBuffer sink = StringBuffer(); @@ -373,7 +347,6 @@ void main() { arguments: [], returnType: const TypeDeclaration(baseName: 'Output', isNullable: false), - isAsynchronous: false, ) ]) ], classes: [ @@ -383,8 +356,7 @@ void main() { baseName: 'String', isNullable: true, ), - name: 'output', - offset: null) + name: 'output') ]), ], enums: []); final StringBuffer sink = StringBuffer(); @@ -403,8 +375,7 @@ void main() { baseName: 'List', isNullable: true, ), - name: 'field1', - offset: null) + name: 'field1') ]), ], enums: []); final StringBuffer sink = StringBuffer(); @@ -423,8 +394,7 @@ void main() { baseName: 'Map', isNullable: true, ), - name: 'field1', - offset: null) + name: 'field1') ]), ], enums: []); final StringBuffer sink = StringBuffer(); @@ -444,8 +414,7 @@ void main() { baseName: 'Nested', isNullable: true, ), - name: 'nested', - offset: null) + name: 'nested') ], ); final Class nestedClass = Class( @@ -456,8 +425,7 @@ void main() { baseName: 'int', isNullable: true, ), - name: 'data', - offset: null) + name: 'data') ], ); final Root root = Root( @@ -490,8 +458,7 @@ void main() { baseName: 'Input', isNullable: false, ), - name: 'arg', - offset: null) + name: 'arg') ], returnType: const TypeDeclaration(baseName: 'Output', isNullable: false), @@ -505,8 +472,7 @@ void main() { baseName: 'String', isNullable: true, ), - name: 'input', - offset: null) + name: 'input') ]), Class(name: 'Output', fields: [ NamedType( @@ -514,8 +480,7 @@ void main() { baseName: 'String', isNullable: true, ), - name: 'output', - offset: null) + name: 'output') ]) ], enums: []); final StringBuffer sink = StringBuffer(); @@ -544,8 +509,7 @@ void main() { baseName: 'Input', isNullable: false, ), - name: '', - offset: null) + name: '') ], returnType: const TypeDeclaration(baseName: 'Output', isNullable: false), @@ -559,8 +523,7 @@ void main() { baseName: 'String', isNullable: true, ), - name: 'input', - offset: null) + name: 'input') ]), Class(name: 'Output', fields: [ NamedType( @@ -568,8 +531,7 @@ void main() { baseName: 'String', isNullable: true, ), - name: 'output', - offset: null) + name: 'output') ]) ], enums: []); final StringBuffer sink = StringBuffer(); @@ -597,8 +559,7 @@ void main() { baseName: 'Enum1', isNullable: true, ), - name: 'enum1', - offset: null), + name: 'enum1'), ], ); final Root root = Root( @@ -655,7 +616,7 @@ void main() { 'Foo fooArg = args.get(0) == null ? null : Foo.values()[(int)args.get(0)];')); }); - Iterable _makeIterable(String string) sync* { + Iterable makeIterable(String string) sync* { yield string; } @@ -664,7 +625,7 @@ void main() { final StringBuffer sink = StringBuffer(); final JavaOptions javaOptions = JavaOptions( className: 'Messages', - copyrightHeader: _makeIterable('hello world'), + copyrightHeader: makeIterable('hello world'), ); generateJava(javaOptions, root, sink); final String code = sink.toString(); @@ -682,8 +643,7 @@ void main() { typeArguments: [ TypeDeclaration(baseName: 'int', isNullable: true) ]), - name: 'field1', - offset: null), + name: 'field1'), ], ); final Root root = Root( @@ -711,8 +671,7 @@ void main() { TypeDeclaration(baseName: 'String', isNullable: true), TypeDeclaration(baseName: 'String', isNullable: true), ]), - name: 'field1', - offset: null), + name: 'field1'), ], ); final Root root = Root( @@ -743,8 +702,7 @@ void main() { typeArguments: [ TypeDeclaration(baseName: 'int', isNullable: true) ]), - name: 'arg', - offset: null) + name: 'arg') ]) ]) ], @@ -773,8 +731,7 @@ void main() { typeArguments: [ TypeDeclaration(baseName: 'int', isNullable: true) ]), - name: 'arg', - offset: null) + name: 'arg') ]) ]) ], @@ -882,7 +839,6 @@ void main() { const TypeDeclaration(isNullable: false, baseName: 'int')), ], returnType: const TypeDeclaration(baseName: 'int', isNullable: false), - isAsynchronous: false, ) ]) ], classes: [], enums: []); @@ -918,7 +874,6 @@ void main() { const TypeDeclaration(isNullable: false, baseName: 'int')), ], returnType: const TypeDeclaration(baseName: 'int', isNullable: false), - isAsynchronous: false, ) ]) ], classes: [], enums: []); diff --git a/packages/pigeon/test/objc_generator_test.dart b/packages/pigeon/test/objc_generator_test.dart index 58e6301570..57546013c9 100644 --- a/packages/pigeon/test/objc_generator_test.dart +++ b/packages/pigeon/test/objc_generator_test.dart @@ -13,8 +13,7 @@ void main() { Class(name: 'Foobar', fields: [ NamedType( type: const TypeDeclaration(baseName: 'String', isNullable: true), - name: 'field1', - offset: null) + name: 'field1') ]), ], enums: []); final StringBuffer sink = StringBuffer(); @@ -29,8 +28,7 @@ void main() { Class(name: 'Foobar', fields: [ NamedType( type: const TypeDeclaration(baseName: 'String', isNullable: true), - name: 'field1', - offset: null) + name: 'field1') ]), ], enums: []); final StringBuffer sink = StringBuffer(); @@ -86,13 +84,11 @@ void main() { NamedType( type: const TypeDeclaration(baseName: 'String', isNullable: true), - name: 'field1', - offset: null), + name: 'field1'), NamedType( type: const TypeDeclaration(baseName: 'Enum1', isNullable: true), - name: 'enum1', - offset: null), + name: 'enum1'), ], ), ], @@ -183,13 +179,11 @@ void main() { NamedType( type: const TypeDeclaration(baseName: 'String', isNullable: true), - name: 'field1', - offset: null), + name: 'field1'), NamedType( type: const TypeDeclaration(baseName: 'Enum1', isNullable: true), - name: 'enum1', - offset: null), + name: 'enum1'), ], ), ], @@ -218,8 +212,7 @@ void main() { NamedType( type: const TypeDeclaration( baseName: 'Input', isNullable: false), - name: '', - offset: null) + name: '') ], returnType: const TypeDeclaration(baseName: 'Output', isNullable: false)) @@ -228,14 +221,12 @@ void main() { Class(name: 'Input', fields: [ NamedType( type: const TypeDeclaration(baseName: 'String', isNullable: true), - name: 'input', - offset: null) + name: 'input') ]), Class(name: 'Output', fields: [ NamedType( type: const TypeDeclaration(baseName: 'String', isNullable: true), - name: 'output', - offset: null) + name: 'output') ]) ], enums: []); final StringBuffer sink = StringBuffer(); @@ -260,8 +251,7 @@ void main() { baseName: 'Input', isNullable: false, ), - name: '', - offset: null) + name: '') ], returnType: const TypeDeclaration(baseName: 'Output', isNullable: false)) @@ -270,14 +260,12 @@ void main() { Class(name: 'Input', fields: [ NamedType( type: const TypeDeclaration(baseName: 'String', isNullable: true), - name: 'input', - offset: null) + name: 'input') ]), Class(name: 'Output', fields: [ NamedType( type: const TypeDeclaration(baseName: 'String', isNullable: true), - name: 'output', - offset: null) + name: 'output') ]) ], enums: []); final StringBuffer sink = StringBuffer(); @@ -298,40 +286,32 @@ void main() { Class(name: 'Foobar', fields: [ NamedType( type: const TypeDeclaration(baseName: 'bool', isNullable: true), - name: 'aBool', - offset: null), + name: 'aBool'), NamedType( type: const TypeDeclaration(baseName: 'int', isNullable: true), - name: 'aInt', - offset: null), + name: 'aInt'), NamedType( type: const TypeDeclaration(baseName: 'double', isNullable: true), - name: 'aDouble', - offset: null), + name: 'aDouble'), NamedType( type: const TypeDeclaration(baseName: 'String', isNullable: true), - name: 'aString', - offset: null), + name: 'aString'), NamedType( type: const TypeDeclaration(baseName: 'Uint8List', isNullable: true), - name: 'aUint8List', - offset: null), + name: 'aUint8List'), NamedType( type: const TypeDeclaration(baseName: 'Int32List', isNullable: true), - name: 'aInt32List', - offset: null), + name: 'aInt32List'), NamedType( type: const TypeDeclaration(baseName: 'Int64List', isNullable: true), - name: 'aInt64List', - offset: null), + name: 'aInt64List'), NamedType( type: const TypeDeclaration( baseName: 'Float64List', isNullable: true), - name: 'aFloat64List', - offset: null), + name: 'aFloat64List'), ]), ], enums: []); @@ -359,8 +339,7 @@ void main() { Class(name: 'Foobar', fields: [ NamedType( type: const TypeDeclaration(baseName: 'bool', isNullable: true), - name: 'aBool', - offset: null), + name: 'aBool'), ]), ], enums: []); @@ -377,14 +356,12 @@ void main() { Class(name: 'Input', fields: [ NamedType( type: const TypeDeclaration(baseName: 'String', isNullable: true), - name: 'input', - offset: null) + name: 'input') ]), Class(name: 'Nested', fields: [ NamedType( type: const TypeDeclaration(baseName: 'Input', isNullable: true), - name: 'nested', - offset: null) + name: 'nested') ]) ], enums: []); final StringBuffer sink = StringBuffer(); @@ -399,14 +376,12 @@ void main() { Class(name: 'Input', fields: [ NamedType( type: const TypeDeclaration(baseName: 'String', isNullable: true), - name: 'input', - offset: null) + name: 'input') ]), Class(name: 'Nested', fields: [ NamedType( type: const TypeDeclaration(baseName: 'Input', isNullable: true), - name: 'nested', - offset: null) + name: 'nested') ]) ], enums: []); final StringBuffer sink = StringBuffer(); @@ -424,8 +399,7 @@ void main() { Class(name: 'Foobar', fields: [ NamedType( type: const TypeDeclaration(baseName: 'String', isNullable: true), - name: 'field1', - offset: null) + name: 'field1') ]), ], enums: []); final StringBuffer sink = StringBuffer(); @@ -439,8 +413,7 @@ void main() { Class(name: 'Foobar', fields: [ NamedType( type: const TypeDeclaration(baseName: 'String', isNullable: true), - name: 'field1', - offset: null) + name: 'field1') ]), ], enums: []); final StringBuffer sink = StringBuffer(); @@ -460,8 +433,7 @@ void main() { baseName: 'Input', isNullable: false, ), - name: '', - offset: null) + name: '') ], returnType: const TypeDeclaration(baseName: 'Nested', isNullable: false)) @@ -470,14 +442,12 @@ void main() { Class(name: 'Input', fields: [ NamedType( type: const TypeDeclaration(baseName: 'String', isNullable: true), - name: 'input', - offset: null) + name: 'input') ]), Class(name: 'Nested', fields: [ NamedType( type: const TypeDeclaration(baseName: 'Input', isNullable: true), - name: 'nested', - offset: null) + name: 'nested') ]) ], enums: []); final StringBuffer sink = StringBuffer(); @@ -499,8 +469,7 @@ void main() { baseName: 'Input', isNullable: false, ), - name: '', - offset: null) + name: '') ], returnType: const TypeDeclaration(baseName: 'Nested', isNullable: false)) @@ -509,14 +478,12 @@ void main() { Class(name: 'Input', fields: [ NamedType( type: const TypeDeclaration(baseName: 'String', isNullable: true), - name: 'input', - offset: null) + name: 'input') ]), Class(name: 'Nested', fields: [ NamedType( type: const TypeDeclaration(baseName: 'Input', isNullable: true), - name: 'nested', - offset: null) + name: 'nested') ]) ], enums: []); final StringBuffer sink = StringBuffer(); @@ -538,8 +505,7 @@ void main() { baseName: 'Input', isNullable: false, ), - name: '', - offset: null) + name: '') ], returnType: const TypeDeclaration(baseName: 'Output', isNullable: false)) @@ -548,14 +514,12 @@ void main() { Class(name: 'Input', fields: [ NamedType( type: const TypeDeclaration(baseName: 'String', isNullable: true), - name: 'input', - offset: null) + name: 'input') ]), Class(name: 'Output', fields: [ NamedType( type: const TypeDeclaration(baseName: 'String', isNullable: true), - name: 'output', - offset: null) + name: 'output') ]) ], enums: []); final StringBuffer sink = StringBuffer(); @@ -580,8 +544,7 @@ void main() { baseName: 'Input', isNullable: false, ), - name: '', - offset: null) + name: '') ], returnType: const TypeDeclaration(baseName: 'Output', isNullable: false)) @@ -590,14 +553,12 @@ void main() { Class(name: 'Input', fields: [ NamedType( type: const TypeDeclaration(baseName: 'String', isNullable: true), - name: 'input', - offset: null) + name: 'input') ]), Class(name: 'Output', fields: [ NamedType( type: const TypeDeclaration(baseName: 'String', isNullable: true), - name: 'output', - offset: null) + name: 'output') ]) ], enums: []); final StringBuffer sink = StringBuffer(); @@ -618,8 +579,7 @@ void main() { baseName: 'Input', isNullable: false, ), - name: '', - offset: null) + name: '') ], returnType: const TypeDeclaration.voidDeclaration()) ]) @@ -627,8 +587,7 @@ void main() { Class(name: 'Input', fields: [ NamedType( type: const TypeDeclaration(baseName: 'String', isNullable: true), - name: 'input', - offset: null) + name: 'input') ]), ], enums: []); final StringBuffer sink = StringBuffer(); @@ -649,8 +608,7 @@ void main() { baseName: 'Input', isNullable: false, ), - name: '', - offset: null) + name: '') ], returnType: const TypeDeclaration.voidDeclaration()) ]) @@ -658,8 +616,7 @@ void main() { Class(name: 'Input', fields: [ NamedType( type: const TypeDeclaration(baseName: 'String', isNullable: true), - name: 'input', - offset: null) + name: 'input') ]), ], enums: []); final StringBuffer sink = StringBuffer(); @@ -682,8 +639,7 @@ void main() { baseName: 'Input', isNullable: false, ), - name: '', - offset: null) + name: '') ], returnType: const TypeDeclaration.voidDeclaration()) ]) @@ -691,8 +647,7 @@ void main() { Class(name: 'Input', fields: [ NamedType( type: const TypeDeclaration(baseName: 'String', isNullable: true), - name: 'input', - offset: null) + name: 'input') ]), ], enums: []); final StringBuffer sink = StringBuffer(); @@ -713,8 +668,7 @@ void main() { baseName: 'Input', isNullable: false, ), - name: '', - offset: null) + name: '') ], returnType: const TypeDeclaration.voidDeclaration()) ]) @@ -722,8 +676,7 @@ void main() { Class(name: 'Input', fields: [ NamedType( type: const TypeDeclaration(baseName: 'String', isNullable: true), - name: 'input', - offset: null) + name: 'input') ]), ], enums: []); final StringBuffer sink = StringBuffer(); @@ -747,8 +700,7 @@ void main() { Class(name: 'Output', fields: [ NamedType( type: const TypeDeclaration(baseName: 'String', isNullable: true), - name: 'output', - offset: null) + name: 'output') ]), ], enums: []); final StringBuffer sink = StringBuffer(); @@ -771,8 +723,7 @@ void main() { Class(name: 'Output', fields: [ NamedType( type: const TypeDeclaration(baseName: 'String', isNullable: true), - name: 'output', - offset: null) + name: 'output') ]), ], enums: []); final StringBuffer sink = StringBuffer(); @@ -795,8 +746,7 @@ void main() { Class(name: 'Output', fields: [ NamedType( type: const TypeDeclaration(baseName: 'String', isNullable: true), - name: 'output', - offset: null) + name: 'output') ]), ], enums: []); final StringBuffer sink = StringBuffer(); @@ -822,8 +772,7 @@ void main() { Class(name: 'Output', fields: [ NamedType( type: const TypeDeclaration(baseName: 'String', isNullable: true), - name: 'output', - offset: null) + name: 'output') ]), ], enums: []); final StringBuffer sink = StringBuffer(); @@ -842,8 +791,7 @@ void main() { Class(name: 'Foobar', fields: [ NamedType( type: const TypeDeclaration(baseName: 'List', isNullable: true), - name: 'field1', - offset: null) + name: 'field1') ]), ], enums: []); final StringBuffer sink = StringBuffer(); @@ -858,8 +806,7 @@ void main() { Class(name: 'Foobar', fields: [ NamedType( type: const TypeDeclaration(baseName: 'Map', isNullable: true), - name: 'field1', - offset: null) + name: 'field1') ]), ], enums: []); final StringBuffer sink = StringBuffer(); @@ -880,8 +827,7 @@ void main() { TypeDeclaration(baseName: 'String', isNullable: true), TypeDeclaration(baseName: 'Object', isNullable: true), ]), - name: 'field1', - offset: null) + name: 'field1') ]), ], enums: []); final StringBuffer sink = StringBuffer(); @@ -930,8 +876,7 @@ void main() { baseName: 'Input', isNullable: false, ), - name: 'input', - offset: null) + name: 'input') ], returnType: const TypeDeclaration.voidDeclaration(), isAsynchronous: true) @@ -940,14 +885,12 @@ void main() { Class(name: 'Input', fields: [ NamedType( type: const TypeDeclaration(baseName: 'String', isNullable: true), - name: 'input', - offset: null) + name: 'input') ]), Class(name: 'Output', fields: [ NamedType( type: const TypeDeclaration(baseName: 'String', isNullable: true), - name: 'output', - offset: null) + name: 'output') ]), ], enums: []); final StringBuffer sink = StringBuffer(); @@ -971,8 +914,7 @@ void main() { baseName: 'Input', isNullable: false, ), - name: 'input', - offset: null) + name: 'input') ], returnType: const TypeDeclaration(baseName: 'Output', isNullable: false), @@ -982,14 +924,12 @@ void main() { Class(name: 'Input', fields: [ NamedType( type: const TypeDeclaration(baseName: 'String', isNullable: true), - name: 'input', - offset: null) + name: 'input') ]), Class(name: 'Output', fields: [ NamedType( type: const TypeDeclaration(baseName: 'String', isNullable: true), - name: 'output', - offset: null) + name: 'output') ]), ], enums: []); final StringBuffer sink = StringBuffer(); @@ -1016,8 +956,7 @@ void main() { Class(name: 'Output', fields: [ NamedType( type: const TypeDeclaration(baseName: 'String', isNullable: true), - name: 'output', - offset: null) + name: 'output') ]), ], enums: []); final StringBuffer sink = StringBuffer(); @@ -1061,8 +1000,7 @@ void main() { baseName: 'Input', isNullable: false, ), - name: '', - offset: null) + name: '') ], returnType: const TypeDeclaration(baseName: 'Output', isNullable: false), @@ -1072,14 +1010,12 @@ void main() { Class(name: 'Input', fields: [ NamedType( type: const TypeDeclaration(baseName: 'String', isNullable: true), - name: 'input', - offset: null) + name: 'input') ]), Class(name: 'Output', fields: [ NamedType( type: const TypeDeclaration(baseName: 'String', isNullable: true), - name: 'output', - offset: null) + name: 'output') ]), ], enums: []); final StringBuffer sink = StringBuffer(); @@ -1103,8 +1039,7 @@ void main() { baseName: 'Input', isNullable: false, ), - name: 'foo', - offset: null) + name: 'foo') ], returnType: const TypeDeclaration.voidDeclaration(), isAsynchronous: true) @@ -1113,14 +1048,12 @@ void main() { Class(name: 'Input', fields: [ NamedType( type: const TypeDeclaration(baseName: 'String', isNullable: true), - name: 'input', - offset: null) + name: 'input') ]), Class(name: 'Output', fields: [ NamedType( type: const TypeDeclaration(baseName: 'String', isNullable: true), - name: 'output', - offset: null) + name: 'output') ]), ], enums: []); final StringBuffer sink = StringBuffer(); @@ -1167,8 +1100,7 @@ void main() { Class(name: 'Output', fields: [ NamedType( type: const TypeDeclaration(baseName: 'String', isNullable: true), - name: 'output', - offset: null) + name: 'output') ]), ], enums: []); final StringBuffer sink = StringBuffer(); @@ -1181,7 +1113,7 @@ void main() { '[api doSomethingWithCompletion:^(ABCOutput *_Nullable output, FlutterError *_Nullable error) {')); }); - Iterable _makeIterable(String string) sync* { + Iterable makeIterable(String string) sync* { yield string; } @@ -1192,7 +1124,7 @@ void main() { ObjcOptions( header: 'foo.h', prefix: 'ABC', - copyrightHeader: _makeIterable('hello world')), + copyrightHeader: makeIterable('hello world')), root, sink, ); @@ -1207,7 +1139,7 @@ void main() { ObjcOptions( header: 'foo.h', prefix: 'ABC', - copyrightHeader: _makeIterable('hello world')), + copyrightHeader: makeIterable('hello world')), root, sink, ); @@ -1226,8 +1158,7 @@ void main() { typeArguments: [ TypeDeclaration(baseName: 'int', isNullable: true) ]), - name: 'field1', - offset: null), + name: 'field1'), ], ); final Root root = Root( @@ -1257,8 +1188,7 @@ void main() { typeArguments: [ TypeDeclaration(baseName: 'int', isNullable: true) ]), - name: 'arg', - offset: null) + name: 'arg') ]) ]) ], @@ -1299,8 +1229,7 @@ void main() { typeArguments: [ TypeDeclaration(baseName: 'int', isNullable: true) ]), - name: 'arg', - offset: null) + name: 'arg') ]) ]) ], @@ -1344,8 +1273,7 @@ void main() { baseName: 'bool', isNullable: true) ]), ]), - name: 'arg', - offset: null) + name: 'arg') ]) ]) ], @@ -1448,7 +1376,6 @@ void main() { const TypeDeclaration(isNullable: false, baseName: 'int')), ], returnType: const TypeDeclaration(baseName: 'int', isNullable: false), - isAsynchronous: false, ) ]) ], classes: [], enums: []); @@ -1537,7 +1464,6 @@ void main() { const TypeDeclaration(isNullable: false, baseName: 'int')), ], returnType: const TypeDeclaration(baseName: 'int', isNullable: false), - isAsynchronous: false, ) ]) ], classes: [], enums: []); @@ -1567,7 +1493,7 @@ void main() { } }); - Root _getDivideRoot(ApiLocation location) => Root( + Root getDivideRoot(ApiLocation location) => Root( apis: [ Api(name: 'Api', location: location, methods: [ Method( @@ -1594,7 +1520,7 @@ void main() { ); test('host custom objc selector', () { - final Root divideRoot = _getDivideRoot(ApiLocation.host); + final Root divideRoot = getDivideRoot(ApiLocation.host); { final StringBuffer sink = StringBuffer(); generateObjcHeader( @@ -1612,7 +1538,7 @@ void main() { }); test('flutter custom objc selector', () { - final Root divideRoot = _getDivideRoot(ApiLocation.flutter); + final Root divideRoot = getDivideRoot(ApiLocation.flutter); { final StringBuffer sink = StringBuffer(); generateObjcHeader( @@ -1640,8 +1566,7 @@ void main() { Class(name: 'Foobar', fields: [ NamedType( type: const TypeDeclaration(baseName: 'String', isNullable: false), - name: 'field1', - offset: null) + name: 'field1') ]), ], enums: []); final StringBuffer sink = StringBuffer(); diff --git a/packages/pigeon/test/pigeon_lib_test.dart b/packages/pigeon/test/pigeon_lib_test.dart index da061d026b..6b28183d13 100644 --- a/packages/pigeon/test/pigeon_lib_test.dart +++ b/packages/pigeon/test/pigeon_lib_test.dart @@ -34,7 +34,7 @@ void main() { /// Creates a temporary file named [filename] then calls [callback] with a /// [File] representing that temporary directory. The file will be deleted /// after the [callback] is executed. - void _withTempFile(String filename, void Function(File) callback) { + void withTempFile(String filename, void Function(File) callback) { final Directory dir = Directory.systemTemp.createTempSync(); final String path = '${dir.path}/$filename'; final File file = File(path); @@ -46,10 +46,10 @@ void main() { } } - ParseResults _parseSource(String source) { + ParseResults parseSource(String source) { final Pigeon dartle = Pigeon.setup(); ParseResults? results; - _withTempFile('source.dart', (File file) { + withTempFile('source.dart', (File file) { file.writeAsStringSync(source); results = dartle.parseFile(file.path); }); @@ -142,7 +142,7 @@ abstract class Api1 { Output1 doit(Input1 input); } '''; - final ParseResults parseResult = _parseSource(code); + final ParseResults parseResult = parseSource(code); expect(parseResult.errors.length, equals(0)); final Root root = parseResult.root; expect(root.classes.length, equals(2)); @@ -189,7 +189,7 @@ abstract class Api { InvalidDatatype foo(); } '''; - final ParseResults results = _parseSource(source); + final ParseResults results = parseSource(source); expect(results.errors.length, 1); expect(results.errors[0].message, contains('InvalidDatatype')); expect(results.errors[0].message, contains('dynamic')); @@ -211,7 +211,7 @@ abstract class Api { ClassWithEnum foo(); } '''; - final ParseResults results = _parseSource(code); + final ParseResults results = parseSource(code); expect(results.errors.length, equals(0)); expect(results.root.classes.length, equals(1)); expect(results.root.classes[0].name, equals('ClassWithEnum')); @@ -237,7 +237,7 @@ abstract class ApiTwoMethods { Output1 method2(Input1 input); } '''; - final ParseResults results = _parseSource(code); + final ParseResults results = parseSource(code); expect(results.errors.length, 0); expect(results.root.apis.length, 1); expect(results.root.apis[0].methods.length, equals(2)); @@ -260,7 +260,7 @@ abstract class Api { Nested foo(); } '''; - final ParseResults results = _parseSource(code); + final ParseResults results = parseSource(code); expect(results.errors.length, equals(0)); expect(results.root.classes.length, equals(2)); final Class nested = @@ -285,7 +285,7 @@ abstract class AFlutterApi { Output1 doit(Input1 input); } '''; - final ParseResults results = _parseSource(code); + final ParseResults results = parseSource(code); expect(results.errors.length, equals(0)); expect(results.root.apis.length, equals(1)); expect(results.root.apis[0].name, equals('AFlutterApi')); @@ -303,7 +303,7 @@ abstract class VoidApi { void doit(Input1 input); } '''; - final ParseResults results = _parseSource(code); + final ParseResults results = parseSource(code); expect(results.errors.length, equals(0)); expect(results.root.apis.length, equals(1)); expect(results.root.apis[0].methods.length, equals(1)); @@ -322,7 +322,7 @@ abstract class VoidArgApi { Output1 doit(); } '''; - final ParseResults results = _parseSource(code); + final ParseResults results = parseSource(code); expect(results.errors.length, equals(0)); expect(results.root.apis.length, equals(1)); expect(results.root.apis[0].methods.length, equals(1)); @@ -343,7 +343,7 @@ abstract class ApiWithMockDartClass { Output1 doit(); } '''; - final ParseResults results = _parseSource(code); + final ParseResults results = parseSource(code); expect(results.errors.length, equals(0)); expect(results.root.apis.length, equals(1)); expect(results.root.apis[0].dartHostTestHandler, @@ -365,7 +365,7 @@ abstract class NestorApi { Nestor getit(); } '''; - final ParseResults results = _parseSource(code); + final ParseResults results = parseSource(code); expect(results.errors.length, 0); expect(results.root.apis.length, 1); final List classNames = @@ -473,7 +473,7 @@ abstract class NestedEnumApi { void method(NestedEnum3 foo); } '''; - final ParseResults parseResult = _parseSource(code); + final ParseResults parseResult = parseSource(code); expect(parseResult.errors.length, equals(0)); expect(parseResult.root.apis.length, 1); expect(parseResult.root.classes.length, 3); @@ -495,7 +495,7 @@ abstract class NotificationsHostApi { void doit(Foo foo); } '''; - final ParseResults results = _parseSource(code); + final ParseResults results = parseSource(code); expect(results.errors.length, 0); expect(results.root.classes.length, 2); final Class foo = @@ -506,7 +506,7 @@ abstract class NotificationsHostApi { test('test compilation error', () { const String code = 'Hello\n'; - final ParseResults results = _parseSource(code); + final ParseResults results = parseSource(code); expect(results.errors.length, greaterThanOrEqualTo(1)); expect(results.errors[0].lineNumber, 1); }); @@ -523,7 +523,7 @@ abstract class Api { Foo doit(Foo foo); } '''; - final ParseResults results = _parseSource(code); + final ParseResults results = parseSource(code); expect(results.errors.length, 1); expect(results.errors[0].lineNumber, 3); expect(results.errors[0].message, contains('Method')); @@ -540,7 +540,7 @@ abstract class Api { Foo doit(Foo foo); } '''; - final ParseResults results = _parseSource(code); + final ParseResults results = parseSource(code); expect(results.errors.length, 1); expect(results.errors[0].lineNumber, 2); expect(results.errors[0].message, contains('Initialization')); @@ -558,7 +558,7 @@ abstract class Api { Foo doit(Foo foo); } '''; - final ParseResults results = _parseSource(code); + final ParseResults results = parseSource(code); expect(results.errors.length, 1); expect(results.errors[0].lineNumber, 7); expect(results.errors[0].message, contains('Field')); @@ -576,7 +576,7 @@ abstract class Api { Foo doit(Foo foo); } '''; - final ParseResults results = _parseSource(code); + final ParseResults results = parseSource(code); expect(results.errors.length, 0); }); @@ -592,7 +592,7 @@ abstract class Api { Foo doit(Foo foo); } '''; - final ParseResults results = _parseSource(code); + final ParseResults results = parseSource(code); expect(results.errors.length, 1); expect(results.errors[0].lineNumber, 3); expect(results.errors[0].message, contains('Constructor')); @@ -610,7 +610,7 @@ abstract class Api { Foo doit(Foo foo); } '''; - final ParseResults results = _parseSource(code); + final ParseResults results = parseSource(code); expect(results.errors.length, 1); expect(results.errors[0].lineNumber, 3); expect(results.errors[0].message, contains('Constructor')); @@ -628,22 +628,22 @@ abstract class Api { Foo doit(Foo foo); } '''; - final ParseResults results = _parseSource(code); + final ParseResults results = parseSource(code); expect(results.errors.length, 1); expect(results.errors[0].lineNumber, 7); expect(results.errors[0].message, contains('Constructor')); }); test('test invalid import', () { - const String code = 'import \'foo.dart\';\n'; - final ParseResults results = _parseSource(code); + const String code = "import 'foo.dart';\n"; + final ParseResults results = parseSource(code); expect(results.errors.length, greaterThanOrEqualTo(1)); expect(results.errors[0].lineNumber, 1); }); test('test valid import', () { - const String code = 'import \'package:pigeon/pigeon.dart\';\n'; - final ParseResults parseResults = _parseSource(code); + const String code = "import 'package:pigeon/pigeon.dart';\n"; + final ParseResults parseResults = parseSource(code); expect(parseResults.errors.length, 0); }); @@ -659,7 +659,7 @@ abstract class WithStaticFieldApi { void doit(WithStaticField withTemplate); } '''; - final ParseResults parseResult = _parseSource(code); + final ParseResults parseResult = parseSource(code); expect(parseResult.errors.length, equals(1)); expect(parseResult.errors[0].message, contains('static field')); expect(parseResult.errors[0].lineNumber, isNotNull); @@ -676,7 +676,7 @@ abstract class Api { void doit(Foo foo); } '''; - final ParseResults parseResult = _parseSource(code); + final ParseResults parseResult = parseSource(code); expect(parseResult.errors.length, equals(0)); final NamedType field = parseResult.root.classes[0].fields[0]; expect(field.type.typeArguments.length, 1); @@ -694,7 +694,7 @@ abstract class Api { void doit(Foo foo); } '''; - final ParseResults parseResult = _parseSource(code); + final ParseResults parseResult = parseSource(code); expect(parseResult.errors.length, equals(0)); final NamedType field = parseResult.root.classes[0].fields[0]; expect(field.type.typeArguments.length, 1); @@ -713,7 +713,7 @@ abstract class Api { void doit(Foo foo); } '''; - final ParseResults parseResult = _parseSource(code); + final ParseResults parseResult = parseSource(code); expect(parseResult.errors.length, equals(1)); expect(parseResult.errors[0].message, contains('Generic type arguments must be nullable')); @@ -733,7 +733,7 @@ abstract class Api { void doit(Foo foo); } '''; - final ParseResults parseResult = _parseSource(code); + final ParseResults parseResult = parseSource(code); expect(parseResult.errors.length, equals(0)); }); @@ -751,7 +751,7 @@ abstract class Api { void doit(Foo foo); } '''; - final ParseResults parseResult = _parseSource(code); + final ParseResults parseResult = parseSource(code); expect(parseResult.errors.length, equals(1)); expect(parseResult.errors[0].message, contains('Enums')); }); @@ -770,7 +770,7 @@ abstract class Api { Foo doit(); } '''; - final ParseResults parseResult = _parseSource(code); + final ParseResults parseResult = parseSource(code); expect(parseResult.errors.length, equals(1)); expect(parseResult.errors[0].message, contains('Enums')); }); @@ -782,7 +782,7 @@ abstract class Api { List doit(); } '''; - final ParseResults parseResult = _parseSource(code); + final ParseResults parseResult = parseSource(code); expect(parseResult.root.apis[0].methods[0].returnType.baseName, 'List'); expect( parseResult @@ -801,7 +801,7 @@ abstract class Api { void doit(int x, List value); } '''; - final ParseResults parseResult = _parseSource(code); + final ParseResults parseResult = parseSource(code); expect( parseResult.root.apis[0].methods[0].arguments[1].type.baseName, 'List'); expect( @@ -825,7 +825,7 @@ abstract class Api { void doit(Foo foo); } '''; - final ParseResults parseResult = _parseSource(code); + final ParseResults parseResult = parseSource(code); final NamedType field = parseResult.root.classes[0].fields[0]; expect(field.type.typeArguments.length, 2); expect(field.type.typeArguments[0].baseName, 'String'); @@ -843,7 +843,7 @@ abstract class Api { void method(Input input1, Input input2); } '''; - final ParseResults results = _parseSource(code); + final ParseResults results = parseSource(code); expect(results.root.apis.length, 1); expect(results.root.apis[0].methods.length, equals(1)); expect(results.root.apis[0].methods[0].name, equals('method')); @@ -857,7 +857,7 @@ abstract class Api { void method(x); } '''; - final ParseResults results = _parseSource(code); + final ParseResults results = parseSource(code); expect(results.errors.length, 1); expect(results.errors[0].lineNumber, 3); expect(results.errors[0].message, @@ -872,7 +872,7 @@ abstract class Api { void subtract(int x, int y); } '''; - final ParseResults results = _parseSource(code); + final ParseResults results = parseSource(code); expect(results.errors.length, 0); expect(results.root.apis.length, 1); expect(results.root.apis[0].methods.length, equals(1)); @@ -888,7 +888,7 @@ abstract class Api { void subtract(int x, int y); } '''; - final ParseResults results = _parseSource(code); + final ParseResults results = parseSource(code); expect(results.errors.length, 1); expect(results.errors[0].lineNumber, 3); expect(results.errors[0].message, @@ -903,7 +903,7 @@ abstract class Api { void initialize(); } '''; - final ParseResults results = _parseSource(code); + final ParseResults results = parseSource(code); expect(results.errors.length, 0); expect(results.root.apis.length, 1); expect(results.root.apis[0].methods.length, equals(1)); @@ -934,7 +934,7 @@ abstract class Api { List grabAll(); } '''; - final ParseResults results = _parseSource(code); + final ParseResults results = parseSource(code); expect(results.errors.length, 0); expect(results.root.classes.length, 1); expect(results.root.classes[0].name, 'Foo'); @@ -951,7 +951,7 @@ abstract class Api { void storeAll(List foos); } '''; - final ParseResults results = _parseSource(code); + final ParseResults results = parseSource(code); expect(results.errors.length, 0); expect(results.root.classes.length, 1); expect(results.root.classes[0].name, 'Foo'); @@ -973,7 +973,7 @@ abstract class Api { void storeAll(List foos); } '''; - final ParseResults results = _parseSource(code); + final ParseResults results = parseSource(code); expect(results.errors.length, 0); expect(results.root.classes.length, 2); expect( @@ -995,7 +995,7 @@ abstract class Api { void storeAll(List foos); } '''; - final ParseResults results = _parseSource(code); + final ParseResults results = parseSource(code); expect(results.errors.length, 1); expect(results.errors[0].lineNumber, 3); expect(results.errors[0].message, contains('Unknown type: Foo')); @@ -1008,7 +1008,7 @@ abstract class Api { void storeAll(List foos); } '''; - final ParseResults results = _parseSource(code); + final ParseResults results = parseSource(code); expect(results.errors.length, 0); }); @@ -1030,7 +1030,7 @@ abstract class HostApiBridge { void sendMessage(Message message); } '''; - final ParseResults results = _parseSource(code); + final ParseResults results = parseSource(code); expect(results.errors.length, 1); }); @@ -1052,7 +1052,7 @@ abstract class HostApiBridge { void sendMessage(Message message); } '''; - final ParseResults results = _parseSource(code); + final ParseResults results = parseSource(code); expect(results.root.enums.length, 1); expect(results.root.enums[0].name, 'MessageKey'); }); @@ -1067,7 +1067,7 @@ class Message { } '''; - final ParseResults results = _parseSource(code); + final ParseResults results = parseSource(code); final PigeonOptions options = PigeonOptions.fromMap(results.pigeonOptions!); expect(options.javaOptions!.copyrightHeader, ['A', 'Header']); }); @@ -1082,7 +1082,7 @@ class Message { } '''; - final ParseResults results = _parseSource(code); + final ParseResults results = parseSource(code); final PigeonOptions options = PigeonOptions.fromMap(results.pigeonOptions!); expect(options.dartOptions!.copyrightHeader, ['A', 'Header']); }); @@ -1097,7 +1097,7 @@ class Message { } '''; - final ParseResults results = _parseSource(code); + final ParseResults results = parseSource(code); final PigeonOptions options = PigeonOptions.fromMap(results.pigeonOptions!); expect(options.objcOptions!.copyrightHeader, ['A', 'Header']); }); @@ -1110,7 +1110,7 @@ abstract class Api { } '''; - final ParseResults results = _parseSource(code); + final ParseResults results = parseSource(code); expect(results.errors.length, 0); expect(results.root.apis[0].methods[0].returnType.isNullable, isTrue); }); @@ -1122,7 +1122,7 @@ abstract class Api { void calc(int? value); } '''; - final ParseResults results = _parseSource(code); + final ParseResults results = parseSource(code); expect(results.errors.length, 0); expect( results.root.apis[0].methods[0].arguments[0].type.isNullable, isTrue); @@ -1137,7 +1137,7 @@ abstract class Api { } '''; - final ParseResults results = _parseSource(code); + final ParseResults results = parseSource(code); expect(results.errors.length, 0); expect(results.root.apis[0].methods[0].taskQueueType, equals(TaskQueueType.serialBackgroundThread)); @@ -1151,7 +1151,7 @@ abstract class Api { } '''; - final ParseResults results = _parseSource(code); + final ParseResults results = parseSource(code); expect(results.errors.length, 0); expect(results.root.apis[0].methods[0].taskQueueType, equals(TaskQueueType.serial)); @@ -1166,7 +1166,7 @@ abstract class Api { } '''; - final ParseResults results = _parseSource(code); + final ParseResults results = parseSource(code); expect(results.errors.length, 1); expect(results.errors[0].message, contains('Unsupported TaskQueue specification')); @@ -1174,7 +1174,7 @@ abstract class Api { test('generator validation', () async { final Completer completer = Completer(); - _withTempFile('foo.dart', (File input) async { + withTempFile('foo.dart', (File input) async { final _ValidatorGenerator generator = _ValidatorGenerator(stdout); final int result = await Pigeon.run(['--input', input.path], generators: [generator]); @@ -1187,7 +1187,7 @@ abstract class Api { test('generator validation skipped', () async { final Completer completer = Completer(); - _withTempFile('foo.dart', (File input) async { + withTempFile('foo.dart', (File input) async { final _ValidatorGenerator generator = _ValidatorGenerator(null); final int result = await Pigeon.run( ['--input', input.path, '--dart_out', 'foo.dart'], diff --git a/packages/pigeon/test/swift_generator_test.dart b/packages/pigeon/test/swift_generator_test.dart index 436d291ed6..319054f3e6 100644 --- a/packages/pigeon/test/swift_generator_test.dart +++ b/packages/pigeon/test/swift_generator_test.dart @@ -16,8 +16,7 @@ void main() { baseName: 'int', isNullable: true, ), - name: 'field1', - offset: null), + name: 'field1'), ], ); final Root root = Root( @@ -93,12 +92,10 @@ void main() { baseName: 'Input', isNullable: false, ), - name: '', - offset: null) + name: '') ], returnType: const TypeDeclaration(baseName: 'Output', isNullable: false), - isAsynchronous: false, ) ]) ], classes: [ @@ -108,8 +105,7 @@ void main() { baseName: 'String', isNullable: true, ), - name: 'input', - offset: null) + name: 'input') ]), Class(name: 'Output', fields: [ NamedType( @@ -117,8 +113,7 @@ void main() { baseName: 'String', isNullable: true, ), - name: 'output', - offset: null) + name: 'output') ]) ], enums: []); final StringBuffer sink = StringBuffer(); @@ -138,57 +133,49 @@ void main() { baseName: 'bool', isNullable: true, ), - name: 'aBool', - offset: null), + name: 'aBool'), NamedType( type: const TypeDeclaration( baseName: 'int', isNullable: true, ), - name: 'aInt', - offset: null), + name: 'aInt'), NamedType( type: const TypeDeclaration( baseName: 'double', isNullable: true, ), - name: 'aDouble', - offset: null), + name: 'aDouble'), NamedType( type: const TypeDeclaration( baseName: 'String', isNullable: true, ), - name: 'aString', - offset: null), + name: 'aString'), NamedType( type: const TypeDeclaration( baseName: 'Uint8List', isNullable: true, ), - name: 'aUint8List', - offset: null), + name: 'aUint8List'), NamedType( type: const TypeDeclaration( baseName: 'Int32List', isNullable: true, ), - name: 'aInt32List', - offset: null), + name: 'aInt32List'), NamedType( type: const TypeDeclaration( baseName: 'Int64List', isNullable: true, ), - name: 'aInt64List', - offset: null), + name: 'aInt64List'), NamedType( type: const TypeDeclaration( baseName: 'Float64List', isNullable: true, ), - name: 'aFloat64List', - offset: null), + name: 'aFloat64List'), ]), ], enums: []); @@ -217,12 +204,10 @@ void main() { baseName: 'Input', isNullable: false, ), - name: '', - offset: null) + name: '') ], returnType: const TypeDeclaration(baseName: 'Output', isNullable: false), - isAsynchronous: false, ) ]) ], classes: [ @@ -232,8 +217,7 @@ void main() { baseName: 'String', isNullable: true, ), - name: 'input', - offset: null) + name: 'input') ]), Class(name: 'Output', fields: [ NamedType( @@ -241,8 +225,7 @@ void main() { baseName: 'String', isNullable: true, ), - name: 'output', - offset: null) + name: 'output') ]) ], enums: []); final StringBuffer sink = StringBuffer(); @@ -265,11 +248,9 @@ void main() { baseName: 'Input', isNullable: false, ), - name: '', - offset: null) + name: '') ], returnType: const TypeDeclaration.voidDeclaration(), - isAsynchronous: false, ) ]) ], classes: [ @@ -279,8 +260,7 @@ void main() { baseName: 'String', isNullable: true, ), - name: 'input', - offset: null) + name: 'input') ]), ], enums: []); final StringBuffer sink = StringBuffer(); @@ -302,11 +282,9 @@ void main() { baseName: 'Input', isNullable: false, ), - name: '', - offset: null) + name: '') ], returnType: const TypeDeclaration.voidDeclaration(), - isAsynchronous: false, ) ]) ], classes: [ @@ -316,8 +294,7 @@ void main() { baseName: 'String', isNullable: true, ), - name: 'input', - offset: null) + name: 'input') ]), ], enums: []); final StringBuffer sink = StringBuffer(); @@ -336,7 +313,6 @@ void main() { arguments: [], returnType: const TypeDeclaration(baseName: 'Output', isNullable: false), - isAsynchronous: false, ) ]) ], classes: [ @@ -346,8 +322,7 @@ void main() { baseName: 'String', isNullable: true, ), - name: 'output', - offset: null) + name: 'output') ]), ], enums: []); final StringBuffer sink = StringBuffer(); @@ -367,7 +342,6 @@ void main() { arguments: [], returnType: const TypeDeclaration(baseName: 'Output', isNullable: false), - isAsynchronous: false, ) ]) ], classes: [ @@ -377,8 +351,7 @@ void main() { baseName: 'String', isNullable: true, ), - name: 'output', - offset: null) + name: 'output') ]), ], enums: []); final StringBuffer sink = StringBuffer(); @@ -398,8 +371,7 @@ void main() { baseName: 'List', isNullable: true, ), - name: 'field1', - offset: null) + name: 'field1') ]), ], enums: []); final StringBuffer sink = StringBuffer(); @@ -418,8 +390,7 @@ void main() { baseName: 'Map', isNullable: true, ), - name: 'field1', - offset: null) + name: 'field1') ]), ], enums: []); final StringBuffer sink = StringBuffer(); @@ -439,8 +410,7 @@ void main() { baseName: 'Nested', isNullable: true, ), - name: 'nested', - offset: null) + name: 'nested') ], ); final Class nestedClass = Class( @@ -451,8 +421,7 @@ void main() { baseName: 'int', isNullable: true, ), - name: 'data', - offset: null) + name: 'data') ], ); final Root root = Root( @@ -484,8 +453,7 @@ void main() { baseName: 'Input', isNullable: false, ), - name: 'arg', - offset: null) + name: 'arg') ], returnType: const TypeDeclaration(baseName: 'Output', isNullable: false), @@ -499,8 +467,7 @@ void main() { baseName: 'String', isNullable: true, ), - name: 'input', - offset: null) + name: 'input') ]), Class(name: 'Output', fields: [ NamedType( @@ -508,8 +475,7 @@ void main() { baseName: 'String', isNullable: true, ), - name: 'output', - offset: null) + name: 'output') ]) ], enums: []); final StringBuffer sink = StringBuffer(); @@ -532,8 +498,7 @@ void main() { baseName: 'Input', isNullable: false, ), - name: '', - offset: null) + name: '') ], returnType: const TypeDeclaration(baseName: 'Output', isNullable: false), @@ -547,8 +512,7 @@ void main() { baseName: 'String', isNullable: true, ), - name: 'input', - offset: null) + name: 'input') ]), Class(name: 'Output', fields: [ NamedType( @@ -556,8 +520,7 @@ void main() { baseName: 'String', isNullable: true, ), - name: 'output', - offset: null) + name: 'output') ]) ], enums: []); final StringBuffer sink = StringBuffer(); @@ -584,8 +547,7 @@ void main() { baseName: 'Enum1', isNullable: true, ), - name: 'enum1', - offset: null), + name: 'enum1'), ], ); final Root root = Root( @@ -602,7 +564,7 @@ void main() { expect(code, contains('case two = 1')); }); - Iterable _makeIterable(String string) sync* { + Iterable makeIterable(String string) sync* { yield string; } @@ -610,7 +572,7 @@ void main() { final Root root = Root(apis: [], classes: [], enums: []); final StringBuffer sink = StringBuffer(); final SwiftOptions swiftOptions = SwiftOptions( - copyrightHeader: _makeIterable('hello world'), + copyrightHeader: makeIterable('hello world'), ); generateSwift(swiftOptions, root, sink); final String code = sink.toString(); @@ -628,8 +590,7 @@ void main() { typeArguments: [ TypeDeclaration(baseName: 'int', isNullable: true) ]), - name: 'field1', - offset: null), + name: 'field1'), ], ); final Root root = Root( @@ -657,8 +618,7 @@ void main() { TypeDeclaration(baseName: 'String', isNullable: true), TypeDeclaration(baseName: 'String', isNullable: true), ]), - name: 'field1', - offset: null), + name: 'field1'), ], ); final Root root = Root( @@ -689,8 +649,7 @@ void main() { typeArguments: [ TypeDeclaration(baseName: 'int', isNullable: true) ]), - name: 'arg', - offset: null) + name: 'arg') ]) ]) ], @@ -719,8 +678,7 @@ void main() { typeArguments: [ TypeDeclaration(baseName: 'int', isNullable: true) ]), - name: 'arg', - offset: null) + name: 'arg') ]) ]) ], @@ -805,7 +763,6 @@ void main() { const TypeDeclaration(isNullable: false, baseName: 'int')), ], returnType: const TypeDeclaration(baseName: 'int', isNullable: false), - isAsynchronous: false, ) ]) ], classes: [], enums: []); @@ -837,7 +794,6 @@ void main() { const TypeDeclaration(baseName: 'int', isNullable: false)), ], returnType: const TypeDeclaration(baseName: 'int', isNullable: false), - isAsynchronous: false, ) ]) ], classes: [], enums: []); @@ -970,11 +926,9 @@ void main() { baseName: 'Input', isNullable: false, ), - name: '', - offset: null) + name: '') ], returnType: const TypeDeclaration.voidDeclaration(), - isAsynchronous: false, ) ]) ], classes: [ @@ -984,8 +938,7 @@ void main() { baseName: 'String', isNullable: false, ), - name: 'input', - offset: null) + name: 'input') ]), ], enums: []); final StringBuffer sink = StringBuffer(); diff --git a/packages/pigeon/tool/run_tests.dart b/packages/pigeon/tool/run_tests.dart index 35d98518e5..cfb742b463 100644 --- a/packages/pigeon/tool/run_tests.dart +++ b/packages/pigeon/tool/run_tests.dart @@ -2,12 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// ignore_for_file: avoid_print + //////////////////////////////////////////////////////////////////////////////// /// Script for executing the Pigeon tests /// /// usage: dart run tool/run_tests.dart //////////////////////////////////////////////////////////////////////////////// -import 'dart:io' show File, Process, Platform, exit, stderr, stdout; +import 'dart:io' show File, Platform, Process, exit, stderr, stdout; import 'package:args/args.dart'; import 'package:meta/meta.dart'; import 'package:pigeon/functional.dart'; @@ -34,7 +36,7 @@ const Map _tests = { description: 'Compilation tests on generated Dart code.'), 'dart_unittests': _TestInfo( function: _runDartUnitTests, - description: 'Unit tests on and analysis on Pigeon\'s implementation.'), + description: "Unit tests on and analysis on Pigeon's implementation."), 'flutter_unittests': _TestInfo( function: _runFlutterUnitTests, description: 'Unit tests on generated Dart code.'), @@ -121,7 +123,6 @@ Future _analyzeFlutterUnitTests(String flutterUnitTestsPath) async { input: 'pigeons/message.dart', dartOut: messagePath, dartTestOut: messageTestPath, - streamOutput: true, ); if (generateTestCode != 0) { return generateTestCode; @@ -400,7 +401,7 @@ Future main(List args) async { print('available tests:'); for (final MapEntry info in _tests.entries) { final int tabCount = (4 - info.key.length / 8).toInt(); - final String tabs = repeat('\t', tabCount).join(''); + final String tabs = repeat('\t', tabCount).join(); print('${info.key}$tabs- ${info.value.description}'); } exit(0); diff --git a/packages/pointer_interceptor/CHANGELOG.md b/packages/pointer_interceptor/CHANGELOG.md index 642174c8bd..35f8291460 100644 --- a/packages/pointer_interceptor/CHANGELOG.md +++ b/packages/pointer_interceptor/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.9.3+3 + +* Fixes lint warnings. + ## 0.9.3+2 * (Temporarily) helps tests introduced in prior version to pass in `stable`. diff --git a/packages/pointer_interceptor/example/integration_test/widget_test.dart b/packages/pointer_interceptor/example/integration_test/widget_test.dart index aa7776568d..c8d5d6f52b 100644 --- a/packages/pointer_interceptor/example/integration_test/widget_test.dart +++ b/packages/pointer_interceptor/example/integration_test/widget_test.dart @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// ignore_for_file: avoid_print + import 'dart:html' as html; // Imports the Flutter Driver API. diff --git a/packages/pointer_interceptor/example/lib/main.dart b/packages/pointer_interceptor/example/lib/main.dart index b30ea010bf..9e759f339d 100644 --- a/packages/pointer_interceptor/example/lib/main.dart +++ b/packages/pointer_interceptor/example/lib/main.dart @@ -70,7 +70,7 @@ class MyHomePage extends StatefulWidget { const MyHomePage({Key? key}) : super(key: key); @override - _MyHomePageState createState() => _MyHomePageState(); + State createState() => _MyHomePageState(); } class _MyHomePageState extends State { @@ -205,7 +205,7 @@ class HtmlElement extends StatelessWidget { const HtmlElement({Key? key, required this.onClick}) : super(key: key); /// A function to run when the element is clicked - final Function onClick; + final VoidCallback onClick; @override Widget build(BuildContext context) { diff --git a/packages/pointer_interceptor/pubspec.yaml b/packages/pointer_interceptor/pubspec.yaml index e26e12b792..259b80ae49 100644 --- a/packages/pointer_interceptor/pubspec.yaml +++ b/packages/pointer_interceptor/pubspec.yaml @@ -2,7 +2,7 @@ name: pointer_interceptor description: A widget to prevent clicks from being swallowed by underlying HtmlElementViews on the web. repository: https://github.com/flutter/packages/tree/main/packages/pointer_interceptor issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+pointer_interceptor%22 -version: 0.9.3+2 +version: 0.9.3+3 environment: sdk: ">=2.12.0 <3.0.0" diff --git a/packages/pointer_interceptor/test/tests_exist_elsewhere_test.dart b/packages/pointer_interceptor/test/tests_exist_elsewhere_test.dart index 442c501447..cc32e6c72f 100644 --- a/packages/pointer_interceptor/test/tests_exist_elsewhere_test.dart +++ b/packages/pointer_interceptor/test/tests_exist_elsewhere_test.dart @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// ignore_for_file: avoid_print + import 'package:flutter_test/flutter_test.dart'; void main() { diff --git a/packages/rfw/CHANGELOG.md b/packages/rfw/CHANGELOG.md index c0a98f1851..2d1bddc70b 100644 --- a/packages/rfw/CHANGELOG.md +++ b/packages/rfw/CHANGELOG.md @@ -1,7 +1,8 @@ -## NEXT +## 1.0.6 * Temporarily lowers test coverage minimum to fix flutter roll. -* Disable golden testing due to https://github.com/flutter/flutter/issues/106205 +* Disables golden testing due to https://github.com/flutter/flutter/issues/106205. +* Fixes lint warnings. ## 1.0.5 diff --git a/packages/rfw/example/remote/lib/main.dart b/packages/rfw/example/remote/lib/main.dart index f1d5fbeb59..646423e002 100644 --- a/packages/rfw/example/remote/lib/main.dart +++ b/packages/rfw/example/remote/lib/main.dart @@ -65,7 +65,7 @@ class _ExampleState extends State { FlutterError.reportError(FlutterErrorDetails(exception: e, stack: stack)); } } - print('Fetching: $urlPrefix/$nextFile'); + print('Fetching: $urlPrefix/$nextFile'); // ignore: avoid_print final HttpClientResponse client = await (await HttpClient().getUrl(Uri.parse('$urlPrefix/$nextFile'))).close(); await currentFile.writeAsBytes(await client.expand((List chunk) => chunk).toList()); await settingsFile.writeAsString(nextFile); diff --git a/packages/rfw/example/wasm/lib/main.dart b/packages/rfw/example/wasm/lib/main.dart index a0dd80ad9d..181fb18518 100644 --- a/packages/rfw/example/wasm/lib/main.dart +++ b/packages/rfw/example/wasm/lib/main.dart @@ -71,15 +71,17 @@ class _ExampleState extends State { } List _asList(Object? value) { - if (value is List) + if (value is List) { return value; + } return const []; } @override Widget build(BuildContext context) { - if (!RendererBinding.instance.sendFramesToEngine) + if (!RendererBinding.instance.sendFramesToEngine) { return const SizedBox.shrink(); + } return RemoteWidget( runtime: _runtime, data: _data, diff --git a/packages/rfw/example/wasm/logic/encode.dart b/packages/rfw/example/wasm/logic/encode.dart index 610c0b6733..f4d16a7d2c 100644 --- a/packages/rfw/example/wasm/logic/encode.dart +++ b/packages/rfw/example/wasm/logic/encode.dart @@ -8,6 +8,7 @@ import 'package:rfw/formats.dart'; void main(List arguments) { if (arguments.length != 2) { + // ignore: avoid_print print('usage: dart encode.dart source.rfwtxt output.rfw'); exit(1); } diff --git a/packages/rfw/lib/src/flutter/core_widgets.dart b/packages/rfw/lib/src/flutter/core_widgets.dart index 26c4cbe3b8..0ff1b12269 100644 --- a/packages/rfw/lib/src/flutter/core_widgets.dart +++ b/packages/rfw/lib/src/flutter/core_widgets.dart @@ -248,8 +248,8 @@ Map get _coreWidgetsDefinitions => (['widthFactor']), heightFactor: source.v(['heightFactor']), - child: source.optionalChild(['child']), onEnd: source.voidHandler(['onEnd']), + child: source.optionalChild(['child']), ); }, @@ -302,9 +302,9 @@ Map get _coreWidgetsDefinitions => (Clip.values, source, ['clipBehavior']) ?? Clip.none, onEnd: source.voidHandler(['onEnd']), + child: source.optionalChild(['child']), ); }, @@ -319,8 +319,8 @@ Map get _coreWidgetsDefinitions => (['maxLines']), textWidthBasis: ArgumentDecoders.enumValue(TextWidthBasis.values, source, ['textWidthBasis']) ?? TextWidthBasis.parent, textHeightBehavior: ArgumentDecoders.textHeightBehavior(source, ['textHeightBehavior']), - child: source.child(['child']), onEnd: source.voidHandler(['onEnd']), + child: source.child(['child']), ); }, @@ -496,8 +496,8 @@ Map get _coreWidgetsDefinitions => get _coreWidgetsDefinitions => (['bottom']), width: source.v(['width']), height: source.v(['height']), - child: source.child(['child']), onEnd: source.voidHandler(['onEnd']), + child: source.child(['child']), ); }, @@ -532,8 +532,8 @@ Map get _coreWidgetsDefinitions => (['turns']) ?? 0.0, alignment: (ArgumentDecoders.alignment(source, ['alignment']) ?? Alignment.center).resolve(Directionality.of(context)), filterQuality: ArgumentDecoders.enumValue(FilterQuality.values, source, ['filterQuality']), - child: source.optionalChild(['child']), onEnd: source.voidHandler(['onEnd']), + child: source.optionalChild(['child']), ); }, @@ -568,8 +568,8 @@ Map get _coreWidgetsDefinitions => (['scale']) ?? 1.0, alignment: (ArgumentDecoders.alignment(source, ['alignment']) ?? Alignment.center).resolve(Directionality.of(context)), filterQuality: ArgumentDecoders.enumValue(FilterQuality.values, source, ['filterQuality']), - child: source.optionalChild(['child']), onEnd: source.voidHandler(['onEnd']), + child: source.optionalChild(['child']), ); }, @@ -579,13 +579,13 @@ Map get _coreWidgetsDefinitions => (['reverse']) ?? false, padding: ArgumentDecoders.edgeInsets(source, ['padding']), primary: source.v(['primary']) ?? true, - // ScrollPhysics? physics, - // ScrollController? controller, - child: source.optionalChild(['child']), dragStartBehavior: ArgumentDecoders.enumValue(DragStartBehavior.values, source, ['dragStartBehavior']) ?? DragStartBehavior.start, clipBehavior: ArgumentDecoders.enumValue(Clip.values, source, ['clipBehavior']) ?? Clip.hardEdge, restorationId: source.v(['restorationId']), keyboardDismissBehavior: ArgumentDecoders.enumValue(ScrollViewKeyboardDismissBehavior.values, source, ['keyboardDismissBehavior']) ?? ScrollViewKeyboardDismissBehavior.manual, + // ScrollPhysics? physics, + // ScrollController? controller, + child: source.optionalChild(['child']), ); }, diff --git a/packages/rfw/lib/src/flutter/material_widgets.dart b/packages/rfw/lib/src/flutter/material_widgets.dart index 382627edd6..00a721b2b7 100644 --- a/packages/rfw/lib/src/flutter/material_widgets.dart +++ b/packages/rfw/lib/src/flutter/material_widgets.dart @@ -81,13 +81,13 @@ Map get _materialWidgetsDefinitions => (['applicationName']), applicationVersion: source.v(['applicationVersion']), applicationIcon: source.optionalChild(['applicationIcon']), applicationLegalese: source.v(['applicationLegalese']), aboutBoxChildren: source.childList(['aboutBoxChildren']), dense: source.v(['dense']), + child: source.optionalChild(['child']), ); }, @@ -142,8 +142,8 @@ Map get _materialWidgetsDefinitions => (['borderOnForeground']) ?? true, margin: ArgumentDecoders.edgeInsets(source, ['margin']), clipBehavior: ArgumentDecoders.enumValue(Clip.values, source, ['clipBehavior']) ?? Clip.none, - child: source.optionalChild(['child']), semanticContainer: source.v(['semanticContainer']) ?? true, + child: source.optionalChild(['child']), ); }, @@ -202,7 +202,6 @@ Map get _materialWidgetsDefinitions => (['tooltip']), foregroundColor: ArgumentDecoders.color(source, ['foregroundColor']), backgroundColor: ArgumentDecoders.color(source, ['backgroundColor']), @@ -223,6 +222,7 @@ Map get _materialWidgetsDefinitions => (MaterialTapTargetSize.values, source, ['materialTapTargetSize']), isExtended: source.v(['isExtended']) ?? false, enableFeedback: source.v(['enableFeedback']), + child: source.child(['child']), ); }, diff --git a/packages/rfw/lib/src/flutter/remote_widget.dart b/packages/rfw/lib/src/flutter/remote_widget.dart index 7dd0d5c1df..83a571caf1 100644 --- a/packages/rfw/lib/src/flutter/remote_widget.dart +++ b/packages/rfw/lib/src/flutter/remote_widget.dart @@ -57,7 +57,7 @@ class RemoteWidget extends StatefulWidget { final RemoteEventHandler? onEvent; @override - _RemoteWidgetState createState() => _RemoteWidgetState(); + State createState() => _RemoteWidgetState(); } class _RemoteWidgetState extends State { diff --git a/packages/rfw/pubspec.yaml b/packages/rfw/pubspec.yaml index 6ac9778a37..577aabbb84 100644 --- a/packages/rfw/pubspec.yaml +++ b/packages/rfw/pubspec.yaml @@ -2,7 +2,7 @@ name: rfw description: "Remote Flutter widgets: a library for rendering declarative widget description files at runtime." repository: https://github.com/flutter/packages/tree/main/packages/rfw issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+rfw%22 -version: 1.0.5 +version: 1.0.6 environment: sdk: ">=2.13.0 <3.0.0" diff --git a/packages/rfw/test/binary_test.dart b/packages/rfw/test/binary_test.dart index de8921c78b..207f7060f4 100644 --- a/packages/rfw/test/binary_test.dart +++ b/packages/rfw/test/binary_test.dart @@ -450,7 +450,7 @@ void main() { expect(value.widgets, hasLength(1)); expect(value.widgets.first.name, 'a'); expect(value.widgets.first.initialState, isNotNull); - expect(value.widgets.first.initialState!, hasLength(1)); + expect(value.widgets.first.initialState, hasLength(1)); expect(value.widgets.first.initialState!['b'], false); expect(value.widgets.first.root, isA()); expect((value.widgets.first.root as ConstructorCall).name, 'c'); diff --git a/packages/rfw/test/core_widgets_test.dart b/packages/rfw/test/core_widgets_test.dart index 317c6180e7..8765e1315c 100644 --- a/packages/rfw/test/core_widgets_test.dart +++ b/packages/rfw/test/core_widgets_test.dart @@ -202,7 +202,7 @@ void main() { ); ''')); await tester.pump(); - expect(tester.getTopLeft(find.byType(SizedBox)), const Offset(0.0, 0.0)); + expect(tester.getTopLeft(find.byType(SizedBox)), Offset.zero); runtime.update(const LibraryName(['test']), parseLibraryFile(''' import core; diff --git a/packages/rfw/test/runtime_test.dart b/packages/rfw/test/runtime_test.dart index 0e3f4761cd..609b6e28da 100644 --- a/packages/rfw/test/runtime_test.dart +++ b/packages/rfw/test/runtime_test.dart @@ -4,6 +4,8 @@ // This file is hand-formatted. +// ignore_for_file: avoid_dynamic_calls + import 'dart:convert'; import 'dart:typed_data'; diff --git a/packages/rfw/test_coverage/bin/test_coverage.dart b/packages/rfw/test_coverage/bin/test_coverage.dart index 5ed9b1bda5..488da7c3f5 100644 --- a/packages/rfw/test_coverage/bin/test_coverage.dart +++ b/packages/rfw/test_coverage/bin/test_coverage.dart @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// ignore_for_file: avoid_print + import 'dart:io'; import 'package:lcov_parser/lcov_parser.dart' as lcov; diff --git a/packages/standard_message_codec/CHANGELOG.md b/packages/standard_message_codec/CHANGELOG.md index d1108d5e79..e3a9a0a86c 100644 --- a/packages/standard_message_codec/CHANGELOG.md +++ b/packages/standard_message_codec/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.0.1+2 + +* Fixes lint warnings. + ## 0.0.1+1 * Fixes minimum version of `test` dependency. diff --git a/packages/standard_message_codec/example/lib/readme_excerpts.dart b/packages/standard_message_codec/example/lib/readme_excerpts.dart index f2d44121e9..ea70bc2ffd 100644 --- a/packages/standard_message_codec/example/lib/readme_excerpts.dart +++ b/packages/standard_message_codec/example/lib/readme_excerpts.dart @@ -5,6 +5,8 @@ // This file exists solely to host compiled excerpts for README.md, and is not // intended for use as an actual example application. +// ignore_for_file: avoid_print + // #docregion Encoding import 'dart:typed_data'; import 'package:standard_message_codec/standard_message_codec.dart'; diff --git a/packages/standard_message_codec/lib/standard_message_codec.dart b/packages/standard_message_codec/lib/standard_message_codec.dart index 3ecddf4893..cdb70feef5 100644 --- a/packages/standard_message_codec/lib/standard_message_codec.dart +++ b/packages/standard_message_codec/lib/standard_message_codec.dart @@ -230,8 +230,8 @@ class StandardMessageCodec implements MessageCodec { // decoding because we use tags to detect the type of value. buffer.putUint8(_valueFloat64); buffer.putFloat64(value); - } else if (value is int) { // ignore: avoid_double_and_int_checks, JS code always goes through the `double` path above + } else if (value is int) { if (-0x7fffffff - 1 <= value && value <= 0x7fffffff) { buffer.putUint8(_valueInt32); buffer.putInt32(value); diff --git a/packages/standard_message_codec/pubspec.yaml b/packages/standard_message_codec/pubspec.yaml index dccca1f89b..235f502309 100644 --- a/packages/standard_message_codec/pubspec.yaml +++ b/packages/standard_message_codec/pubspec.yaml @@ -1,6 +1,6 @@ name: standard_message_codec description: An efficient and schemaless binary encoding format for Flutter and Dart. -version: 0.0.1+1 +version: 0.0.1+2 repository: https://github.com/flutter/packages/tree/main/packages/standard_message_codec issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3Astandard_message_codec diff --git a/packages/web_benchmarks/CHANGELOG.md b/packages/web_benchmarks/CHANGELOG.md index 13e6cfdf94..d7edff7a13 100644 --- a/packages/web_benchmarks/CHANGELOG.md +++ b/packages/web_benchmarks/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.1.0+1 + +* Fixes lint warnings. + ## 0.1.0 * Migrates to null safety. diff --git a/packages/web_benchmarks/lib/client.dart b/packages/web_benchmarks/lib/client.dart index ae0c453b11..6676dc8f6b 100644 --- a/packages/web_benchmarks/lib/client.dart +++ b/packages/web_benchmarks/lib/client.dart @@ -73,7 +73,7 @@ Future _runBenchmark(String? benchmarkName) async { await _client.sendProfileData(profile); } else { _printResultsToScreen(profile); - print(profile); + print(profile); // ignore: avoid_print } }, zoneSpecification: ZoneSpecification( @@ -133,14 +133,14 @@ void _fallbackToManual(String error) { /// Visualizes results on the Web page for manual inspection. void _printResultsToScreen(Profile profile) { - final html.BodyElement _body = html.document.body!; + final html.BodyElement body = html.document.body!; - _body.innerHtml = '

${profile.name}

'; + body.innerHtml = '

${profile.name}

'; profile.scoreData.forEach((String scoreKey, Timeseries timeseries) { - _body.appendHtml('

$scoreKey

'); - _body.appendHtml('
${timeseries.computeStats()}
'); - _body.append(TimeseriesVisualization(timeseries).render()); + body.appendHtml('

$scoreKey

'); + body.appendHtml('
${timeseries.computeStats()}
'); + body.append(TimeseriesVisualization(timeseries).render()); }); } diff --git a/packages/web_benchmarks/lib/src/browser.dart b/packages/web_benchmarks/lib/src/browser.dart index b6b9cf5e88..52b31d69f9 100644 --- a/packages/web_benchmarks/lib/src/browser.dart +++ b/packages/web_benchmarks/lib/src/browser.dart @@ -2,8 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// ignore_for_file: avoid_print, avoid_dynamic_calls + import 'dart:async'; -import 'dart:convert' show json, utf8, LineSplitter, JsonEncoder; +import 'dart:convert' show JsonEncoder, LineSplitter, json, utf8; import 'dart:io' as io; import 'dart:math' as math; @@ -327,7 +329,7 @@ class BlinkTraceSummary { Exception noMeasuredFramesFound() => Exception( 'No measured frames found in benchmark tracing data. This likely ' 'indicates a bug in the benchmark. For example, the benchmark failed ' - 'to pump enough frames. It may also indicate a change in Chrome\'s ' + "to pump enough frames. It may also indicate a change in Chrome's " 'tracing data format. Check if Chrome version changed recently and ' 'adjust the parsing code accordingly.', ); @@ -396,7 +398,7 @@ class BlinkTraceSummary { .whereType() .toList()), ); - } catch (_, __) { + } catch (_) { final io.File traceFile = io.File('./chrome-trace.json'); io.stderr.writeln( 'Failed to interpret the Chrome trace contents. The trace was saved in ${traceFile.path}'); @@ -454,11 +456,11 @@ Duration _computeAverageDuration(List events) { final double sum = events .skip(math.max(events.length - kMeasuredSampleCount, 0)) .fold(0.0, (double previousValue, BlinkTraceEvent event) { - final int? _threadClockDuration = event.tdur; - if (_threadClockDuration == null) { + final int? threadClockDuration = event.tdur; + if (threadClockDuration == null) { throw FormatException('Trace event lacks "tdur" field: $event'); } - return previousValue + _threadClockDuration; + return previousValue + threadClockDuration; }); final int sampleCount = math.min(events.length, kMeasuredSampleCount); return Duration(microseconds: sum ~/ sampleCount); @@ -614,7 +616,7 @@ int? _readInt(Map json, String key) { final num? jsonValue = json[key]; if (jsonValue == null) { - return null; + return null; // ignore: avoid_returning_null } return jsonValue.toInt(); diff --git a/packages/web_benchmarks/lib/src/runner.dart b/packages/web_benchmarks/lib/src/runner.dart index 3c9dd7222e..68c09f873a 100644 --- a/packages/web_benchmarks/lib/src/runner.dart +++ b/packages/web_benchmarks/lib/src/runner.dart @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// ignore_for_file: avoid_print + import 'dart:async'; import 'dart:convert' show json; import 'dart:io' as io; @@ -89,7 +91,7 @@ class BenchmarkServer { if (!_processManager.canRun('flutter')) { throw Exception( - 'flutter executable is not runnable. Make sure it\'s in the PATH.'); + "flutter executable is not runnable. Make sure it's in the PATH."); } final io.ProcessResult buildResult = await _processManager.run( @@ -160,7 +162,7 @@ class BenchmarkServer { traceSummary?.averageTotalUIFrameTime.inMicroseconds; profile['scoreKeys'] ??= []; // using dynamic for consistency with JSON - profile['scoreKeys'].add('totalUiFrame.average'); + (profile['scoreKeys'] as List).add('totalUiFrame.average'); latestPerformanceTrace = null; } collectedProfiles.add(profile); @@ -191,7 +193,8 @@ class BenchmarkServer { } else if (request.requestedUri.path.endsWith('/next-benchmark')) { if (benchmarks == null) { benchmarks = - (json.decode(await request.readAsString())).cast(); + (json.decode(await request.readAsString()) as List) + .cast(); benchmarkIterator = benchmarks!.iterator; } if (benchmarkIterator.moveNext()) { @@ -244,8 +247,6 @@ class BenchmarkServer { final ChromeOptions options = ChromeOptions( url: 'http://localhost:$benchmarkServerPort/index.html', userDataDirectory: userDataDir, - windowHeight: 1024, - windowWidth: 1024, headless: headless, debugPort: chromeDebugPort, ); @@ -272,17 +273,18 @@ class BenchmarkServer { for (final Map profile in profiles) { final String benchmarkName = profile['name']; if (benchmarkName.isEmpty) { - throw 'Benchmark name is empty'; + throw StateError('Benchmark name is empty'); } final List scoreKeys = List.from(profile['scoreKeys']); if (scoreKeys == null || scoreKeys.isEmpty) { - throw 'No score keys in benchmark "$benchmarkName"'; + throw StateError('No score keys in benchmark "$benchmarkName"'); } for (final String scoreKey in scoreKeys) { if (scoreKey == null || scoreKey.isEmpty) { - throw 'Score key is empty in benchmark "$benchmarkName". ' - 'Received [${scoreKeys.join(', ')}]'; + throw StateError( + 'Score key is empty in benchmark "$benchmarkName". ' + 'Received [${scoreKeys.join(', ')}]'); } } diff --git a/packages/web_benchmarks/pubspec.yaml b/packages/web_benchmarks/pubspec.yaml index b82a743249..459a2a6442 100644 --- a/packages/web_benchmarks/pubspec.yaml +++ b/packages/web_benchmarks/pubspec.yaml @@ -2,7 +2,7 @@ name: web_benchmarks description: A benchmark harness for performance-testing Flutter apps in Chrome. repository: https://github.com/flutter/packages/tree/main/packages/web_benchmarks issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+web_benchmarks%22 -version: 0.1.0 +version: 0.1.0+1 environment: sdk: '>=2.17.0 <3.0.0' diff --git a/packages/web_benchmarks/test/more_tests_in_testing_dir_test.dart b/packages/web_benchmarks/test/more_tests_in_testing_dir_test.dart index d7c658c63b..53387e1964 100644 --- a/packages/web_benchmarks/test/more_tests_in_testing_dir_test.dart +++ b/packages/web_benchmarks/test/more_tests_in_testing_dir_test.dart @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// ignore_for_file: avoid_print + import 'package:flutter_test/flutter_test.dart'; void main() { diff --git a/packages/web_benchmarks/testing/test_app/lib/aboutpage.dart b/packages/web_benchmarks/testing/test_app/lib/aboutpage.dart index ebe52713e3..4147c33f8f 100644 --- a/packages/web_benchmarks/testing/test_app/lib/aboutpage.dart +++ b/packages/web_benchmarks/testing/test_app/lib/aboutpage.dart @@ -7,7 +7,7 @@ import 'package:flutter/material.dart'; const ValueKey backKey = ValueKey('backKey'); class AboutPage extends StatelessWidget { - const AboutPage({Key? key}) : super(key: key); + const AboutPage({super.key}); @override Widget build(BuildContext context) { diff --git a/packages/web_benchmarks/testing/test_app/lib/benchmarks/runner.dart b/packages/web_benchmarks/testing/test_app/lib/benchmarks/runner.dart index c8f340ecc7..9d3a59dde4 100644 --- a/packages/web_benchmarks/testing/test_app/lib/benchmarks/runner.dart +++ b/packages/web_benchmarks/testing/test_app/lib/benchmarks/runner.dart @@ -2,12 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// ignore_for_file: avoid_print + import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:web_benchmarks/client.dart'; import '../aboutpage.dart' show backKey; -import '../homepage.dart' show textKey, aboutPageKey; +import '../homepage.dart' show aboutPageKey, textKey; import '../main.dart'; /// A recorder that measures frame building durations. diff --git a/packages/web_benchmarks/testing/test_app/lib/homepage.dart b/packages/web_benchmarks/testing/test_app/lib/homepage.dart index 734371313b..dee8c9d0ee 100644 --- a/packages/web_benchmarks/testing/test_app/lib/homepage.dart +++ b/packages/web_benchmarks/testing/test_app/lib/homepage.dart @@ -8,12 +8,12 @@ const ValueKey textKey = ValueKey('textKey'); const ValueKey aboutPageKey = ValueKey('aboutPageKey'); class HomePage extends StatefulWidget { - const HomePage({Key? key, required this.title}) : super(key: key); + const HomePage({super.key, required this.title}); final String title; @override - _HomePageState createState() => _HomePageState(); + State createState() => _HomePageState(); } class _HomePageState extends State { @@ -63,7 +63,6 @@ class _HomePageState extends State { elevation: 8, child: Row( mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, children: [ Text( 'Line $index', diff --git a/packages/web_benchmarks/testing/test_app/lib/main.dart b/packages/web_benchmarks/testing/test_app/lib/main.dart index 8607bf328b..5621621e21 100644 --- a/packages/web_benchmarks/testing/test_app/lib/main.dart +++ b/packages/web_benchmarks/testing/test_app/lib/main.dart @@ -12,7 +12,7 @@ void main() { } class MyApp extends StatelessWidget { - const MyApp({Key? key}) : super(key: key); + const MyApp({super.key}); @override Widget build(BuildContext context) { diff --git a/packages/web_benchmarks/testing/test_app/pubspec.yaml b/packages/web_benchmarks/testing/test_app/pubspec.yaml index 3a124baa95..eb671395eb 100644 --- a/packages/web_benchmarks/testing/test_app/pubspec.yaml +++ b/packages/web_benchmarks/testing/test_app/pubspec.yaml @@ -12,12 +12,10 @@ dependencies: cupertino_icons: ^0.1.3 flutter: sdk: flutter + flutter_test: + sdk: flutter web_benchmarks: path: ../../ -dev_dependencies: - flutter_test: - sdk: flutter - flutter: uses-material-design: true diff --git a/packages/xdg_directories/CHANGELOG.md b/packages/xdg_directories/CHANGELOG.md index ced4c1a031..ec5bb29f53 100644 --- a/packages/xdg_directories/CHANGELOG.md +++ b/packages/xdg_directories/CHANGELOG.md @@ -1,6 +1,7 @@ -## NEXT +## 0.2.0+2 * Fixes unit tests on Windows. +* Fixes lint warnings. ## 0.2.0+1 diff --git a/packages/xdg_directories/lib/xdg_directories.dart b/packages/xdg_directories/lib/xdg_directories.dart index c5ae57f0ee..2192153090 100644 --- a/packages/xdg_directories/lib/xdg_directories.dart +++ b/packages/xdg_directories/lib/xdg_directories.dart @@ -152,7 +152,6 @@ Directory? get runtimeDir => _directoryFromEnvironment('XDG_RUNTIME_DIR'); Directory? getUserDirectory(String dirName) { final ProcessResult result = _processManager.runSync( ['xdg-user-dir', dirName], - includeParentEnvironment: true, stdoutEncoding: utf8, ); final String path = (result.stdout as String).split('\n')[0]; diff --git a/packages/xdg_directories/pubspec.yaml b/packages/xdg_directories/pubspec.yaml index 11b01bd97e..8edfad111f 100644 --- a/packages/xdg_directories/pubspec.yaml +++ b/packages/xdg_directories/pubspec.yaml @@ -2,7 +2,7 @@ name: xdg_directories description: A Dart package for reading XDG directory configuration information on Linux. repository: https://github.com/flutter/packages/tree/main/packages/xdg_directories issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+xdg_directories%22 -version: 0.2.0+1 +version: 0.2.0+2 environment: sdk: ">=2.12.0 <3.0.0" diff --git a/packages/xdg_directories/test/xdg_directories_test.dart b/packages/xdg_directories/test/xdg_directories_test.dart index 7bcb4caf98..800b0b69e2 100644 --- a/packages/xdg_directories/test/xdg_directories_test.dart +++ b/packages/xdg_directories/test/xdg_directories_test.dart @@ -136,6 +136,6 @@ class FakeProcessManager extends Fake implements ProcessManager { Encoding stdoutEncoding = systemEncoding, Encoding stderrEncoding = systemEncoding, }) { - return ProcessResult(0, 0, expected[command[1]]!, ''); + return ProcessResult(0, 0, expected[command[1]], ''); } }