stringToTextDecoration function
Implementation
TextDecoration? stringToTextDecoration(String data) {
if (!data.contains('combine')) {
switch (data) {
case 'TextDecoration.none':
return TextDecoration.none;
case 'TextDecoration.underline':
return TextDecoration.underline;
case 'TextDecoration.overline':
return TextDecoration.overline;
case 'TextDecoration.lineThrough':
return TextDecoration.lineThrough;
default:
return TextDecoration.none;
}
}
final List<String> values = data.split('[')[1].split(']')[0].split(', ');
final List<TextDecoration> decorations = <TextDecoration>[];
for (final String value in values) {
switch (value) {
case 'underline':
decorations.add(TextDecoration.underline);
break;
case 'overline':
decorations.add(TextDecoration.overline);
break;
case 'lineThrough':
decorations.add(TextDecoration.lineThrough);
break;
default:
break;
}
}
return TextDecoration.combine(decorations);
}