Skip to content

Commit bb97da8

Browse files
authored
[various] Sync lints with flutter/flutter (flutter#5717)
Applying the latest analysis_options.yaml from flutter/flutter to this repo. Most fixes were auto-generated by `dart fix`.
1 parent 6b2249f commit bb97da8

File tree

282 files changed

+527
-947
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

282 files changed

+527
-947
lines changed

analysis_options.yaml

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
# Specify analysis options.
22
#
33
# This file is a copy of analysis_options.yaml from flutter repo
4-
# as of 2022-07-27, but with some modifications marked with
4+
# as of 2023-12-18, but with some modifications marked with
55
# "DIFFERENT FROM FLUTTER/FLUTTER" below. The file is expected to
66
# be kept in sync with the master file from the flutter repo.
77

88
analyzer:
99
language:
1010
strict-casts: true
11+
strict-inference: true
1112
strict-raw-types: true
1213
errors:
1314
# allow self-reference to deprecated members (we do this because otherwise we have
@@ -21,19 +22,18 @@ analyzer:
2122
linter:
2223
rules:
2324
# This list is derived from the list of all available lints located at
24-
# https://github.com/dart-lang/linter/blob/master/example/all.yaml
25+
# https://github.com/dart-lang/linter/blob/main/example/all.yaml
2526
- always_declare_return_types
2627
- always_put_control_body_on_new_line
2728
# - always_put_required_named_parameters_first # we prefer having parameters in the same order as fields https://github.com/flutter/flutter/issues/10219
28-
- always_require_non_null_named_parameters
2929
- always_specify_types
3030
# - always_use_package_imports # we do this commonly
3131
- annotate_overrides
3232
# - avoid_annotating_with_dynamic # conflicts with always_specify_types
3333
- avoid_bool_literals_in_conditional_expressions
3434
# - avoid_catches_without_on_clauses # blocked on https://github.com/dart-lang/linter/issues/3023
3535
# - avoid_catching_errors # blocked on https://github.com/dart-lang/linter/issues/3023
36-
- avoid_classes_with_only_static_members
36+
# - avoid_classes_with_only_static_members # we do this commonly for `abstract final class`es
3737
- avoid_double_and_int_checks
3838
- avoid_dynamic_calls
3939
- avoid_empty_else
@@ -42,7 +42,7 @@ linter:
4242
- avoid_field_initializers_in_const_classes
4343
# - avoid_final_parameters # incompatible with prefer_final_parameters
4444
- avoid_function_literals_in_foreach_calls
45-
- avoid_implementing_value_types
45+
# - avoid_implementing_value_types # see https://github.com/dart-lang/linter/issues/4558
4646
- avoid_init_to_null
4747
- avoid_js_rounded_ints
4848
# - avoid_multiple_declarations_per_line # seems to be a stylistic choice we don't subscribe to
@@ -54,8 +54,6 @@ linter:
5454
- avoid_relative_lib_imports
5555
- avoid_renaming_method_parameters
5656
- avoid_return_types_on_setters
57-
- avoid_returning_null
58-
- avoid_returning_null_for_future
5957
- avoid_returning_null_for_void
6058
# - avoid_returning_this # there are enough valid reasons to return `this` that this lint ends up with too many false positives
6159
- avoid_setters_without_getters
@@ -77,17 +75,19 @@ linter:
7775
- cast_nullable_to_non_nullable
7876
# - close_sinks # not reliable enough
7977
- collection_methods_unrelated_type
80-
# - combinators_ordering # DIFFERENT FROM FLUTTER/FLUTTER: This isn't available on stable yet.
78+
- combinators_ordering
8179
# - comment_references # blocked on https://github.com/dart-lang/linter/issues/1142
8280
- conditional_uri_does_not_exist
8381
# - constant_identifier_names # needs an opt-out https://github.com/dart-lang/linter/issues/204
8482
- control_flow_in_finally
8583
- curly_braces_in_flow_control_structures
84+
- dangling_library_doc_comments
8685
- depend_on_referenced_packages
8786
- deprecated_consistency
87+
# - deprecated_member_use_from_same_package # we allow self-references to deprecated members
8888
# - diagnostic_describe_all_properties # enabled only at the framework level (packages/flutter/lib)
8989
- directives_ordering
90-
# - discarded_futures # not yet tested
90+
# - discarded_futures # too many false positives, similar to unawaited_futures
9191
# - do_not_use_environment # there are appropriate times to use the environment, especially in our tests and build logic
9292
- empty_catches
9393
- empty_constructor_bodies
@@ -98,21 +98,29 @@ linter:
9898
- flutter_style_todos
9999
- hash_and_equals
100100
- implementation_imports
101+
- implicit_call_tearoffs
102+
- implicit_reopen
103+
- invalid_case_patterns
101104
# - join_return_with_assignment # not required by flutter style
102105
- leading_newlines_in_multiline_strings
106+
- library_annotations
103107
- library_names
104108
- library_prefixes
105109
- library_private_types_in_public_api
106110
# - lines_longer_than_80_chars # not required by flutter style
107-
# - literal_only_boolean_expressions # too many false positives: https://github.com/dart-lang/linter/issues/453
111+
- literal_only_boolean_expressions
112+
# - matching_super_parameters # blocked on https://github.com/dart-lang/language/issues/2509
108113
- missing_whitespace_between_adjacent_strings
109114
- no_adjacent_strings_in_list
110115
- no_default_cases
111116
- no_duplicate_case_values
112117
- no_leading_underscores_for_library_prefixes
113118
- no_leading_underscores_for_local_identifiers
119+
- no_literal_bool_comparisons
114120
- no_logic_in_create_state
115121
- no_runtimeType_toString # DIFFERENT FROM FLUTTER/FLUTTER
122+
- no_self_assignments
123+
- no_wildcard_variable_uses
116124
- non_constant_identifier_names
117125
- noop_primitive_operations
118126
- null_check_on_nullable_type_parameter
@@ -137,12 +145,11 @@ linter:
137145
# - prefer_constructors_over_static_methods # far too many false positives
138146
- prefer_contains
139147
# - prefer_double_quotes # opposite of prefer_single_quotes
140-
- prefer_equal_for_default_values
141148
# - prefer_expression_function_bodies # conflicts with https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#consider-using--for-short-functions-and-methods
142149
- prefer_final_fields
143150
- prefer_final_in_for_each
144151
- prefer_final_locals
145-
# - 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
152+
# - prefer_final_parameters # adds too much verbosity
146153
- prefer_for_elements_to_map_fromIterable
147154
- prefer_foreach
148155
- prefer_function_declarations_over_variables
@@ -157,7 +164,7 @@ linter:
157164
- prefer_is_not_empty
158165
- prefer_is_not_operator
159166
- prefer_iterable_whereType
160-
# - prefer_mixin # Has false positives, see https://github.com/dart-lang/linter/issues/3018
167+
# - prefer_mixin # DIFFERENT FROM FLUTTER/FLUTTER: enable when v2.1.7 of plugin_platform_interface is the oldest supported version (which makes MockPlatformInterfaceMixin a mixin class)
161168
# - prefer_null_aware_method_calls # "call()" is confusing to people new to the language since it's not documented anywhere
162169
- prefer_null_aware_operators
163170
- prefer_relative_imports
@@ -168,10 +175,10 @@ linter:
168175
- provide_deprecation_message
169176
- public_member_api_docs # DIFFERENT FROM FLUTTER/FLUTTER
170177
- recursive_getters
171-
# - require_trailing_commas # blocked on https://github.com/dart-lang/sdk/issues/47441
178+
# - require_trailing_commas # would be nice, but requires a lot of manual work: 10,000+ code locations would need to be reformatted by hand after bulk fix is applied
172179
- secure_pubspec_urls
173180
- sized_box_for_whitespace
174-
# - sized_box_shrink_expand # not yet tested
181+
- sized_box_shrink_expand
175182
- slash_for_doc_comments
176183
- sort_child_properties_last
177184
- sort_constructors_first
@@ -182,15 +189,18 @@ linter:
182189
- tighten_type_of_initializing_formals
183190
# - type_annotate_public_apis # subset of always_specify_types
184191
- type_init_formals
192+
- type_literal_in_constant_pattern
185193
- unawaited_futures # DIFFERENT FROM FLUTTER/FLUTTER: It's disabled there for "too many false positives"; that's not an issue here, and missing awaits have caused production issues in plugins.
186194
- unnecessary_await_in_return
187195
- unnecessary_brace_in_string_interps
196+
- unnecessary_breaks
188197
- unnecessary_const
189198
- unnecessary_constructor_name
190199
# - unnecessary_final # conflicts with prefer_final_locals
191200
- unnecessary_getters_setters
192201
# - unnecessary_lambdas # has false positives: https://github.com/dart-lang/linter/issues/498
193202
- unnecessary_late
203+
- unnecessary_library_directive
194204
- unnecessary_new
195205
- unnecessary_null_aware_assignments
196206
- unnecessary_null_aware_operator_on_extension_on_nullable
@@ -205,12 +215,13 @@ linter:
205215
- unnecessary_string_interpolations
206216
- unnecessary_this
207217
- unnecessary_to_list_in_spreads
218+
- unreachable_from_main
208219
- unrelated_type_equality_checks
209220
- unsafe_html
210221
- use_build_context_synchronously
211-
# - use_colored_box # not yet tested
212-
# - use_decorated_box # not yet tested
213-
# - use_enums # not yet tested
222+
- use_colored_box
223+
# - use_decorated_box # leads to bugs: DecoratedBox and Container are not equivalent (Container inserts extra padding)
224+
- use_enums
214225
- use_full_hex_values_for_flutter_colors
215226
- use_function_type_syntax_for_parameters
216227
- use_if_null_to_convert_nulls_to_bools
@@ -222,6 +233,7 @@ linter:
222233
- use_rethrow_when_possible
223234
- use_setters_to_change_properties
224235
# - use_string_buffers # has false positives: https://github.com/dart-lang/sdk/issues/34182
236+
- use_string_in_part_of_directives
225237
- use_super_parameters
226238
- use_test_throws_matchers
227239
# - use_to_and_as_if_applicable # has false positives, so we prefer to catch this by code-review

packages/animations/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 2.0.11
2+
3+
* Fixes new lint warnings.
4+
15
## 2.0.10
26

37
* Updates minimum supported SDK version to Flutter 3.16/Dart 3.2.

packages/animations/example/lib/container_transition.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ class _ExampleCard extends StatelessWidget {
312312
crossAxisAlignment: CrossAxisAlignment.stretch,
313313
children: <Widget>[
314314
Expanded(
315-
child: Container(
315+
child: ColoredBox(
316316
color: Colors.black38,
317317
child: Center(
318318
child: Image.asset(

packages/animations/example/lib/fade_through_transition.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class _ExampleCard extends StatelessWidget {
7979
crossAxisAlignment: CrossAxisAlignment.stretch,
8080
children: <Widget>[
8181
Expanded(
82-
child: Container(
82+
child: ColoredBox(
8383
color: Colors.black26,
8484
child: Padding(
8585
padding: const EdgeInsets.all(30.0),

packages/animations/lib/src/fade_through_transition.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ class FadeThroughTransition extends StatelessWidget {
201201
Widget build(BuildContext context) {
202202
return _ZoomedFadeInFadeOut(
203203
animation: animation,
204-
child: Container(
204+
child: ColoredBox(
205205
color: fillColor ?? Theme.of(context).canvasColor,
206206
child: _ZoomedFadeInFadeOut(
207207
animation: ReverseAnimation(secondaryAnimation),

packages/animations/lib/src/open_container.dart

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -604,10 +604,8 @@ class _OpenContainerRoute<T> extends ModalRoute<T> {
604604
switch (status) {
605605
case AnimationStatus.dismissed:
606606
_toggleHideable(hide: false);
607-
break;
608607
case AnimationStatus.completed:
609608
_toggleHideable(hide: true);
610-
break;
611609
case AnimationStatus.forward:
612610
case AnimationStatus.reverse:
613611
break;
@@ -699,23 +697,19 @@ class _OpenContainerRoute<T> extends ModalRoute<T> {
699697
case AnimationStatus.completed:
700698
case AnimationStatus.dismissed:
701699
isInProgress = false;
702-
break;
703700
case AnimationStatus.forward:
704701
case AnimationStatus.reverse:
705702
isInProgress = true;
706-
break;
707703
case null:
708704
break;
709705
}
710706
switch (_lastAnimationStatus) {
711707
case AnimationStatus.completed:
712708
case AnimationStatus.dismissed:
713709
wasInProgress = false;
714-
break;
715710
case AnimationStatus.forward:
716711
case AnimationStatus.reverse:
717712
wasInProgress = true;
718-
break;
719713
case null:
720714
break;
721715
}
@@ -769,7 +763,6 @@ class _OpenContainerRoute<T> extends ModalRoute<T> {
769763
openOpacityTween = _openOpacityTween;
770764
colorTween = _colorTween;
771765
scrimTween = _scrimFadeInTween;
772-
break;
773766
case AnimationStatus.reverse:
774767
if (_transitionWasInterrupted) {
775768
closedOpacityTween = _closedOpacityTween;
@@ -782,10 +775,8 @@ class _OpenContainerRoute<T> extends ModalRoute<T> {
782775
openOpacityTween = _openOpacityTween.flipped;
783776
colorTween = _colorTween.flipped;
784777
scrimTween = _scrimFadeOutTween;
785-
break;
786778
case AnimationStatus.completed:
787779
assert(false); // Unreachable.
788-
break;
789780
}
790781
assert(colorTween != null);
791782
assert(closedOpacityTween != null);

packages/animations/lib/src/shared_axis_transition.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ class _ExitTransition extends StatelessWidget {
410410

411411
return FadeTransition(
412412
opacity: _fadeOutTransition.animate(animation),
413-
child: Container(
413+
child: ColoredBox(
414414
color: fillColor,
415415
child: AnimatedBuilder(
416416
animation: animation,
@@ -432,7 +432,7 @@ class _ExitTransition extends StatelessWidget {
432432

433433
return FadeTransition(
434434
opacity: _fadeOutTransition.animate(animation),
435-
child: Container(
435+
child: ColoredBox(
436436
color: fillColor,
437437
child: AnimatedBuilder(
438438
animation: animation,
@@ -449,7 +449,7 @@ class _ExitTransition extends StatelessWidget {
449449
case SharedAxisTransitionType.scaled:
450450
return FadeTransition(
451451
opacity: _fadeOutTransition.animate(animation),
452-
child: Container(
452+
child: ColoredBox(
453453
color: fillColor,
454454
child: ScaleTransition(
455455
scale: (!reverse ? _scaleUpTransition : _scaleDownTransition)

packages/animations/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: animations
22
description: Fancy pre-built animations that can easily be integrated into any Flutter application.
33
repository: https://github.com/flutter/packages/tree/main/packages/animations
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+animations%22
5-
version: 2.0.10
5+
version: 2.0.11
66

77
environment:
88
sdk: ">=3.2.0 <4.0.0"

0 commit comments

Comments
 (0)