Unverified Commit b554f893 authored by Abhishek Ghaskata's avatar Abhishek Ghaskata Committed by GitHub

Enable unnecessary_null_checks lint (#82084)

parent f6747dfa
......@@ -204,7 +204,7 @@ linter:
# - unnecessary_lambdas # has false positives: https://github.com/dart-lang/linter/issues/498
- unnecessary_new
- unnecessary_null_aware_assignments
# - unnecessary_null_checks # not yet tested
- unnecessary_null_checks
- unnecessary_null_in_if_null_operators
- unnecessary_nullable_for_final_variable_declarations
- unnecessary_overrides
......
......@@ -227,7 +227,9 @@ class SnippetGenerator {
if (match != null) { // If we saw the start or end of a code block
inCodeBlock = !inCodeBlock;
if (match.namedGroup('language') != null) {
language = match[1]!;
language = match[1];
assert(language != null);
language = language!;
if (match.namedGroup('section') != null) {
components.add(_ComponentTuple('code-${match.namedGroup('section')}', <String>[], language: language));
} else {
......
......@@ -287,7 +287,7 @@ class CupertinoFormSection extends StatelessWidget {
),
child: Padding(
padding: _kDefaultHeaderMargin,
child: header!,
child: header,
),
),
),
......@@ -311,7 +311,7 @@ class CupertinoFormSection extends StatelessWidget {
),
child: Padding(
padding: _kDefaultFooterMargin,
child: footer!,
child: footer,
),
),
),
......
......@@ -1652,7 +1652,7 @@ class _CalendarRangePickerDialog extends StatelessWidget {
if (orientation == Orientation.portrait && entryModeButton != null)
Padding(
padding: const EdgeInsets.symmetric(horizontal: 8.0),
child: entryModeButton!,
child: entryModeButton,
),
]),
),
......
......@@ -528,7 +528,7 @@ class AlertDialog extends StatelessWidget {
style: contentTextStyle ?? dialogTheme.contentTextStyle ?? theme.textTheme.subtitle1!,
child: Semantics(
container: true,
child: content!,
child: content,
),
),
);
......
......@@ -557,7 +557,7 @@ class _ReorderableListViewState extends State<ReorderableListView> {
if (widget.header != null)
SliverPadding(
padding: headerPadding,
sliver: SliverToBoxAdapter(child: widget.header!),
sliver: SliverToBoxAdapter(child: widget.header),
),
SliverPadding(
padding: listPadding,
......
......@@ -454,9 +454,9 @@ void main() {
error = e;
}
expect(error, isNotNull);
expect(error!, isFlutterError);
expect(error, isFlutterError);
expect(
error.toStringDeep(),
error!.toStringDeep(),
equalsIgnoringHashCodes(
'FlutterError\n'
' A TestNotifier was used after being disposed.\n'
......
......@@ -257,7 +257,7 @@ void main() {
rootBucket2 = bucket;
});
expect(rootBucket2, isNotNull);
expect(rootBucket2!, isNot(same(rootBucket)));
expect(rootBucket2, isNot(same(rootBucket)));
expect(manager.isReplacing, isTrue);
expect(rootBucket2!.isReplacing, isTrue);
await tester.idle();
......
......@@ -4861,7 +4861,7 @@ void main() {
);
expect(
selection!,
selection,
equals(
const TextSelection(
baseOffset: 0,
......@@ -4884,7 +4884,7 @@ void main() {
);
expect(
selection!,
selection,
equals(
const TextSelection(
baseOffset: 0,
......@@ -4912,7 +4912,7 @@ void main() {
);
expect(
selection!,
selection,
equals(
const TextSelection(
baseOffset: 0,
......@@ -4938,7 +4938,7 @@ void main() {
platform: platform,
);
expect(
selection!,
selection,
equals(
const TextSelection(
baseOffset: 0,
......@@ -4959,7 +4959,7 @@ void main() {
platform: platform,
);
expect(
selection!,
selection,
equals(
const TextSelection(
baseOffset: 0,
......@@ -7715,7 +7715,7 @@ class NoImplicitScrollPhysics extends AlwaysScrollableScrollPhysics {
@override
NoImplicitScrollPhysics applyTo(ScrollPhysics? ancestor) {
return NoImplicitScrollPhysics(parent: buildParent(ancestor)!);
return NoImplicitScrollPhysics(parent: buildParent(ancestor));
}
}
......
......@@ -263,7 +263,7 @@ void main() {
);
// Add the child focus scope to the focus tree.
final FocusAttachment childAttachment = childFocusScope.attach(key.currentContext!);
final FocusAttachment childAttachment = childFocusScope.attach(key.currentContext);
parentFocusScope.setFirstFocus(childFocusScope);
await tester.pumpAndSettle();
expect(childFocusScope.isFirstFocus, isTrue);
......
......@@ -417,7 +417,7 @@ class RecordingPhysics extends ScrollPhysics {
@override
RecordingPhysics applyTo(ScrollPhysics? ancestor) {
return RecordingPhysics(parent: buildParent(ancestor)!);
return RecordingPhysics(parent: buildParent(ancestor));
}
@override
......@@ -437,7 +437,7 @@ class ControllablePhysics extends ScrollPhysics {
@override
ControllablePhysics applyTo(ScrollPhysics? ancestor) {
return ControllablePhysics(parent: buildParent(ancestor)!);
return ControllablePhysics(parent: buildParent(ancestor));
}
@override
......
......@@ -26,7 +26,7 @@ class TestDispatcher extends ActionDispatcher {
@override
Object? invokeAction(Action<TestIntent> action, Intent intent, [BuildContext? context]) {
final Object? result = super.invokeAction(action, intent, context);
postInvoke?.call(action: action, intent: intent, context: context!, dispatcher: this);
postInvoke?.call(action: action, intent: intent, context: context, dispatcher: this);
return result;
}
}
......
......@@ -307,8 +307,9 @@ class TestAsyncUtils {
do { // skip past frames that are from this class
index += 1;
assert(index < stack.length);
lineMatch = getClassPattern.matchAsPrefix(stack[index])!;
lineMatch = getClassPattern.matchAsPrefix(stack[index]);
assert(lineMatch != null);
lineMatch = lineMatch!;
assert(lineMatch.groupCount == 1);
} while (lineMatch.group(1) == _className);
// try to parse the stack to find the interesting frame
......
......@@ -137,7 +137,7 @@ class AnalysisServer {
}
} else if (response['error'] != null) {
// Fields are 'code', 'message', and 'stackTrace'.
final Map<String, dynamic> error = castStringKeyedMap(response['error']!)!;
final Map<String, dynamic> error = castStringKeyedMap(response['error'])!;
_logger.printError(
'Error response from the server: ${error['code']} ${error['message']}');
if (error['stackTrace'] != null) {
......
......@@ -210,7 +210,7 @@ class FuchsiaRemoteConnection {
SshCommandRunner(
address: address,
interface: interface,
sshConfigPath: sshConfigPath!,
sshConfigPath: sshConfigPath,
),
);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment