Skip to content

Commit d2858f0

Browse files
authored
enable null_check_on_nullable_type_parameter and tighten_type_of_initializing_formals (flutter#67557)
* enable null_check_on_nullable_type_parameter and tighten_type_of_initializing_formals * fix CI
1 parent 0d8d4f7 commit d2858f0

File tree

11 files changed

+23
-18
lines changed

11 files changed

+23
-18
lines changed

analysis_options.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ linter:
123123
# - no_logic_in_create_state # not yet tested
124124
# - no_runtimeType_toString # not yet tested
125125
- non_constant_identifier_names
126+
- null_check_on_nullable_type_parameter
126127
# - null_closures # not yet tested
127128
# - omit_local_variable_types # opposite of always_specify_types
128129
# - one_member_abstracts # too many false positives
@@ -180,6 +181,7 @@ linter:
180181
- sort_unnamed_constructors_first
181182
- test_types_in_equals
182183
- throw_in_finally
184+
- tighten_type_of_initializing_formals
183185
# - type_annotate_public_apis # subset of always_specify_types
184186
- type_init_formals
185187
# - unawaited_futures # too many false positives

packages/flutter/lib/src/animation/animations.dart

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -491,8 +491,11 @@ class TrainHoppingAnimation extends Animation<double>
491491
/// The current train argument must not be null but the next train argument
492492
/// can be null. If the next train is null, then this object will just proxy
493493
/// the first animation and never hop.
494-
TrainHoppingAnimation(this._currentTrain, this._nextTrain, { this.onSwitchedTrain })
495-
: assert(_currentTrain != null) {
494+
TrainHoppingAnimation(
495+
Animation<double> this._currentTrain,
496+
this._nextTrain, {
497+
this.onSwitchedTrain,
498+
}) : assert(_currentTrain != null) {
496499
if (_nextTrain != null) {
497500
if (_currentTrain!.value == _nextTrain!.value) {
498501
_currentTrain = _nextTrain;

packages/flutter/lib/src/material/app.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,12 +169,12 @@ class MaterialApp extends StatefulWidget {
169169
this.navigatorKey,
170170
this.scaffoldMessengerKey,
171171
this.home,
172-
this.routes = const <String, WidgetBuilder>{},
172+
Map<String, WidgetBuilder> this.routes = const <String, WidgetBuilder>{},
173173
this.initialRoute,
174174
this.onGenerateRoute,
175175
this.onGenerateInitialRoutes,
176176
this.onUnknownRoute,
177-
this.navigatorObservers = const <NavigatorObserver>[],
177+
List<NavigatorObserver> this.navigatorObservers = const <NavigatorObserver>[],
178178
this.builder,
179179
this.title = '',
180180
this.onGenerateTitle,
@@ -218,8 +218,8 @@ class MaterialApp extends StatefulWidget {
218218
Key? key,
219219
this.scaffoldMessengerKey,
220220
this.routeInformationProvider,
221-
required this.routeInformationParser,
222-
required this.routerDelegate,
221+
required RouteInformationParser<Object> this.routeInformationParser,
222+
required RouterDelegate<Object> this.routerDelegate,
223223
this.backButtonDispatcher,
224224
this.builder,
225225
this.title = '',

packages/flutter/lib/src/material/input_decorator.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3736,7 +3736,7 @@ class InputDecorationTheme with Diagnosticable {
37363736
/// true and bordered per the [border].
37373737
///
37383738
/// This property is false by default.
3739-
final bool? filled;
3739+
final bool filled;
37403740

37413741
/// The color to fill the decoration's container with, if [filled] is true.
37423742
///

packages/flutter/lib/src/material/pickers/input_date_picker.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ class _InputDatePickerFormFieldState extends State<InputDatePickerFormField> {
224224
return TextFormField(
225225
decoration: InputDecoration(
226226
border: inputTheme.border ?? const UnderlineInputBorder(),
227-
filled: inputTheme.filled ?? true,
227+
filled: inputTheme.filled,
228228
hintText: widget.fieldHintText ?? localizations.dateHelpText,
229229
labelText: widget.fieldLabelText ?? localizations.dateInputLabel,
230230
),

packages/flutter/lib/src/material/pickers/input_date_range_picker.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ class InputDateRangePickerState extends State<InputDateRangePicker> {
235235
controller: _startController,
236236
decoration: InputDecoration(
237237
border: inputTheme.border ?? const UnderlineInputBorder(),
238-
filled: inputTheme.filled ?? true,
238+
filled: inputTheme.filled,
239239
hintText: widget.fieldStartHintText ?? localizations.dateHelpText,
240240
labelText: widget.fieldStartLabelText ?? localizations.dateRangeStartLabel,
241241
errorText: _startErrorText,
@@ -251,7 +251,7 @@ class InputDateRangePickerState extends State<InputDateRangePicker> {
251251
controller: _endController,
252252
decoration: InputDecoration(
253253
border: inputTheme.border ?? const UnderlineInputBorder(),
254-
filled: inputTheme.filled ?? true,
254+
filled: inputTheme.filled,
255255
hintText: widget.fieldEndHintText ?? localizations.dateHelpText,
256256
labelText: widget.fieldEndLabelText ?? localizations.dateRangeEndLabel,
257257
errorText: _endErrorText,

packages/flutter/lib/src/material/selectable_text.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ class SelectableText extends StatefulWidget {
174174
/// must not be null. If specified, the [maxLines] argument must be greater
175175
/// than zero.
176176
const SelectableText(
177-
this.data, {
177+
String this.data, {
178178
Key? key,
179179
this.focusNode,
180180
this.style,
@@ -226,7 +226,7 @@ class SelectableText extends StatefulWidget {
226226
///
227227
/// The [autofocus] and [dragStartBehavior] arguments must not be null.
228228
const SelectableText.rich(
229-
this.textSpan, {
229+
TextSpan this.textSpan, {
230230
Key? key,
231231
this.focusNode,
232232
this.style,

packages/flutter/lib/src/rendering/mouse_tracking.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ class MouseTrackerUpdateDetails with Diagnosticable {
177177
const MouseTrackerUpdateDetails.byNewFrame({
178178
required this.lastAnnotations,
179179
required this.nextAnnotations,
180-
required this.previousEvent,
180+
required PointerEvent this.previousEvent,
181181
}) : assert(previousEvent != null),
182182
assert(lastAnnotations != null),
183183
assert(nextAnnotations != null),

packages/flutter/lib/src/widgets/async.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ class StreamBuilder<T> extends StreamBuilderBase<T, AsyncSnapshot<T>> {
500500
@override
501501
AsyncSnapshot<T> initial() => initialData == null
502502
? AsyncSnapshot<T>.nothing()
503-
: AsyncSnapshot<T>.withData(ConnectionState.none, initialData!);
503+
: AsyncSnapshot<T>.withData(ConnectionState.none, initialData as T);
504504

505505
@override
506506
AsyncSnapshot<T> afterConnected(AsyncSnapshot<T> current) => current.inState(ConnectionState.waiting);
@@ -733,7 +733,7 @@ class _FutureBuilderState<T> extends State<FutureBuilder<T>> {
733733
super.initState();
734734
_snapshot = widget.initialData == null
735735
? AsyncSnapshot<T>.nothing()
736-
: AsyncSnapshot<T>.withData(ConnectionState.none, widget.initialData!);
736+
: AsyncSnapshot<T>.withData(ConnectionState.none, widget.initialData as T);
737737
_subscribe();
738738
}
739739

packages/flutter/lib/src/widgets/disposable_build_context.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ class DisposableBuildContext<T extends State> {
2727
/// Creators must call [dispose] when the [State] is disposed.
2828
///
2929
/// The [State] must not be null, and [State.mounted] must be true.
30-
DisposableBuildContext(this._state)
30+
DisposableBuildContext(T this._state)
3131
: assert(_state != null),
32-
assert(_state!.mounted, 'A DisposableBuildContext was given a BuildContext for an Element that is not mounted.');
32+
assert(_state.mounted, 'A DisposableBuildContext was given a BuildContext for an Element that is not mounted.');
3333

3434
T? _state;
3535

0 commit comments

Comments
 (0)