decodeTargetPlatform static method
Decodes a value
to a TargetPlatform. Supported values are:
android
fuchsia
iOS
linux
macOS
windows
Implementation
static TargetPlatform? decodeTargetPlatform(
dynamic value, {
bool validate = true,
}) {
TargetPlatform? result;
if (value is TargetPlatform) {
result = value;
} else {
_checkSupported(
'TargetPlatform',
[
'android',
'fuchsia',
'iOS',
'linux',
'macOS',
'windows',
],
value,
);
if (value != null) {
assert(SchemaValidator.validate(
schemaId: '$_baseSchemaUrl/target_platform',
value: value,
validate: validate,
));
switch (value) {
case 'android':
result = TargetPlatform.android;
break;
case 'fuchsia':
result = TargetPlatform.fuchsia;
break;
case 'iOS':
result = TargetPlatform.iOS;
break;
case 'linux':
result = TargetPlatform.linux;
break;
case 'macOS':
result = TargetPlatform.macOS;
break;
case 'windows':
result = TargetPlatform.windows;
break;
}
}
}
return result;
}