Skip to content

Commit b9ead37

Browse files
authored
Simplify null check. (#117026)
* Simplify null check. * Simplify null check. * Simplify null check. * Fix.
1 parent ccfd14b commit b9ead37

File tree

5 files changed

+36
-36
lines changed

5 files changed

+36
-36
lines changed

packages/flutter_tools/lib/src/device.dart

+27-27
Original file line numberDiff line numberDiff line change
@@ -1004,45 +1004,45 @@ class DebuggingOptions {
10041004
static DebuggingOptions fromJson(Map<String, Object?> json, BuildInfo buildInfo) =>
10051005
DebuggingOptions._(
10061006
buildInfo: buildInfo,
1007-
debuggingEnabled: (json['debuggingEnabled'] as bool?)!,
1008-
startPaused: (json['startPaused'] as bool?)!,
1009-
dartFlags: (json['dartFlags'] as String?)!,
1010-
dartEntrypointArgs: ((json['dartEntrypointArgs'] as List<dynamic>?)?.cast<String>())!,
1011-
disableServiceAuthCodes: (json['disableServiceAuthCodes'] as bool?)!,
1012-
enableDds: (json['enableDds'] as bool?)!,
1013-
cacheStartupProfile: (json['cacheStartupProfile'] as bool?)!,
1014-
enableSoftwareRendering: (json['enableSoftwareRendering'] as bool?)!,
1015-
skiaDeterministicRendering: (json['skiaDeterministicRendering'] as bool?)!,
1016-
traceSkia: (json['traceSkia'] as bool?)!,
1007+
debuggingEnabled: json['debuggingEnabled']! as bool,
1008+
startPaused: json['startPaused']! as bool,
1009+
dartFlags: json['dartFlags']! as String,
1010+
dartEntrypointArgs: (json['dartEntrypointArgs']! as List<dynamic>).cast<String>(),
1011+
disableServiceAuthCodes: json['disableServiceAuthCodes']! as bool,
1012+
enableDds: json['enableDds']! as bool,
1013+
cacheStartupProfile: json['cacheStartupProfile']! as bool,
1014+
enableSoftwareRendering: json['enableSoftwareRendering']! as bool,
1015+
skiaDeterministicRendering: json['skiaDeterministicRendering']! as bool,
1016+
traceSkia: json['traceSkia']! as bool,
10171017
traceAllowlist: json['traceAllowlist'] as String?,
10181018
traceSkiaAllowlist: json['traceSkiaAllowlist'] as String?,
1019-
traceSystrace: (json['traceSystrace'] as bool?)!,
1020-
endlessTraceBuffer: (json['endlessTraceBuffer'] as bool?)!,
1021-
dumpSkpOnShaderCompilation: (json['dumpSkpOnShaderCompilation'] as bool?)!,
1022-
cacheSkSL: (json['cacheSkSL'] as bool?)!,
1023-
purgePersistentCache: (json['purgePersistentCache'] as bool?)!,
1024-
useTestFonts: (json['useTestFonts'] as bool?)!,
1025-
verboseSystemLogs: (json['verboseSystemLogs'] as bool?)!,
1019+
traceSystrace: json['traceSystrace']! as bool,
1020+
endlessTraceBuffer: json['endlessTraceBuffer']! as bool,
1021+
dumpSkpOnShaderCompilation: json['dumpSkpOnShaderCompilation']! as bool,
1022+
cacheSkSL: json['cacheSkSL']! as bool,
1023+
purgePersistentCache: json['purgePersistentCache']! as bool,
1024+
useTestFonts: json['useTestFonts']! as bool,
1025+
verboseSystemLogs: json['verboseSystemLogs']! as bool,
10261026
hostVmServicePort: json['hostVmServicePort'] as int? ,
10271027
deviceVmServicePort: json['deviceVmServicePort'] as int?,
1028-
disablePortPublication: (json['disablePortPublication'] as bool?)!,
1028+
disablePortPublication: json['disablePortPublication']! as bool,
10291029
ddsPort: json['ddsPort'] as int?,
10301030
devToolsServerAddress: json['devToolsServerAddress'] != null ? Uri.parse(json['devToolsServerAddress']! as String) : null,
10311031
port: json['port'] as String?,
10321032
hostname: json['hostname'] as String?,
10331033
webEnableExposeUrl: json['webEnableExposeUrl'] as bool?,
1034-
webUseSseForDebugProxy: (json['webUseSseForDebugProxy'] as bool?)!,
1035-
webUseSseForDebugBackend: (json['webUseSseForDebugBackend'] as bool?)!,
1036-
webUseSseForInjectedClient: (json['webUseSseForInjectedClient'] as bool?)!,
1037-
webRunHeadless: (json['webRunHeadless'] as bool?)!,
1034+
webUseSseForDebugProxy: json['webUseSseForDebugProxy']! as bool,
1035+
webUseSseForDebugBackend: json['webUseSseForDebugBackend']! as bool,
1036+
webUseSseForInjectedClient: json['webUseSseForInjectedClient']! as bool,
1037+
webRunHeadless: json['webRunHeadless']! as bool,
10381038
webBrowserDebugPort: json['webBrowserDebugPort'] as int?,
1039-
webBrowserFlags: ((json['webBrowserFlags'] as List<dynamic>?)?.cast<String>())!,
1040-
webEnableExpressionEvaluation: (json['webEnableExpressionEvaluation'] as bool?)!,
1039+
webBrowserFlags: (json['webBrowserFlags']! as List<dynamic>).cast<String>(),
1040+
webEnableExpressionEvaluation: json['webEnableExpressionEvaluation']! as bool,
10411041
webLaunchUrl: json['webLaunchUrl'] as String?,
10421042
vmserviceOutFile: json['vmserviceOutFile'] as String?,
1043-
fastStart: (json['fastStart'] as bool?)!,
1044-
nullAssertions: (json['nullAssertions'] as bool?)!,
1045-
nativeNullAssertions: (json['nativeNullAssertions'] as bool?)!,
1043+
fastStart: json['fastStart']! as bool,
1044+
nullAssertions: json['nullAssertions']! as bool,
1045+
nativeNullAssertions: json['nativeNullAssertions']! as bool,
10461046
enableImpeller: (json['enableImpeller'] as bool?) ?? false,
10471047
uninstallFirst: (json['uninstallFirst'] as bool?) ?? false,
10481048
enableDartProfiling: (json['enableDartProfiling'] as bool?) ?? true,

packages/flutter_tools/test/general.shard/application_package_test.dart

+3-3
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ void main() {
292292
globals.fs.directory('bundle.app').createSync();
293293
globals.fs.file('bundle.app/Info.plist').createSync();
294294
testPlistParser.setProperty('CFBundleIdentifier', 'fooBundleId');
295-
final PrebuiltIOSApp iosApp = (IOSApp.fromPrebuiltApp(globals.fs.file('bundle.app')) as PrebuiltIOSApp?)!;
295+
final PrebuiltIOSApp iosApp = IOSApp.fromPrebuiltApp(globals.fs.file('bundle.app'))! as PrebuiltIOSApp;
296296
expect(testLogger.errorText, isEmpty);
297297
expect(iosApp.uncompressedBundle.path, 'bundle.app');
298298
expect(iosApp.id, 'fooBundleId');
@@ -343,7 +343,7 @@ void main() {
343343
.file(globals.fs.path.join(bundleAppDir.path, 'Info.plist'))
344344
.createSync();
345345
};
346-
final PrebuiltIOSApp iosApp = (IOSApp.fromPrebuiltApp(globals.fs.file('app.ipa')) as PrebuiltIOSApp?)!;
346+
final PrebuiltIOSApp iosApp = IOSApp.fromPrebuiltApp(globals.fs.file('app.ipa'))! as PrebuiltIOSApp;
347347
expect(testLogger.errorText, isEmpty);
348348
expect(iosApp.uncompressedBundle.path, endsWith('bundle.app'));
349349
expect(iosApp.id, 'fooBundleId');
@@ -594,7 +594,7 @@ void main() {
594594

595595
testUsingContext('Success with far file', () {
596596
globals.fs.file('bundle.far').createSync();
597-
final PrebuiltFuchsiaApp fuchsiaApp = (FuchsiaApp.fromPrebuiltApp(globals.fs.file('bundle.far')) as PrebuiltFuchsiaApp?)!;
597+
final PrebuiltFuchsiaApp fuchsiaApp = FuchsiaApp.fromPrebuiltApp(globals.fs.file('bundle.far'))! as PrebuiltFuchsiaApp;
598598
expect(testLogger.errorText, isEmpty);
599599
expect(fuchsiaApp.id, 'bundle.far');
600600
expect(fuchsiaApp.applicationPackage.path, globals.fs.file('bundle.far').path);

packages/flutter_tools/test/general.shard/dap/mocks.dart

+3-3
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ class MockFlutterDebugAdapter extends FlutterDebugAdapter {
117117
// Pretend to be the client, delegating any reverse-requests to the relevant
118118
// handler that is provided by the test.
119119
if (message is Event && message.event == 'flutter.forwardedRequest') {
120-
final Map<String, Object?> body = (message.body as Map<String, Object?>?)!;
121-
final String method = (body['method'] as String?)!;
120+
final Map<String, Object?> body = message.body! as Map<String, Object?>;
121+
final String method = body['method']! as String;
122122
final Map<String, Object?>? params = body['params'] as Map<String, Object?>?;
123123

124124
final Object? result = _handleReverseRequest(method, params);
@@ -138,7 +138,7 @@ class MockFlutterDebugAdapter extends FlutterDebugAdapter {
138138
Object? _handleReverseRequest(String method, Map<String, Object?>? params) {
139139
switch (method) {
140140
case 'app.exposeUrl':
141-
final String url = (params!['url'] as String?)!;
141+
final String url = params!['url']! as String;
142142
return exposeUrlHandler!(url);
143143
default:
144144
throw ArgumentError('Reverse-request $method is unknown');

packages/flutter_tools/test/integration.shard/hot_reload_test.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,6 @@ bool _isHotReloadCompletionEvent(Map<String, Object?>? event) {
193193
return event != null &&
194194
event['event'] == 'app.progress' &&
195195
event['params'] != null &&
196-
(event['params'] as Map<String, Object?>?)!['progressId'] == 'hot.reload' &&
197-
(event['params'] as Map<String, Object?>?)!['finished'] == true;
196+
(event['params']! as Map<String, Object?>)['progressId'] == 'hot.reload' &&
197+
(event['params']! as Map<String, Object?>)['finished'] == true;
198198
}

packages/flutter_tools/test/integration.shard/template_manifest_test.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ void main() {
1414
fileSystem.file('templates/template_manifest.json').readAsStringSync(),
1515
) as Map<String, Object?>;
1616
final Set<Uri> declaredFileList = Set<Uri>.from(
17-
(manifest['files'] as List<Object?>?)!.cast<String>().map<Uri>(fileSystem.path.toUri));
17+
(manifest['files']! as List<Object?>).cast<String>().map<Uri>(fileSystem.path.toUri));
1818

1919
final Set<Uri> activeTemplateList = fileSystem.directory('templates')
2020
.listSync(recursive: true)

0 commit comments

Comments
 (0)