enable lint unnecessary_nullable_for_final_variable_declarations (#66387)

This commit is contained in:
Alexandre Ardhuin 2020-09-23 06:39:47 +02:00 committed by GitHub
parent 97d6799331
commit 71c1f6c3e4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 11 additions and 8 deletions

View file

@ -192,6 +192,7 @@ linter:
- unnecessary_new
- unnecessary_null_aware_assignments
- unnecessary_null_in_if_null_operators
- unnecessary_nullable_for_final_variable_declarations
- unnecessary_overrides
- unnecessary_parenthesis
- unnecessary_statements

View file

@ -453,13 +453,13 @@ class StandardMessageCodec implements MessageCodec<dynamic> {
return buffer.getFloat64List(length);
case _valueList:
final int length = readSize(buffer);
final dynamic result = List<dynamic>.filled(length, null, growable: false);
final List<dynamic> result = List<dynamic>.filled(length, null, growable: false);
for (int i = 0; i < length; i++)
result[i] = readValue(buffer);
return result;
case _valueMap:
final int length = readSize(buffer);
final dynamic result = <dynamic, dynamic>{};
final Map<dynamic, dynamic> result = <dynamic, dynamic>{};
for (int i = 0; i < length; i++)
result[readValue(buffer)] = readValue(buffer);
return result;

View file

@ -321,7 +321,7 @@ abstract class GlobalKey<T extends State<StatefulWidget>> extends Key {
final Element? element = _currentElement;
if (element is StatefulElement) {
final StatefulElement statefulElement = element;
final State? state = statefulElement.state;
final State state = statefulElement.state;
if (state is T)
return state;
}

View file

@ -181,7 +181,11 @@ class ListWheelChildBuilderDelegate extends ListWheelChildDelegate {
@override
Widget? build(BuildContext context, int index) {
if (childCount == null) {
final Widget? child = builder(context, index);
final Widget child = builder(context, index);
// `child` has a non-nullable return type, but might be null when
// running with weak checking, so we need to null check it anyway (and
// ignore the warning that the null-handling logic is dead code).
// ignore: dead_code
return child == null ? null : IndexedSemantics(child: child, index: index);
}
if (index < 0 || index >= childCount!)

View file

@ -1048,10 +1048,8 @@ mixin WidgetInspectorService {
renderObject.markNeedsPaint();
renderObject.visitChildren(markTreeNeedsPaint);
}
final RenderObject? root = RendererBinding.instance!.renderView;
if (root != null) {
markTreeNeedsPaint(root);
}
final RenderObject root = RendererBinding.instance!.renderView;
markTreeNeedsPaint(root);
} else {
debugOnProfilePaint = null;
}