Skip to content

Commit a5e4400

Browse files
committed
Update env for demo_app
1 parent 49d02d1 commit a5e4400

26 files changed

+640
-773
lines changed

demo_app/analysis_options.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ 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-
118
linter:
129
rules:
1310
always_put_control_body_on_new_line: true

demo_app/integration_test/auto_resize_test.dart

Lines changed: 23 additions & 33 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
);
@@ -30,49 +30,39 @@ void main() {
3030
WebViewTestCase(input: 1.0, issue375: true),
3131
});
3232

33-
patrolTest(
34-
'WebView',
35-
($) async {
36-
final testCase = webViewTestCases.currentValue!;
37-
final test = await testCase.run($);
38-
39-
for (var i = 0; ; i++) {
40-
await $.pump();
41-
await $.tester.runAsync(
42-
() => Future.delayed(const Duration(seconds: 3)),
43-
);
44-
await $.pump();
45-
46-
try {
47-
test.expectValueEquals(testCase.input);
48-
break;
49-
} catch (e) {
50-
if (i >= 5) {
51-
// too many failures
52-
rethrow;
53-
}
33+
patrolTest('WebView', ($) async {
34+
final testCase = webViewTestCases.currentValue!;
35+
final test = await testCase.run($);
36+
37+
for (var i = 0;; i++) {
38+
await $.pump();
39+
await $.tester.runAsync(() => Future.delayed(const Duration(seconds: 3)));
40+
await $.pump();
41+
42+
try {
43+
test.expectValueEquals(testCase.input);
44+
break;
45+
} catch (e) {
46+
if (i >= 5) {
47+
// too many failures
48+
rethrow;
5449
}
5550
}
51+
}
5652

57-
await $.pump();
58-
await $.pumpWidget(const SizedBox.shrink());
59-
},
60-
variant: webViewTestCases,
61-
);
53+
await $.pump();
54+
await $.pumpWidget(const SizedBox.shrink());
55+
}, variant: webViewTestCases);
6256
}
6357

6458
class WebViewTestCase {
6559
final double input;
6660
final bool issue375;
6761

68-
const WebViewTestCase({
69-
required this.input,
70-
required this.issue375,
71-
});
62+
const WebViewTestCase({required this.input, required this.issue375});
7263

7364
Future<_AspectRatioTest> run(PatrolIntegrationTester $) async {
74-
final html =
75-
'''
65+
final html = '''
7666
<!doctype html>
7767
<head>
7868
<meta charset="utf-8">

demo_app/lib/main.dart

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

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

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

3029
@override
3130
Widget build(BuildContext context) => PopupMenuStateProvider(
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,
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,
3736

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

demo_app/lib/screens/audio.dart

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

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

7166
void _setState(VoidCallback callback) => setState(() {
72-
callback();
67+
callback();
7368

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-
}
69+
final attributes = <String>[];
70+
if (autoplay) {
71+
attributes.add('autoplay');
72+
}
73+
if (loop) {
74+
attributes.add('loop');
75+
}
76+
if (muted) {
77+
attributes.add('muted');
78+
}
79+
if (preload) {
80+
attributes.add('preload');
81+
}
8782

88-
_html =
89-
'''
83+
_html = '''
9084
<figure>
9185
<audio src="/media/cc0-audio/t-rex-roar.mp3" ${attributes.join(' ')}>
9286
Sorry, <code>AUDIO</code> tag is not supported.
9387
</audio>
9488
<figcaption>Source: <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/audio">developer.mozilla.org</a></figcaption>
9589
</figure>
9690
''';
97-
});
91+
});
9892
}

demo_app/lib/screens/custom_styles_builder.dart

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,14 @@ 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(title: const Text('CustomStylesBuilderScreen')),
12+
body: Padding(
13+
padding: const EdgeInsets.all(8.0),
14+
child: HtmlWidget(
15+
kHtml,
16+
customStylesBuilder: (e) =>
17+
e.classes.contains('name') ? {'color': 'red'} : null,
18+
),
19+
),
20+
);
2321
}

demo_app/lib/screens/custom_widget_builder.dart

Lines changed: 33 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -29,44 +29,42 @@ 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(title: const Text('CustomWidgetBuilderScreen')),
33+
body: SingleChildScrollView(
34+
child: Padding(
35+
padding: const EdgeInsets.all(8.0),
36+
child: HtmlWidget(
37+
kHtml,
38+
customWidgetBuilder: (e) {
39+
if (!e.classes.contains('carousel')) {
40+
return null;
41+
}
4442

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);
43+
final srcs = <String>[];
44+
for (final child in e.children) {
45+
for (final grandChild in child.children) {
46+
if (grandChild.attributes case {'src': final String src}) {
47+
srcs.add(src);
48+
}
49+
}
5050
}
51-
}
52-
}
5351

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-
},
52+
return CarouselSlider(
53+
options: CarouselOptions(
54+
autoPlay: true,
55+
autoPlayAnimationDuration:
56+
const Duration(milliseconds: 500),
57+
autoPlayInterval: const Duration(seconds: 2),
58+
enlargeCenterPage: true,
59+
),
60+
items: srcs.map(_toItem).toList(growable: false),
61+
);
62+
},
63+
),
64+
),
6465
),
65-
),
66-
),
67-
);
66+
);
6867

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

0 commit comments

Comments
 (0)