textScaler method
- @preferInline
- String key = FlutterPropertyKeys.textScaler,
- TextScaler defaultValue = TextScaler.noScaling,
- Object? target,
- bool warmUp = false,
Retrieves a TextScaler 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 TextScaler,
it is returned as is. If the value is a Map<String, dynamic>, it attempts to parse it into a TextScaler.
Otherwise, it returns defaultValue.
key: The key to look up in the JSON map. Defaults to 'textScaler'.defaultValue: The value to return if the key is not found or cannot be resolved. Defaults to TextScaler.noScaling.
Returns:
- A TextScaler if the value is valid or can be parsed.
defaultValueif the value is not a valid TextScaler or cannot be parsed.nullif both the value anddefaultValueare null.
Implementation
@preferInline
TextScaler textScaler({
String key = FlutterPropertyKeys.textScaler,
TextScaler defaultValue = TextScaler.noScaling,
Object? target,
bool warmUp = false,
}) {
final value = _readProp(key, target, warmUp);
if (value is TextScaler) return value;
if (value == null) return defaultValue;
switch (value) {
case Map<String, dynamic>():
if (envAttributeWarmUpEnabled) {
if (warmUp) {
return _textScalerFromMap(value);
} else {
return _json[key] = _textScalerFromMap(value);
}
} else {
return _json[key] = _textScalerFromMap(value);
}
case double():
if (envAttributeWarmUpEnabled) {
if (warmUp) {
return TextScaler.linear(value);
} else {
return _json[key] = TextScaler.linear(value);
}
} else {
return _json[key] = TextScaler.linear(value);
}
default:
return defaultValue;
}
}