Skip to content

Commit 58464dc

Browse files
committed
flutter format
1 parent 1686b19 commit 58464dc

File tree

6 files changed

+54
-31
lines changed

6 files changed

+54
-31
lines changed

example/lib/main.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,10 @@ class _MyHomePageState extends State<MyHomePage> {
132132
@override
133133
Widget build(BuildContext context) {
134134
return new Scaffold(
135-
appBar: AppBar(title: Text('flutter_html Example'), centerTitle: true,),
135+
appBar: AppBar(
136+
title: Text('flutter_html Example'),
137+
centerTitle: true,
138+
),
136139
body: SingleChildScrollView(
137140
child: Html(
138141
data: htmlData,

lib/html_parser.dart

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@ class HtmlParser extends StatelessWidget {
142142

143143
///TODO document
144144
static StyledElement applyCSS(StyledElement tree) {
145-
146145
//Make sure style is never null.
147146
if (tree.style == null) {
148147
tree.style = Style();
@@ -398,7 +397,7 @@ class HtmlParser extends StatelessWidget {
398397
if (tree.style.display == Display.BLOCK) {
399398
wpc.data = false;
400399
}
401-
400+
402401
if (tree is ImageContentElement || tree is SvgContentElement) {
403402
wpc.data = false;
404403
}
@@ -476,10 +475,12 @@ class HtmlParser extends StatelessWidget {
476475
/// properties.
477476
static StyledElement _processBeforesAndAfters(StyledElement tree) {
478477
if (tree.style?.before != null) {
479-
tree.children?.insert(0, TextContentElement(text: tree.style.before, style: tree.style));
478+
tree.children?.insert(
479+
0, TextContentElement(text: tree.style.before, style: tree.style));
480480
}
481481
if (tree.style?.after != null) {
482-
tree.children?.add(TextContentElement(text: tree.style.after, style: tree.style));
482+
tree.children
483+
?.add(TextContentElement(text: tree.style.after, style: tree.style));
483484
} else {
484485
tree.children?.forEach(_processBeforesAndAfters);
485486
}
@@ -711,7 +712,10 @@ class StyledText extends StatelessWidget {
711712
@override
712713
Widget build(BuildContext context) {
713714
return SizedBox(
714-
width: style.display == Display.BLOCK || style.display == Display.LIST_ITEM? double.infinity: null,
715+
width:
716+
style.display == Display.BLOCK || style.display == Display.LIST_ITEM
717+
? double.infinity
718+
: null,
715719
child: Text.rich(
716720
textSpan,
717721
style: style.generateTextStyle(),

lib/style.dart

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,6 @@ class Style {
184184
this.whiteSpace,
185185
this.width,
186186
this.wordSpacing,
187-
188187
this.before,
189188
this.after,
190189
this.border,
@@ -309,7 +308,6 @@ class Style {
309308
WhiteSpace whiteSpace,
310309
double width,
311310
double wordSpacing,
312-
313311
String before,
314312
String after,
315313
Border border,
@@ -335,13 +333,13 @@ class Style {
335333
textDecoration: textDecoration ?? this.textDecoration,
336334
textDecorationColor: textDecorationColor ?? this.textDecorationColor,
337335
textDecorationStyle: textDecorationStyle ?? this.textDecorationStyle,
338-
textDecorationThickness: textDecorationThickness ?? this.textDecorationThickness,
336+
textDecorationThickness:
337+
textDecorationThickness ?? this.textDecorationThickness,
339338
textShadow: textShadow ?? this.textShadow,
340339
verticalAlign: verticalAlign ?? this.verticalAlign,
341340
whiteSpace: whiteSpace ?? this.whiteSpace,
342341
width: width ?? this.width,
343342
wordSpacing: wordSpacing ?? this.wordSpacing,
344-
345343
before: before ?? this.before,
346344
after: after ?? this.after,
347345
border: border ?? this.border,

test/golden_test.dart

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ void main() {
4646
testWidgets('whitespace golden test', (WidgetTester tester) async {
4747
await tester.pumpWidget(
4848
TestApp(
49-
Html(
50-
data: """
49+
Html(data: """
5150
<p id='whitespace'>
5251
These two lines should have an identical length:<br /><br />
5352
@@ -60,8 +59,7 @@ void main() {
6059
dog.<br />
6160
The quick brown fox jumped over the lazy dog.
6261
</p>
63-
"""
64-
),
62+
"""),
6563
),
6664
);
6765
// await expectLater(find.byType(Html), matchesGoldenFile('./goldens/whitespace.png'));

test/html_parser_test.dart

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,26 +28,37 @@ void testNewParser() {
2828
});
2929

3030
test("lexDomTree works correctly", () {
31-
StyledElement tree = HtmlParser.lexDomTree(HtmlParser.parseHTML(
32-
"Hello! <b>Hello, World!</b><i>Hello, New World!</i>"), [], []);
31+
StyledElement tree = HtmlParser.lexDomTree(
32+
HtmlParser.parseHTML(
33+
"Hello! <b>Hello, World!</b><i>Hello, New World!</i>"),
34+
[],
35+
[]);
3336
print(tree.toString());
3437
});
3538

3639
test("InteractableElements work correctly", () {
37-
StyledElement tree = HtmlParser.lexDomTree(HtmlParser.parseHTML(
38-
"Hello, World! <a href='https://example.com'>This is a link</a>"), [], []);
40+
StyledElement tree = HtmlParser.lexDomTree(
41+
HtmlParser.parseHTML(
42+
"Hello, World! <a href='https://example.com'>This is a link</a>"),
43+
[],
44+
[]);
3945
print(tree.toString());
4046
});
4147

4248
test("ContentElements work correctly", () {
4349
StyledElement tree = HtmlParser.lexDomTree(
44-
HtmlParser.parseHTML("<img src='https://image.example.com' />"), [], []);
50+
HtmlParser.parseHTML("<img src='https://image.example.com' />"),
51+
[],
52+
[]);
4553
print(tree.toString());
4654
});
4755

4856
test("Nesting of elements works correctly", () {
49-
StyledElement tree = HtmlParser.lexDomTree(HtmlParser.parseHTML(
50-
"<div><div><div><div><a href='link'>Link</a><div>Hello, World! <b>Bold and <i>Italic</i></b></div></div></div></div></div>"), [], []);
57+
StyledElement tree = HtmlParser.lexDomTree(
58+
HtmlParser.parseHTML(
59+
"<div><div><div><div><a href='link'>Link</a><div>Hello, World! <b>Bold and <i>Italic</i></b></div></div></div></div></div>"),
60+
[],
61+
[]);
5162
print(tree.toString());
5263
});
5364

test/test_data.dart

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ const testData = <String, String>{
2424
'dl': '<dl>Hello, World!</dl>',
2525
'dt': '<dt>Hello, World!</dt>',
2626
'em': '<em>Hello, World!</em>',
27-
'figcaption_figure': '<figure><figcaption>Hello, World!</figcaption></figure>',
27+
'figcaption_figure':
28+
'<figure><figcaption>Hello, World!</figcaption></figure>',
2829
'font': '<font>Hello, World!</font>',
2930
'footer': '<footer>Hello, World!</footer>',
3031
'h1': '<h1>Hello, World!</h1>',
@@ -36,7 +37,8 @@ const testData = <String, String>{
3637
'header': '<header>Hello, World!</header>',
3738
'hr': '<div>Hello</div><hr /><div>World!</div>',
3839
'i': '<i>Hello, World!</i>',
39-
'img': '<img alt="Hello, World!" src="https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png" />',
40+
'img':
41+
'<img alt="Hello, World!" src="https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png" />',
4042
'img_alt': '<img alt="Hello, World!" src="" />',
4143
'ins': '<ins>Hello, World!</ins>',
4244
'kbd': '<kbd>Hello, World!</kbd>',
@@ -61,16 +63,23 @@ const testData = <String, String>{
6163
'strong': '<strong>Hello, World!</strong>',
6264
'sub': '<sub>Hello, World!</sub>',
6365
'sup': '<sup>Hello, World!</sup>',
64-
'table': '<table><tr><th>Hello</th><th>World!</th></tr><tr><td>Hello</td><td>World!</td></tr></table>',
65-
'tbody': '<table><tr><th>Hello</th><th>World!</th></tr><tbody><tr><td>Hello</td><td>World!</td></tr></tbody></table>',
66-
'td': '<table><tr><th>Hello</th><th>World!</th></tr><tr><td>Hello</td><td>World!</td></tr></table>',
66+
'table':
67+
'<table><tr><th>Hello</th><th>World!</th></tr><tr><td>Hello</td><td>World!</td></tr></table>',
68+
'tbody':
69+
'<table><tr><th>Hello</th><th>World!</th></tr><tbody><tr><td>Hello</td><td>World!</td></tr></tbody></table>',
70+
'td':
71+
'<table><tr><th>Hello</th><th>World!</th></tr><tr><td>Hello</td><td>World!</td></tr></table>',
6772
'template': '<template>Hello, World!</template>',
68-
'tfoot': '<table><tr><th>Hello</th><th>World!</th></tr><tfoot><tr><td>Hello</td><td>World!</td></tr></tfoot></table>',
69-
'th': '<table><tr><th>Hello</th><th>World!</th></tr><tr><td>Hello</td><td>World!</td></tr></table>',
70-
'thead': '<table><thead><tr><th>Hello</th><th>World!</th></tr></thead><tr><td>Hello</td><td>World!</td></tr></table>',
73+
'tfoot':
74+
'<table><tr><th>Hello</th><th>World!</th></tr><tfoot><tr><td>Hello</td><td>World!</td></tr></tfoot></table>',
75+
'th':
76+
'<table><tr><th>Hello</th><th>World!</th></tr><tr><td>Hello</td><td>World!</td></tr></table>',
77+
'thead':
78+
'<table><thead><tr><th>Hello</th><th>World!</th></tr></thead><tr><td>Hello</td><td>World!</td></tr></table>',
7179
'time': '<time>3:00 PM</time>',
72-
'tr': '<table><tr><th>Hello</th><th>World!</th></tr><tr><td>Hello</td><td>World!</td></tr></table>',
80+
'tr':
81+
'<table><tr><th>Hello</th><th>World!</th></tr><tr><td>Hello</td><td>World!</td></tr></table>',
7382
'tt': '<tt>Hello, World!</tt>',
7483
'u': '<u>Hello, World!</u>',
7584
'var': '<var>Hello, World!</var>',
76-
};
85+
};

0 commit comments

Comments
 (0)