textDecoration static method
Returns a TextDecoration from the specified list or string.
If the key identifies a list, then each entry in the list is decoded by recursively invoking textDecoration, and the result is the combination of those TextDecoration values as obtained using TextDecoration.combine.
Otherwise, if the key identifies a string, then the value lineThrough is
mapped to TextDecoration.lineThrough, overline to
TextDecoration.overline, and underline to TextDecoration.underline.
Other values (and the abscence of a value) are interpreted as
TextDecoration.none.
@return null|String|List
Implementation
static dynamic textDecoration(TextDecoration? decoration) {
if (decoration == null) return null;
String type = decoration.toString();
if (type.startsWith('TextDecoration.combine')) {
List<String> combine = type
.substring('TextDecoration.combine('.length, type.length - 1)
.split(', ');
if (combine.isEmpty) return null;
if (combine.length == 1) return [combine.first];
return combine;
} else {
switch (decoration) {
case TextDecoration.lineThrough:
return 'lineThrough';
case TextDecoration.overline:
return 'overline';
case TextDecoration.underline:
return 'underline';
default:
return null;
}
}
}