diff --git a/analysis_options.yaml b/analysis_options.yaml index 9d9836c3b2..f2de0956aa 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -123,6 +123,7 @@ linter: # - no_logic_in_create_state # not yet tested # - no_runtimeType_toString # not yet tested - non_constant_identifier_names + - null_check_on_nullable_type_parameter # - null_closures # not yet tested # - omit_local_variable_types # opposite of always_specify_types # - one_member_abstracts # too many false positives @@ -180,6 +181,7 @@ linter: - 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 diff --git a/packages/flutter/lib/src/animation/animations.dart b/packages/flutter/lib/src/animation/animations.dart index eb4aae3577..1858033976 100644 --- a/packages/flutter/lib/src/animation/animations.dart +++ b/packages/flutter/lib/src/animation/animations.dart @@ -491,8 +491,11 @@ class TrainHoppingAnimation extends Animation /// The current train argument must not be null but the next train argument /// can be null. If the next train is null, then this object will just proxy /// the first animation and never hop. - TrainHoppingAnimation(this._currentTrain, this._nextTrain, { this.onSwitchedTrain }) - : assert(_currentTrain != null) { + TrainHoppingAnimation( + Animation this._currentTrain, + this._nextTrain, { + this.onSwitchedTrain, + }) : assert(_currentTrain != null) { if (_nextTrain != null) { if (_currentTrain!.value == _nextTrain!.value) { _currentTrain = _nextTrain; diff --git a/packages/flutter/lib/src/material/app.dart b/packages/flutter/lib/src/material/app.dart index 874de23ea0..ad2dae6aeb 100644 --- a/packages/flutter/lib/src/material/app.dart +++ b/packages/flutter/lib/src/material/app.dart @@ -169,12 +169,12 @@ class MaterialApp extends StatefulWidget { this.navigatorKey, this.scaffoldMessengerKey, this.home, - this.routes = const {}, + Map this.routes = const {}, this.initialRoute, this.onGenerateRoute, this.onGenerateInitialRoutes, this.onUnknownRoute, - this.navigatorObservers = const [], + List this.navigatorObservers = const [], this.builder, this.title = '', this.onGenerateTitle, @@ -218,8 +218,8 @@ class MaterialApp extends StatefulWidget { Key? key, this.scaffoldMessengerKey, this.routeInformationProvider, - required this.routeInformationParser, - required this.routerDelegate, + required RouteInformationParser this.routeInformationParser, + required RouterDelegate this.routerDelegate, this.backButtonDispatcher, this.builder, this.title = '', diff --git a/packages/flutter/lib/src/material/input_decorator.dart b/packages/flutter/lib/src/material/input_decorator.dart index 524e69dfff..28d30142ce 100644 --- a/packages/flutter/lib/src/material/input_decorator.dart +++ b/packages/flutter/lib/src/material/input_decorator.dart @@ -3736,7 +3736,7 @@ class InputDecorationTheme with Diagnosticable { /// true and bordered per the [border]. /// /// This property is false by default. - final bool? filled; + final bool filled; /// The color to fill the decoration's container with, if [filled] is true. /// diff --git a/packages/flutter/lib/src/material/pickers/input_date_picker.dart b/packages/flutter/lib/src/material/pickers/input_date_picker.dart index c2172da49b..b3345b2d69 100644 --- a/packages/flutter/lib/src/material/pickers/input_date_picker.dart +++ b/packages/flutter/lib/src/material/pickers/input_date_picker.dart @@ -224,7 +224,7 @@ class _InputDatePickerFormFieldState extends State { return TextFormField( decoration: InputDecoration( border: inputTheme.border ?? const UnderlineInputBorder(), - filled: inputTheme.filled ?? true, + filled: inputTheme.filled, hintText: widget.fieldHintText ?? localizations.dateHelpText, labelText: widget.fieldLabelText ?? localizations.dateInputLabel, ), diff --git a/packages/flutter/lib/src/material/pickers/input_date_range_picker.dart b/packages/flutter/lib/src/material/pickers/input_date_range_picker.dart index 9b161b3d0b..bd11184105 100644 --- a/packages/flutter/lib/src/material/pickers/input_date_range_picker.dart +++ b/packages/flutter/lib/src/material/pickers/input_date_range_picker.dart @@ -235,7 +235,7 @@ class InputDateRangePickerState extends State { controller: _startController, decoration: InputDecoration( border: inputTheme.border ?? const UnderlineInputBorder(), - filled: inputTheme.filled ?? true, + filled: inputTheme.filled, hintText: widget.fieldStartHintText ?? localizations.dateHelpText, labelText: widget.fieldStartLabelText ?? localizations.dateRangeStartLabel, errorText: _startErrorText, @@ -251,7 +251,7 @@ class InputDateRangePickerState extends State { controller: _endController, decoration: InputDecoration( border: inputTheme.border ?? const UnderlineInputBorder(), - filled: inputTheme.filled ?? true, + filled: inputTheme.filled, hintText: widget.fieldEndHintText ?? localizations.dateHelpText, labelText: widget.fieldEndLabelText ?? localizations.dateRangeEndLabel, errorText: _endErrorText, diff --git a/packages/flutter/lib/src/material/selectable_text.dart b/packages/flutter/lib/src/material/selectable_text.dart index ab76518bdb..c4b348346f 100644 --- a/packages/flutter/lib/src/material/selectable_text.dart +++ b/packages/flutter/lib/src/material/selectable_text.dart @@ -174,7 +174,7 @@ class SelectableText extends StatefulWidget { /// must not be null. If specified, the [maxLines] argument must be greater /// than zero. const SelectableText( - this.data, { + String this.data, { Key? key, this.focusNode, this.style, @@ -226,7 +226,7 @@ class SelectableText extends StatefulWidget { /// /// The [autofocus] and [dragStartBehavior] arguments must not be null. const SelectableText.rich( - this.textSpan, { + TextSpan this.textSpan, { Key? key, this.focusNode, this.style, diff --git a/packages/flutter/lib/src/rendering/mouse_tracking.dart b/packages/flutter/lib/src/rendering/mouse_tracking.dart index 9de866e424..bdd90f8fbd 100644 --- a/packages/flutter/lib/src/rendering/mouse_tracking.dart +++ b/packages/flutter/lib/src/rendering/mouse_tracking.dart @@ -177,7 +177,7 @@ class MouseTrackerUpdateDetails with Diagnosticable { const MouseTrackerUpdateDetails.byNewFrame({ required this.lastAnnotations, required this.nextAnnotations, - required this.previousEvent, + required PointerEvent this.previousEvent, }) : assert(previousEvent != null), assert(lastAnnotations != null), assert(nextAnnotations != null), diff --git a/packages/flutter/lib/src/widgets/async.dart b/packages/flutter/lib/src/widgets/async.dart index 9a4d26ed1a..b78acbd1b4 100644 --- a/packages/flutter/lib/src/widgets/async.dart +++ b/packages/flutter/lib/src/widgets/async.dart @@ -500,7 +500,7 @@ class StreamBuilder extends StreamBuilderBase> { @override AsyncSnapshot initial() => initialData == null ? AsyncSnapshot.nothing() - : AsyncSnapshot.withData(ConnectionState.none, initialData!); + : AsyncSnapshot.withData(ConnectionState.none, initialData as T); @override AsyncSnapshot afterConnected(AsyncSnapshot current) => current.inState(ConnectionState.waiting); @@ -733,7 +733,7 @@ class _FutureBuilderState extends State> { super.initState(); _snapshot = widget.initialData == null ? AsyncSnapshot.nothing() - : AsyncSnapshot.withData(ConnectionState.none, widget.initialData!); + : AsyncSnapshot.withData(ConnectionState.none, widget.initialData as T); _subscribe(); } diff --git a/packages/flutter/lib/src/widgets/disposable_build_context.dart b/packages/flutter/lib/src/widgets/disposable_build_context.dart index 213067cd83..3a049ed75c 100644 --- a/packages/flutter/lib/src/widgets/disposable_build_context.dart +++ b/packages/flutter/lib/src/widgets/disposable_build_context.dart @@ -27,9 +27,9 @@ class DisposableBuildContext { /// Creators must call [dispose] when the [State] is disposed. /// /// The [State] must not be null, and [State.mounted] must be true. - DisposableBuildContext(this._state) + DisposableBuildContext(T this._state) : assert(_state != null), - assert(_state!.mounted, 'A DisposableBuildContext was given a BuildContext for an Element that is not mounted.'); + assert(_state.mounted, 'A DisposableBuildContext was given a BuildContext for an Element that is not mounted.'); T? _state; diff --git a/packages/flutter/lib/src/widgets/primary_scroll_controller.dart b/packages/flutter/lib/src/widgets/primary_scroll_controller.dart index 013f214aed..cb71d9eb9f 100644 --- a/packages/flutter/lib/src/widgets/primary_scroll_controller.dart +++ b/packages/flutter/lib/src/widgets/primary_scroll_controller.dart @@ -20,7 +20,7 @@ class PrimaryScrollController extends InheritedWidget { /// Creates a widget that associates a [ScrollController] with a subtree. const PrimaryScrollController({ Key? key, - required this.controller, + required ScrollController this.controller, required Widget child, }) : assert(controller != null), super(key: key, child: child);