Skip to content

Commit efc6650

Browse files
committed
Update files
1 parent 15bd5a2 commit efc6650

24 files changed

+694
-688
lines changed

demo_app/analysis_options.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ analyzer:
55
# TODO: remove this when it auto ignores `depend_on_referenced_packages`
66
- lib/generated_plugin_registrant.dart
77

8+
formatter:
9+
trailing_commas: preserve
10+
811
linter:
912
rules:
1013
always_put_control_body_on_new_line: true

demo_app/integration_test/auto_resize_test.dart

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ void main() {
1313
child: VideoPlayer(
1414
'https://flutter-widget-from-html.github.io/pages/flower.mp4',
1515
aspectRatio: 1,
16-
loadingBuilder: (_, __, ___) =>
16+
loadingBuilder: (_, _, _) =>
1717
const Center(child: CircularProgressIndicator()),
1818
),
1919
);
@@ -36,10 +36,11 @@ void main() {
3636
final testCase = webViewTestCases.currentValue!;
3737
final test = await testCase.run($);
3838

39-
for (var i = 0;; i++) {
39+
for (var i = 0; ; i++) {
4040
await $.pump();
41-
await $.tester
42-
.runAsync(() => Future.delayed(const Duration(seconds: 3)));
41+
await $.tester.runAsync(
42+
() => Future.delayed(const Duration(seconds: 3)),
43+
);
4344
await $.pump();
4445

4546
try {
@@ -70,7 +71,8 @@ class WebViewTestCase {
7071
});
7172

7273
Future<_AspectRatioTest> run(PatrolIntegrationTester $) async {
73-
final html = '''
74+
final html =
75+
'''
7476
<!doctype html>
7577
<head>
7678
<meta charset="utf-8">

demo_app/lib/main.dart

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ void main() {
1212
}
1313

1414
void _onLogRecord(LogRecord record) {
15-
final prefix = '${record.time.toIso8601String().substring(11)} '
15+
final prefix =
16+
'${record.time.toIso8601String().substring(11)} '
1617
'${record.loggerName}@${record.level.name} ';
1718
debugPrint('$prefix${record.message}');
1819

@@ -28,15 +29,15 @@ class MyApp extends StatelessWidget {
2829

2930
@override
3031
Widget build(BuildContext context) => PopupMenuStateProvider(
31-
builder: (context) => MaterialApp(
32-
title: 'Flutter Widget from HTML',
33-
theme: FlexThemeData.light(scheme: FlexScheme.blueM3),
34-
darkTheme: FlexThemeData.dark(scheme: FlexScheme.blueM3),
35-
showPerformanceOverlay: context.showPerformanceOverlay,
32+
builder: (context) => MaterialApp(
33+
title: 'Flutter Widget from HTML',
34+
theme: FlexThemeData.light(scheme: FlexScheme.blueM3),
35+
darkTheme: FlexThemeData.dark(scheme: FlexScheme.blueM3),
36+
showPerformanceOverlay: context.showPerformanceOverlay,
3637

37-
// let HomeScreen handle all the routings
38-
initialRoute: '/',
39-
onGenerateRoute: HomeScreen.onGenerateRoute,
40-
),
41-
);
38+
// let HomeScreen handle all the routings
39+
initialRoute: '/',
40+
onGenerateRoute: HomeScreen.onGenerateRoute,
41+
),
42+
);
4243
}

demo_app/lib/screens/audio.dart

Lines changed: 57 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -24,74 +24,75 @@ class _State extends State<AudioScreen> {
2424

2525
@override
2626
Widget build(BuildContext context) => Scaffold(
27-
appBar: AppBar(
28-
title: const Text('AudioScreen'),
27+
appBar: AppBar(
28+
title: const Text('AudioScreen'),
29+
),
30+
body: ListView(
31+
children: <Widget>[
32+
CheckboxListTile(
33+
value: autoplay,
34+
onChanged: (v) => _setState(() => autoplay = v == true),
35+
title: const Text('autoplay'),
2936
),
30-
body: ListView(
31-
children: <Widget>[
32-
CheckboxListTile(
33-
value: autoplay,
34-
onChanged: (v) => _setState(() => autoplay = v == true),
35-
title: const Text('autoplay'),
36-
),
37-
CheckboxListTile(
38-
value: loop,
39-
onChanged: (v) => _setState(() => loop = v == true),
40-
title: const Text('loop'),
41-
),
42-
CheckboxListTile(
43-
value: muted,
44-
onChanged: (v) => _setState(() => muted = v == true),
45-
title: const Text('muted'),
46-
),
47-
CheckboxListTile(
48-
value: preload,
49-
onChanged: (v) => _setState(() => preload = v == true),
50-
title: const Text('preload'),
51-
),
52-
ListTile(
53-
title: const Text('HTML:'),
54-
subtitle: Text(_html),
55-
),
56-
ListTile(
57-
title: const Text('Rendered:'),
58-
subtitle: HtmlWidget(
59-
_html,
60-
key: Key(_html),
61-
baseUrl: Uri.parse(
62-
'https://interactive-examples.mdn.mozilla.net/pages/tabbed/audio.html',
63-
),
64-
),
37+
CheckboxListTile(
38+
value: loop,
39+
onChanged: (v) => _setState(() => loop = v == true),
40+
title: const Text('loop'),
41+
),
42+
CheckboxListTile(
43+
value: muted,
44+
onChanged: (v) => _setState(() => muted = v == true),
45+
title: const Text('muted'),
46+
),
47+
CheckboxListTile(
48+
value: preload,
49+
onChanged: (v) => _setState(() => preload = v == true),
50+
title: const Text('preload'),
51+
),
52+
ListTile(
53+
title: const Text('HTML:'),
54+
subtitle: Text(_html),
55+
),
56+
ListTile(
57+
title: const Text('Rendered:'),
58+
subtitle: HtmlWidget(
59+
_html,
60+
key: Key(_html),
61+
baseUrl: Uri.parse(
62+
'https://interactive-examples.mdn.mozilla.net/pages/tabbed/audio.html',
6563
),
66-
const Center(child: Text('----')),
67-
],
64+
),
6865
),
69-
);
66+
const Center(child: Text('----')),
67+
],
68+
),
69+
);
7070

7171
void _setState(VoidCallback callback) => setState(() {
72-
callback();
72+
callback();
7373

74-
final attributes = <String>[];
75-
if (autoplay) {
76-
attributes.add('autoplay');
77-
}
78-
if (loop) {
79-
attributes.add('loop');
80-
}
81-
if (muted) {
82-
attributes.add('muted');
83-
}
84-
if (preload) {
85-
attributes.add('preload');
86-
}
74+
final attributes = <String>[];
75+
if (autoplay) {
76+
attributes.add('autoplay');
77+
}
78+
if (loop) {
79+
attributes.add('loop');
80+
}
81+
if (muted) {
82+
attributes.add('muted');
83+
}
84+
if (preload) {
85+
attributes.add('preload');
86+
}
8787

88-
_html = '''
88+
_html =
89+
'''
8990
<figure>
9091
<audio src="/media/cc0-audio/t-rex-roar.mp3" ${attributes.join(' ')}>
9192
Sorry, <code>AUDIO</code> tag is not supported.
9293
</audio>
9394
<figcaption>Source: <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/audio">developer.mozilla.org</a></figcaption>
9495
</figure>
9596
''';
96-
});
97+
});
9798
}

demo_app/lib/screens/custom_styles_builder.dart

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@ class CustomStylesBuilderScreen extends StatelessWidget {
88

99
@override
1010
Widget build(BuildContext context) => Scaffold(
11-
appBar: AppBar(
12-
title: const Text('CustomStylesBuilderScreen'),
13-
),
14-
body: Padding(
15-
padding: const EdgeInsets.all(8.0),
16-
child: HtmlWidget(
17-
kHtml,
18-
customStylesBuilder: (e) =>
19-
e.classes.contains('name') ? {'color': 'red'} : null,
20-
),
21-
),
22-
);
11+
appBar: AppBar(
12+
title: const Text('CustomStylesBuilderScreen'),
13+
),
14+
body: Padding(
15+
padding: const EdgeInsets.all(8.0),
16+
child: HtmlWidget(
17+
kHtml,
18+
customStylesBuilder: (e) =>
19+
e.classes.contains('name') ? {'color': 'red'} : null,
20+
),
21+
),
22+
);
2323
}

demo_app/lib/screens/custom_widget_builder.dart

Lines changed: 34 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -29,45 +29,44 @@ class CustomWidgetBuilderScreen extends StatelessWidget {
2929

3030
@override
3131
Widget build(BuildContext context) => Scaffold(
32-
appBar: AppBar(
33-
title: const Text('CustomWidgetBuilderScreen'),
34-
),
35-
body: SingleChildScrollView(
36-
child: Padding(
37-
padding: const EdgeInsets.all(8.0),
38-
child: HtmlWidget(
39-
kHtml,
40-
customWidgetBuilder: (e) {
41-
if (!e.classes.contains('carousel')) {
42-
return null;
43-
}
32+
appBar: AppBar(
33+
title: const Text('CustomWidgetBuilderScreen'),
34+
),
35+
body: SingleChildScrollView(
36+
child: Padding(
37+
padding: const EdgeInsets.all(8.0),
38+
child: HtmlWidget(
39+
kHtml,
40+
customWidgetBuilder: (e) {
41+
if (!e.classes.contains('carousel')) {
42+
return null;
43+
}
4444

45-
final srcs = <String>[];
46-
for (final child in e.children) {
47-
for (final grandChild in child.children) {
48-
if (grandChild.attributes case {'src': final String src}) {
49-
srcs.add(src);
50-
}
51-
}
45+
final srcs = <String>[];
46+
for (final child in e.children) {
47+
for (final grandChild in child.children) {
48+
if (grandChild.attributes case {'src': final String src}) {
49+
srcs.add(src);
5250
}
51+
}
52+
}
5353

54-
return CarouselSlider(
55-
options: CarouselOptions(
56-
autoPlay: true,
57-
autoPlayAnimationDuration:
58-
const Duration(milliseconds: 500),
59-
autoPlayInterval: const Duration(seconds: 2),
60-
enlargeCenterPage: true,
61-
),
62-
items: srcs.map(_toItem).toList(growable: false),
63-
);
64-
},
65-
),
66-
),
54+
return CarouselSlider(
55+
options: CarouselOptions(
56+
autoPlay: true,
57+
autoPlayAnimationDuration: const Duration(milliseconds: 500),
58+
autoPlayInterval: const Duration(seconds: 2),
59+
enlargeCenterPage: true,
60+
),
61+
items: srcs.map(_toItem).toList(growable: false),
62+
);
63+
},
6764
),
68-
);
65+
),
66+
),
67+
);
6968

7069
static Widget _toItem(String src) => Center(
71-
child: Image.network(src, fit: BoxFit.cover, width: 1000),
72-
);
70+
child: Image.network(src, fit: BoxFit.cover, width: 1000),
71+
);
7372
}

0 commit comments

Comments
 (0)