lookupExtensionEnabledState method
Returns the current enabled state for extensionName
in the
'devtools_options.yaml' file at devtoolsOptionsUri
.
If the 'devtools_options.yaml' file does not exist, it will be created with an empty set of extensions.
devtoolsOptionsUri
is expected to be a file:// URI.
Implementation
ExtensionEnabledState lookupExtensionEnabledState({
required Uri devtoolsOptionsUri,
required String extensionName,
}) {
final options = _optionsAsMap(optionsUri: devtoolsOptionsUri);
if (options == null) return ExtensionEnabledState.error;
final extensions =
(options[_extensionsKey] as List?)?.cast<Map<String, Object?>>();
if (extensions == null) return ExtensionEnabledState.none;
for (final e in extensions) {
// Each entry should only have one key / value pair (e.g. '- foo: true').
assert(e.keys.length == 1);
if (e.keys.first == extensionName) {
return _extensionStateForValue(e[extensionName]);
}
}
return ExtensionEnabledState.none;
}