Skip to content

Commit 6a9fb1a

Browse files
committed
Make CSS camelCase (Css)
1 parent 9661568 commit 6a9fb1a

File tree

5 files changed

+33
-33
lines changed

5 files changed

+33
-33
lines changed

example/lib/main.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ class _MyHomePageState extends State<MyHomePage> {
303303
onImageError: (exception, stackTrace) {
304304
print(exception);
305305
},
306-
onCSSParseError: (css, messages) {
306+
onCssParseError: (css, messages) {
307307
print("css that errored: $css");
308308
print("error messages:");
309309
messages.forEach((element) {

lib/flutter_html.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class Html extends StatelessWidget {
5353
this.onLinkTap,
5454
this.customRender = const {},
5555
this.customImageRenders = const {},
56-
this.onCSSParseError,
56+
this.onCssParseError,
5757
this.onImageError,
5858
this.onMathError,
5959
this.shrinkWrap = false,
@@ -72,7 +72,7 @@ class Html extends StatelessWidget {
7272
this.onLinkTap,
7373
this.customRender = const {},
7474
this.customImageRenders = const {},
75-
this.onCSSParseError,
75+
this.onCssParseError,
7676
this.onImageError,
7777
this.onMathError,
7878
this.shrinkWrap = false,
@@ -102,7 +102,7 @@ class Html extends StatelessWidget {
102102
final Map<ImageSourceMatcher, ImageRender> customImageRenders;
103103

104104
/// A function that defines what to do when CSS fails to parse
105-
final OnCSSParseError? onCSSParseError;
105+
final OnCssParseError? onCssParseError;
106106

107107
/// A function that defines what to do when an image errors
108108
final ImageErrorListener? onImageError;
@@ -153,7 +153,7 @@ class Html extends StatelessWidget {
153153
htmlData: doc,
154154
onLinkTap: onLinkTap,
155155
onImageTap: onImageTap,
156-
onCSSParseError: onCSSParseError,
156+
onCssParseError: onCssParseError,
157157
onImageError: onImageError,
158158
onMathError: onMathError,
159159
shrinkWrap: shrinkWrap,

lib/html_parser.dart

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ typedef OnMathError = Widget Function(
2828
String exception,
2929
String exceptionWithType,
3030
);
31-
typedef OnCSSParseError = String? Function(
31+
typedef OnCssParseError = String? Function(
3232
String css,
3333
List<cssparser.Message> errors,
3434
);
@@ -42,7 +42,7 @@ class HtmlParser extends StatelessWidget {
4242
final dom.Document htmlData;
4343
final OnTap? onLinkTap;
4444
final OnTap? onImageTap;
45-
final OnCSSParseError? onCSSParseError;
45+
final OnCssParseError? onCssParseError;
4646
final ImageErrorListener? onImageError;
4747
final OnMathError? onMathError;
4848
final bool shrinkWrap;
@@ -59,7 +59,7 @@ class HtmlParser extends StatelessWidget {
5959
required this.htmlData,
6060
required this.onLinkTap,
6161
required this.onImageTap,
62-
required this.onCSSParseError,
62+
required this.onCssParseError,
6363
required this.onImageError,
6464
required this.onMathError,
6565
required this.shrinkWrap,
@@ -72,18 +72,18 @@ class HtmlParser extends StatelessWidget {
7272

7373
@override
7474
Widget build(BuildContext context) {
75-
Map<String, Map<String, List<css.Expression>>> declarations = _getExternalCSSDeclarations(htmlData.getElementsByTagName("style"), onCSSParseError);
75+
Map<String, Map<String, List<css.Expression>>> declarations = _getExternalCssDeclarations(htmlData.getElementsByTagName("style"), onCssParseError);
7676
StyledElement lexedTree = lexDomTree(
7777
htmlData,
7878
customRender.keys.toList(),
7979
tagsList,
8080
navigationDelegateForIframe,
8181
);
82-
StyledElement? externalCSSStyledTree;
82+
StyledElement? externalCssStyledTree;
8383
if (declarations.isNotEmpty) {
84-
externalCSSStyledTree = _applyExternalCSS(declarations, lexedTree);
84+
externalCssStyledTree = _applyExternalCss(declarations, lexedTree);
8585
}
86-
StyledElement inlineStyledTree = _applyInlineStyles(externalCSSStyledTree ?? lexedTree, onCSSParseError);
86+
StyledElement inlineStyledTree = _applyInlineStyles(externalCssStyledTree ?? lexedTree, onCssParseError);
8787
StyledElement customStyledTree = _applyCustomStyles(style, inlineStyledTree);
8888
StyledElement cascadedStyledTree = _cascadeStyles(style, customStyledTree);
8989
StyledElement cleanedTree = cleanTree(cascadedStyledTree);
@@ -119,8 +119,8 @@ class HtmlParser extends StatelessWidget {
119119
return htmlparser.parse(data);
120120
}
121121

122-
/// [parseCSS] converts a string of CSS to a CSS stylesheet using the dart `csslib` library.
123-
static css.StyleSheet parseCSS(String data) {
122+
/// [parseCss] converts a string of CSS to a CSS stylesheet using the dart `csslib` library.
123+
static css.StyleSheet parseCss(String data) {
124124
return cssparser.parse(data);
125125
}
126126

@@ -200,34 +200,34 @@ class HtmlParser extends StatelessWidget {
200200
}
201201
}
202202

203-
static Map<String, Map<String, List<css.Expression>>> _getExternalCSSDeclarations(List<dom.Element> styles, OnCSSParseError? errorHandler) {
204-
String fullCSS = "";
203+
static Map<String, Map<String, List<css.Expression>>> _getExternalCssDeclarations(List<dom.Element> styles, OnCssParseError? errorHandler) {
204+
String fullCss = "";
205205
for (final e in styles) {
206-
fullCSS = fullCSS + e.innerHtml;
206+
fullCss = fullCss + e.innerHtml;
207207
}
208-
if (fullCSS.isNotEmpty) {
209-
final declarations = parseExternalCSS(fullCSS, errorHandler);
208+
if (fullCss.isNotEmpty) {
209+
final declarations = parseExternalCss(fullCss, errorHandler);
210210
return declarations;
211211
} else {
212212
return {};
213213
}
214214
}
215215

216-
static StyledElement _applyExternalCSS(Map<String, Map<String, List<css.Expression>>> declarations, StyledElement tree) {
216+
static StyledElement _applyExternalCss(Map<String, Map<String, List<css.Expression>>> declarations, StyledElement tree) {
217217
declarations.forEach((key, style) {
218218
if (tree.matchesSelector(key)) {
219219
tree.style = tree.style.merge(declarationsToStyle(style));
220220
}
221221
});
222222

223-
tree.children.forEach((e) => _applyExternalCSS(declarations, e));
223+
tree.children.forEach((e) => _applyExternalCss(declarations, e));
224224

225225
return tree;
226226
}
227227

228-
static StyledElement _applyInlineStyles(StyledElement tree, OnCSSParseError? errorHandler) {
228+
static StyledElement _applyInlineStyles(StyledElement tree, OnCssParseError? errorHandler) {
229229
if (tree.attributes.containsKey("style")) {
230-
final newStyle = inlineCSSToStyle(tree.attributes['style'], errorHandler);
230+
final newStyle = inlineCssToStyle(tree.attributes['style'], errorHandler);
231231
if (newStyle != null) {
232232
tree.style = tree.style.merge(newStyle);
233233
}

lib/src/css_parser.dart

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -103,30 +103,30 @@ Style declarationsToStyle(Map<String, List<css.Expression>> declarations) {
103103
return style;
104104
}
105105

106-
Style? inlineCSSToStyle(String? inlineStyle, OnCSSParseError? errorHandler) {
106+
Style? inlineCssToStyle(String? inlineStyle, OnCssParseError? errorHandler) {
107107
var errors = <cssparser.Message>[];
108108
final sheet = cssparser.parse("*{$inlineStyle}", errors: errors);
109109
if (errors.isEmpty) {
110110
final declarations = DeclarationVisitor().getDeclarations(sheet);
111111
return declarationsToStyle(declarations["*"]!);
112112
} else if (errorHandler != null) {
113-
String? newCSS = errorHandler.call(inlineStyle ?? "", errors);
114-
if (newCSS != null) {
115-
return inlineCSSToStyle(newCSS, errorHandler);
113+
String? newCss = errorHandler.call(inlineStyle ?? "", errors);
114+
if (newCss != null) {
115+
return inlineCssToStyle(newCss, errorHandler);
116116
}
117117
}
118118
return null;
119119
}
120120

121-
Map<String, Map<String, List<css.Expression>>> parseExternalCSS(String css, OnCSSParseError? errorHandler) {
121+
Map<String, Map<String, List<css.Expression>>> parseExternalCss(String css, OnCssParseError? errorHandler) {
122122
var errors = <cssparser.Message>[];
123123
final sheet = cssparser.parse(css, errors: errors);
124124
if (errors.isEmpty) {
125125
return DeclarationVisitor().getDeclarations(sheet);
126126
} else if (errorHandler != null) {
127-
String? newCSS = errorHandler.call(css, errors);
128-
if (newCSS != null) {
129-
return parseExternalCSS(newCSS, errorHandler);
127+
String? newCss = errorHandler.call(css, errors);
128+
if (newCss != null) {
129+
return parseExternalCss(newCss, errorHandler);
130130
}
131131
}
132132
return {};

lib/style.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,8 @@ class Style {
242242
'body': Style.fromTextStyle(theme.textTheme.bodyText2!),
243243
};
244244

245-
static Map<String, Style> fromCSS(String css, OnCSSParseError? onCSSParseError) {
246-
final declarations = parseExternalCSS(css, onCSSParseError);
245+
static Map<String, Style> fromCss(String css, OnCssParseError? onCssParseError) {
246+
final declarations = parseExternalCss(css, onCssParseError);
247247
Map<String, Style> styleMap = {};
248248
declarations.forEach((key, value) {
249249
styleMap[key] = declarationsToStyle(value);

0 commit comments

Comments
 (0)