@@ -41,6 +41,26 @@ Style declarationsToStyle(Map<String, List<css.Expression>> declarations) {
4141 case 'text-align' :
4242 style.textAlign = ExpressionMapping .expressionToTextAlign (value.first);
4343 break ;
44+ case 'text-decoration' :
45+ List <css.LiteralTerm > exp1 = value.whereType< css.LiteralTerm > ().toList ();
46+ exp1.removeWhere ((element) => element.text != "overline" && element.text != "underline" && element.text != "line-through" );
47+ css.Expression exp2 = value.firstWhere ((element) => element is css.HexColorTerm || element is css.FunctionTerm , orElse: null );
48+ List <css.LiteralTerm > temp = value.whereType< css.LiteralTerm > ().toList ();
49+ temp.removeWhere ((element) => element is css.HexColorTerm || element is css.FunctionTerm );
50+ css.LiteralTerm exp3 = temp.last ?? null ;
51+ style.textDecoration = ExpressionMapping .expressionToTextDecorationLine (exp1);
52+ if (exp2 != null ) style.textDecorationColor = ExpressionMapping .expressionToColor (exp2);
53+ if (exp3 != null ) style.textDecorationStyle = ExpressionMapping .expressionToTextDecorationStyle (exp3);
54+ break ;
55+ case 'text-decoration-color' :
56+ style.textDecorationColor = ExpressionMapping .expressionToColor (value.first);
57+ break ;
58+ case 'text-decoration-line' :
59+ style.textDecoration = ExpressionMapping .expressionToTextDecorationLine (value);
60+ break ;
61+ case 'text-decoration-style' :
62+ style.textDecorationStyle = ExpressionMapping .expressionToTextDecorationStyle (value.first);
63+ break ;
4464 case 'text-shadow' :
4565 style.textShadow = ExpressionMapping .expressionToTextShadow (value);
4666 break ;
@@ -268,6 +288,42 @@ class ExpressionMapping {
268288 return TextAlign .start;
269289 }
270290
291+ static TextDecoration expressionToTextDecorationLine (List <css.LiteralTerm > value) {
292+ List <TextDecoration > decorationList = [];
293+ for (css.LiteralTerm term in value) {
294+ switch (term.text) {
295+ case "overline" :
296+ decorationList.add (TextDecoration .overline);
297+ break ;
298+ case "underline" :
299+ decorationList.add (TextDecoration .underline);
300+ break ;
301+ case "line-through" :
302+ decorationList.add (TextDecoration .lineThrough);
303+ break ;
304+ default :
305+ decorationList.add (TextDecoration .none);
306+ break ;
307+ }
308+ }
309+ return TextDecoration .combine (decorationList);
310+ }
311+
312+ static TextDecorationStyle expressionToTextDecorationStyle (css.LiteralTerm value) {
313+ switch (value.text) {
314+ case "wavy" :
315+ return TextDecorationStyle .wavy;
316+ case "dotted" :
317+ return TextDecorationStyle .dotted;
318+ case "dashed" :
319+ return TextDecorationStyle .dashed;
320+ case "double" :
321+ return TextDecorationStyle .double ;
322+ default :
323+ return TextDecorationStyle .solid;
324+ }
325+ }
326+
271327 static List <Shadow > expressionToTextShadow (List <css.Expression > value) {
272328 List <Shadow > shadow = [];
273329 List <int > indices = [];
0 commit comments