mainAxisSize method
- @preferInline
- String key = FlutterPropertyKeys.mainAxisSize,
- MainAxisSize? defaultValue,
- Object? target,
- bool warmUp = false,
Retrieves a MainAxisSize value from the JSON map for the given key.
Looks up the value associated with key in the JSON. If the value is already a MainAxisSize,
it is returned as is. If the value is a String or int, it is converted using the lookup tables.
Otherwise, it returns defaultValue.
key: The key to look up in the JSON map. Defaults to 'mainAxisSize'.defaultValue: The value to return if the key is not found or cannot be resolved. Defaults to null.
Returns:
- A MainAxisSize if the value is valid or can be parsed.
defaultValueif the value is not a valid MainAxisSize or cannot be parsed.nullif both the value anddefaultValueare null.
Implementation
@preferInline
MainAxisSize? mainAxisSize({
String key = FlutterPropertyKeys.mainAxisSize,
MainAxisSize? defaultValue,
Object? target,
bool warmUp = false,
}) {
final value = _readProp(key, target, warmUp);
if (value is MainAxisSize) return value;
if (value == null) return defaultValue;
switch (value) {
case String():
if (envAttributeWarmUpEnabled) {
if (warmUp) {
return _mainAxisSizeStringLookupTable[value];
} else {
return _json[key] = _mainAxisSizeStringLookupTable[value];
}
} else {
return _json[key] = _mainAxisSizeStringLookupTable[value];
}
case int():
if (envAttributeWarmUpEnabled) {
if (warmUp) {
return _mainAxisSizeIntLookupTable[value];
} else {
return _json[key] = _mainAxisSizeIntLookupTable[value];
}
} else {
return _json[key] = _mainAxisSizeIntLookupTable[value];
}
default:
return defaultValue;
}
}