Skip to content

Commit 974def2

Browse files
committed
Add support for style.fromCSS
1 parent 0f194f1 commit 974def2

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lib/style.dart

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import 'dart:ui';
22

33
import 'package:flutter/material.dart';
4+
import 'package:flutter_html/src/css_parser.dart';
45

56
///This class represents all the available CSS attributes
67
///for this package.
@@ -214,6 +215,15 @@ class Style {
214215
}
215216
}
216217

218+
static Map<String, Style> fromCSS(String css) {
219+
final declarations = parseExternalCSS(css);
220+
Map<String, Style> styleMap = {};
221+
declarations.forEach((key, value) {
222+
styleMap[key] = declarationsToStyle(value);
223+
});
224+
return styleMap;
225+
}
226+
217227
TextStyle generateTextStyle() {
218228
return TextStyle(
219229
backgroundColor: backgroundColor,

0 commit comments

Comments
 (0)