Enable strict_top_level_inference (#160674)

Only observation: It forces a type on `_` parameters.
This commit is contained in:
Michael Goderbauer 2024-12-20 21:23:04 -08:00 committed by GitHub
parent d9e5a5c21d
commit 7df127b1ee
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 13 additions and 8 deletions

View File

@ -8,7 +8,7 @@
# which should be kept in sync with this file:
#
# - analysis_options.yaml (this file)
# - https://github.com/flutter/engine/blob/main/analysis_options.yaml
# - engine/src/flutter/analysis_options.yaml
# - https://github.com/flutter/packages/blob/main/analysis_options.yaml
#
# This file contains the analysis options used for code in the flutter/flutter
@ -58,6 +58,7 @@ linter:
- avoid_field_initializers_in_const_classes
# - avoid_final_parameters # incompatible with prefer_final_parameters
- avoid_function_literals_in_foreach_calls
# - avoid_futureor_void # not yet tested
# - avoid_implementing_value_types # see https://github.com/dart-lang/linter/issues/4558
- avoid_init_to_null
- avoid_js_rounded_ints
@ -146,10 +147,10 @@ linter:
- null_closures
# - omit_local_variable_types # opposite of always_specify_types
# - omit_obvious_local_variable_types # not yet tested
# - omit_obvious_property_types # not yet tested
# - one_member_abstracts # too many false positives
- 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 # Deprecated (https://github.com/dart-lang/linter/issues/5107)
- package_names
- package_prefixed_library_names
# - parameter_assignments # we do this commonly
@ -205,6 +206,8 @@ linter:
# - sort_pub_dependencies # prevents separating pinned transitive dependencies
- sort_unnamed_constructors_first
# - specify_nonobvious_local_variable_types # not yet tested
# - specify_nonobvious_property_types # not yet tested
- strict_top_level_inference
- test_types_in_equals
- throw_in_finally
- tighten_type_of_initializing_formals
@ -240,6 +243,7 @@ linter:
- unnecessary_to_list_in_spreads
- unreachable_from_main
- unrelated_type_equality_checks
# - unsafe_variance # not yet tested
- use_build_context_synchronously
- use_colored_box
# - use_decorated_box # leads to bugs: DecoratedBox and Container are not equivalent (Container inserts extra padding)

View File

@ -808,7 +808,7 @@ class _DropdownMenuState<T> extends State<DropdownMenu<T>> {
return result;
}
void handleUpKeyInvoke(_) {
void handleUpKeyInvoke(_ArrowUpIntent _) {
setState(() {
if (!widget.enabled || !_menuHasEnabledItem || !_controller.isOpen) {
return;
@ -828,7 +828,7 @@ class _DropdownMenuState<T> extends State<DropdownMenu<T>> {
});
}
void handleDownKeyInvoke(_) {
void handleDownKeyInvoke(_ArrowDownIntent _) {
setState(() {
if (!widget.enabled || !_menuHasEnabledItem || !_controller.isOpen) {
return;

View File

@ -1305,7 +1305,7 @@ class _ZoomEnterTransitionPainter extends SnapshotPainter {
fade.addListener(notifyListeners);
}
void _onStatusChange(_) {
void _onStatusChange(AnimationStatus _) {
notifyListeners();
}
@ -1414,7 +1414,7 @@ class _ZoomExitTransitionPainter extends SnapshotPainter {
animation.addStatusListener(_onStatusChange);
}
void _onStatusChange(_) {
void _onStatusChange(AnimationStatus _) {
notifyListeners();
}

View File

@ -4,6 +4,7 @@
import 'dart:io';
import 'dart:isolate';
import 'package:file/file.dart';
import 'package:file/local.dart';
import 'package:flutter/foundation.dart';
@ -168,11 +169,11 @@ dynamic testInvalidError(int square) {
}
}
String? testDebugName(_) {
String? testDebugName(void _) {
return Isolate.current.debugName;
}
int? testReturnNull(_) {
int? testReturnNull(void _) {
return null;
}