1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter/material.dart';
import 'common.dart';
import 'src/animated_image.dart';
import 'src/animated_placeholder.dart';
import 'src/animation_with_microtasks.dart';
import 'src/backdrop_filter.dart';
import 'src/color_filter_and_fade.dart';
import 'src/cubic_bezier.dart';
import 'src/cull_opacity.dart';
import 'src/filtered_child_animation.dart';
import 'src/fullscreen_textfield.dart';
import 'src/heavy_grid_view.dart';
import 'src/large_image_changer.dart';
import 'src/large_images.dart';
import 'src/multi_widget_construction.dart';
import 'src/picture_cache.dart';
import 'src/post_backdrop_filter.dart';
import 'src/simple_animation.dart';
import 'src/simple_scroll.dart';
import 'src/stack_size.dart';
import 'src/text.dart';
const String kMacrobenchmarks = 'Macrobenchmarks';
void main() => runApp(const MacrobenchmarksApp());
class MacrobenchmarksApp extends StatelessWidget {
const MacrobenchmarksApp({Key key, this.initialRoute = '/'}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
title: kMacrobenchmarks,
initialRoute: initialRoute,
routes: <String, WidgetBuilder>{
'/': (BuildContext context) => const HomePage(),
kCullOpacityRouteName: (BuildContext context) => const CullOpacityPage(),
kCubicBezierRouteName: (BuildContext context) => const CubicBezierPage(),
kBackdropFilterRouteName: (BuildContext context) => const BackdropFilterPage(),
kPostBackdropFilterRouteName: (BuildContext context) => const PostBackdropFilterPage(),
kSimpleAnimationRouteName: (BuildContext context) => const SimpleAnimationPage(),
kPictureCacheRouteName: (BuildContext context) => const PictureCachePage(),
kLargeImageChangerRouteName: (BuildContext context) => const LargeImageChangerPage(),
kLargeImagesRouteName: (BuildContext context) => const LargeImagesPage(),
kTextRouteName: (BuildContext context) => const TextPage(),
kFullscreenTextRouteName: (BuildContext context) => const TextFieldPage(),
kAnimatedPlaceholderRouteName: (BuildContext context) => const AnimatedPlaceholderPage(),
kColorFilterAndFadeRouteName: (BuildContext context) => const ColorFilterAndFadePage(),
kFadingChildAnimationRouteName: (BuildContext context) => const FilteredChildAnimationPage(FilterType.opacity),
kImageFilteredTransformAnimationRouteName: (BuildContext context) => const FilteredChildAnimationPage(FilterType.rotateFilter),
kMultiWidgetConstructionRouteName: (BuildContext context) => const MultiWidgetConstructTable(10, 20),
kHeavyGridViewRouteName: (BuildContext context) => const HeavyGridViewPage(),
kSimpleScrollRouteName: (BuildContext context) => const SimpleScroll(),
kStackSizeRouteName: (BuildContext context) => const StackSizePage(),
kAnimationWithMicrotasksRouteName: (BuildContext context) => const AnimationWithMicrotasks(),
kAnimatedImageRouteName: (BuildContext context) => const AnimatedImagePage(),
},
);
}
final String initialRoute;
}
class HomePage extends StatelessWidget {
const HomePage({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text(kMacrobenchmarks)),
body: ListView(
key: const Key(kScrollableName),
children: <Widget>[
ElevatedButton(
key: const Key(kCullOpacityRouteName),
child: const Text('Cull opacity'),
onPressed: () {
Navigator.pushNamed(context, kCullOpacityRouteName);
},
),
ElevatedButton(
key: const Key(kCubicBezierRouteName),
child: const Text('Cubic Bezier'),
onPressed: () {
Navigator.pushNamed(context, kCubicBezierRouteName);
},
),
ElevatedButton(
key: const Key(kBackdropFilterRouteName),
child: const Text('Backdrop Filter'),
onPressed: () {
Navigator.pushNamed(context, kBackdropFilterRouteName);
},
),
ElevatedButton(
key: const Key(kPostBackdropFilterRouteName),
child: const Text('Post Backdrop Filter'),
onPressed: () {
Navigator.pushNamed(context, kPostBackdropFilterRouteName);
},
),
ElevatedButton(
key: const Key(kSimpleAnimationRouteName),
child: const Text('Simple Animation'),
onPressed: () {
Navigator.pushNamed(context, kSimpleAnimationRouteName);
},
),
ElevatedButton(
key: const Key(kPictureCacheRouteName),
child: const Text('Picture Cache'),
onPressed: () {
Navigator.pushNamed(context, kPictureCacheRouteName);
},
),
ElevatedButton(
key: const Key(kLargeImagesRouteName),
child: const Text('Large Images'),
onPressed: () {
Navigator.pushNamed(context, kLargeImagesRouteName);
},
),
ElevatedButton(
key: const Key(kTextRouteName),
child: const Text('Text'),
onPressed: () {
Navigator.pushNamed(context, kTextRouteName);
},
),
ElevatedButton(
key: const Key(kFullscreenTextRouteName),
child: const Text('Fullscreen Text'),
onPressed: () {
Navigator.pushNamed(context, kFullscreenTextRouteName);
},
),
ElevatedButton(
key: const Key(kAnimatedPlaceholderRouteName),
child: const Text('Animated Placeholder'),
onPressed: () {
Navigator.pushNamed(context, kAnimatedPlaceholderRouteName);
},
),
ElevatedButton(
key: const Key(kColorFilterAndFadeRouteName),
child: const Text('Color Filter and Fade'),
onPressed: () {
Navigator.pushNamed(context, kColorFilterAndFadeRouteName);
},
),
ElevatedButton(
key: const Key(kFadingChildAnimationRouteName),
child: const Text('Fading Child Animation'),
onPressed: () {
Navigator.pushNamed(context, kFadingChildAnimationRouteName);
},
),
ElevatedButton(
key: const Key(kImageFilteredTransformAnimationRouteName),
child: const Text('ImageFiltered Transform Animation'),
onPressed: () {
Navigator.pushNamed(context, kImageFilteredTransformAnimationRouteName);
},
),
ElevatedButton(
key: const Key(kMultiWidgetConstructionRouteName),
child: const Text('Widget Construction and Destruction'),
onPressed: () {
Navigator.pushNamed(context, kMultiWidgetConstructionRouteName);
},
),
ElevatedButton(
key: const Key(kHeavyGridViewRouteName),
child: const Text('Heavy Grid View'),
onPressed: () {
Navigator.pushNamed(context, kHeavyGridViewRouteName);
},
),
ElevatedButton(
key: const Key(kLargeImageChangerRouteName),
child: const Text('Large Image Changer'),
onPressed: () {
Navigator.pushNamed(context, kLargeImageChangerRouteName);
},
),
ElevatedButton(
key: const Key(kStackSizeRouteName),
child: const Text('Stack Size'),
onPressed: () {
Navigator.pushNamed(context, kStackSizeRouteName);
},
),
ElevatedButton(
key: const Key(kAnimationWithMicrotasksRouteName),
child: const Text('Animation With Microtasks'),
onPressed: () {
Navigator.pushNamed(context, kAnimationWithMicrotasksRouteName);
},
),
ElevatedButton(
key: const Key(kAnimatedImageRouteName),
child: const Text('Animated Image'),
onPressed: () {
Navigator.pushNamed(context, kAnimatedImageRouteName);
},
),
],
),
);
}
}