mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
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:
parent
988d1a0679
commit
0cef3f1629
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user