Unverified Commit e5d7bab1 authored by Jacob Richman's avatar Jacob Richman Committed by GitHub

Fix null safety error in inspector service extensions taking a variable number of args. (#68661)

* Fix null safety error in inspector service extensions taking variable numbers of args.

Fixes https://github.com/flutter/flutter/issues/68627.
Also fix all inspector tests that do not rely on golden image functionality
so that they run with --enable-experiment=non-nullable. This verifies there
is test coverage to ensure there isn't a regression.

* Remove uses of dynamic.
parent bcac9d4f
......@@ -880,17 +880,18 @@ mixin WidgetInspectorService {
registerServiceExtension(
name: name,
callback: (Map<String, String> parameters) async {
const String argPrefix = 'arg';
final List<String> args = <String>[];
parameters.forEach((String name, String value) {
if (name.startsWith(argPrefix)) {
final int index = int.parse(name.substring(argPrefix.length));
if (index >= args.length) {
args.length = index + 1;
}
args[index] = value;
int index = 0;
while (true) {
final String name = 'arg$index';
if (parameters.containsKey(name)) {
args.add(parameters[name]!);
} else {
break;
}
});
index++;
}
assert(index == parameters.length);
return <String, Object?>{'result': await callback(args)};
},
);
......
......@@ -30,7 +30,7 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService {
}
List<Map<Object, Object?>> getEventsDispatched(String eventKind) {
return eventsDispatched.putIfAbsent(eventKind, () => <Map<Object, Object>>[]);
return eventsDispatched.putIfAbsent(eventKind, () => <Map<Object, Object?>>[]);
}
Iterable<Map<Object, Object?>> getServiceExtensionStateChangedEvents(String extensionName) {
......
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