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