setServiceExtensionState method
Sets the state for a service extension and makes the call to the VMService.
Implementation
Future<void> setServiceExtensionState(
String name, {
required bool enabled,
required Object? value,
bool callExtension = true,
}) async {
if (callExtension && _serviceExtensions.contains(name)) {
await _callServiceExtension(name, value);
} else if (callExtension) {
_log.info(
'Attempted to call extension \'$name\', but no service with that name exists',
);
}
final state = ServiceExtensionState(enabled: enabled, value: value);
_serviceExtensionState(name).value = state;
// Add or remove service extension from [enabledServiceExtensions].
if (enabled) {
_enabledServiceExtensions[name] = state;
} else {
_enabledServiceExtensions.remove(name);
}
}