Correctly handle null case in ProcessText.queryTextActions (#141205)

Replace `as Map<Object?, Object?>` to handle nullable case
Fixes runtime issue in Wasm

*Replace this paragraph with a description of what this PR is changing or adding, and why. Consider including before/after screenshots.*

*List which issues are fixed by this PR. You must list at least one issue. An issue is not required if the PR fixes something trivial like a typo.*

*If you had to change anything in the [flutter/tests] repo, include a link to the migration guide as per the [breaking change policy].*
This commit is contained in:
Kevin Moore 2024-01-09 14:25:54 -08:00 committed by GitHub
parent 988d1a0679
commit 0cef3f1629
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -113,22 +113,27 @@ class DefaultProcessTextService implements ProcessTextService {
@override
Future<List<ProcessTextAction>> queryTextActions() async {
final List<ProcessTextAction> textActions = <ProcessTextAction>[];
final Map<Object?, Object?>? rawResults;
final Map<Object?, Object?> rawResults;
try {
rawResults = await _processTextChannel.invokeMethod(
final Map<Object?, Object?>? result =
await _processTextChannel.invokeMethod(
'ProcessText.queryTextActions',
) as Map<Object?, Object?>;
) as Map<Object?, Object?>?;
if (result == null) {
return <ProcessTextAction>[];
}
rawResults = result;
} catch (e) {
return textActions;
return <ProcessTextAction>[];
}
for (final Object? id in rawResults.keys) {
textActions.add(ProcessTextAction(id! as String, rawResults[id]! as String));
}
return textActions;
return <ProcessTextAction>[
for (final Object? id in rawResults.keys)
ProcessTextAction(id! as String, rawResults[id]! as String),
];
}
@override