Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
37bc7223
Unverified
Commit
37bc7223
authored
Jun 29, 2021
by
Darren Austin
Committed by
GitHub
Jun 29, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate dev/benchmarks/macrobenchmarks to null safety. (#85501)
parent
d16b27bb
Changes
50
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
50 changed files
with
529 additions
and
516 deletions
+529
-516
main.dart
dev/benchmarks/macrobenchmarks/lib/main.dart
+2
-2
animated_image.dart
dev/benchmarks/macrobenchmarks/lib/src/animated_image.dart
+4
-4
animated_placeholder.dart
...chmarks/macrobenchmarks/lib/src/animated_placeholder.dart
+1
-1
animation_with_microtasks.dart
...ks/macrobenchmarks/lib/src/animation_with_microtasks.dart
+1
-1
backdrop_filter.dart
dev/benchmarks/macrobenchmarks/lib/src/backdrop_filter.dart
+5
-5
color_filter_and_fade.dart
...hmarks/macrobenchmarks/lib/src/color_filter_and_fade.dart
+16
-10
cubic_bezier.dart
dev/benchmarks/macrobenchmarks/lib/src/cubic_bezier.dart
+10
-12
cull_opacity.dart
dev/benchmarks/macrobenchmarks/lib/src/cull_opacity.dart
+3
-3
filtered_child_animation.dart
...rks/macrobenchmarks/lib/src/filtered_child_animation.dart
+19
-18
fullscreen_textfield.dart
...chmarks/macrobenchmarks/lib/src/fullscreen_textfield.dart
+1
-1
heavy_grid_view.dart
dev/benchmarks/macrobenchmarks/lib/src/heavy_grid_view.dart
+2
-2
large_image_changer.dart
...nchmarks/macrobenchmarks/lib/src/large_image_changer.dart
+3
-3
large_images.dart
dev/benchmarks/macrobenchmarks/lib/src/large_images.dart
+3
-3
multi_widget_construction.dart
...ks/macrobenchmarks/lib/src/multi_widget_construction.dart
+7
-7
picture_cache.dart
dev/benchmarks/macrobenchmarks/lib/src/picture_cache.dart
+2
-2
post_backdrop_filter.dart
...chmarks/macrobenchmarks/lib/src/post_backdrop_filter.dart
+4
-4
simple_animation.dart
dev/benchmarks/macrobenchmarks/lib/src/simple_animation.dart
+1
-1
simple_scroll.dart
dev/benchmarks/macrobenchmarks/lib/src/simple_scroll.dart
+1
-1
stack_size.dart
dev/benchmarks/macrobenchmarks/lib/src/stack_size.dart
+3
-3
text.dart
dev/benchmarks/macrobenchmarks/lib/src/text.dart
+1
-1
bench_build_image.dart
...hmarks/macrobenchmarks/lib/src/web/bench_build_image.dart
+9
-4
bench_build_material_checkbox.dart
...benchmarks/lib/src/web/bench_build_material_checkbox.dart
+3
-3
bench_card_infinite_scroll.dart
...crobenchmarks/lib/src/web/bench_card_infinite_scroll.dart
+9
-3
bench_child_layers.dart
...marks/macrobenchmarks/lib/src/web/bench_child_layers.dart
+6
-6
bench_dynamic_clip_on_static_picture.dart
...rks/lib/src/web/bench_dynamic_clip_on_static_picture.dart
+3
-3
bench_mouse_region_grid_hover.dart
...benchmarks/lib/src/web/bench_mouse_region_grid_hover.dart
+11
-11
bench_mouse_region_grid_scroll.dart
...enchmarks/lib/src/web/bench_mouse_region_grid_scroll.dart
+7
-7
bench_mouse_region_mixed_grid_hover.dart
...arks/lib/src/web/bench_mouse_region_mixed_grid_hover.dart
+12
-12
bench_pageview_scroll_linethrough.dart
...hmarks/lib/src/web/bench_pageview_scroll_linethrough.dart
+5
-7
bench_paths_recording.dart
...ks/macrobenchmarks/lib/src/web/bench_paths_recording.dart
+212
-212
bench_picture_recording.dart
.../macrobenchmarks/lib/src/web/bench_picture_recording.dart
+2
-2
bench_simple_lazy_text_scroll.dart
...benchmarks/lib/src/web/bench_simple_lazy_text_scroll.dart
+10
-4
bench_text_layout.dart
...hmarks/macrobenchmarks/lib/src/web/bench_text_layout.dart
+23
-26
bench_text_out_of_picture_bounds.dart
...chmarks/lib/src/web/bench_text_out_of_picture_bounds.dart
+2
-2
bench_wrapbox_scroll.dart
...rks/macrobenchmarks/lib/src/web/bench_wrapbox_scroll.dart
+6
-8
recorder.dart
dev/benchmarks/macrobenchmarks/lib/src/web/recorder.dart
+70
-70
test_data.dart
dev/benchmarks/macrobenchmarks/lib/src/web/test_data.dart
+5
-7
web_benchmarks.dart
dev/benchmarks/macrobenchmarks/lib/web_benchmarks.dart
+22
-22
pubspec.yaml
dev/benchmarks/macrobenchmarks/pubspec.yaml
+1
-1
frame_policy.dart
dev/benchmarks/macrobenchmarks/test/frame_policy.dart
+1
-1
util.dart
dev/benchmarks/macrobenchmarks/test/util.dart
+3
-3
animated_image.dart
...enchmarks/macrobenchmarks/test_driver/animated_image.dart
+1
-1
e2e_test.dart
dev/benchmarks/macrobenchmarks/test_driver/e2e_test.dart
+2
-2
frame_policy_test.dart
...hmarks/macrobenchmarks/test_driver/frame_policy_test.dart
+3
-3
large_image_changer.dart
...arks/macrobenchmarks/test_driver/large_image_changer.dart
+1
-1
large_image_changer_test.dart
...macrobenchmarks/test_driver/large_image_changer_test.dart
+1
-1
stack_size_perf_test.dart
...rks/macrobenchmarks/test_driver/stack_size_perf_test.dart
+1
-1
util.dart
dev/benchmarks/macrobenchmarks/test_driver/util.dart
+5
-5
heavy_gridview.dart
...enchmarks/macrobenchmarks/test_memory/heavy_gridview.dart
+2
-2
large_images.dart
dev/benchmarks/macrobenchmarks/test_memory/large_images.dart
+2
-2
No files found.
dev/benchmarks/macrobenchmarks/lib/main.dart
View file @
37bc7223
...
...
@@ -31,7 +31,7 @@ const String kMacrobenchmarks = 'Macrobenchmarks';
void
main
(
)
=>
runApp
(
const
MacrobenchmarksApp
());
class
MacrobenchmarksApp
extends
StatelessWidget
{
const
MacrobenchmarksApp
({
Key
key
,
this
.
initialRoute
=
'/'
})
:
super
(
key:
key
);
const
MacrobenchmarksApp
({
Key
?
key
,
this
.
initialRoute
=
'/'
})
:
super
(
key:
key
);
@override
Widget
build
(
BuildContext
context
)
{
...
...
@@ -68,7 +68,7 @@ class MacrobenchmarksApp extends StatelessWidget {
}
class
HomePage
extends
StatelessWidget
{
const
HomePage
({
Key
key
})
:
super
(
key:
key
);
const
HomePage
({
Key
?
key
})
:
super
(
key:
key
);
@override
Widget
build
(
BuildContext
context
)
{
...
...
dev/benchmarks/macrobenchmarks/lib/src/animated_image.dart
View file @
37bc7223
...
...
@@ -5,9 +5,9 @@
import
'package:flutter/material.dart'
;
class
AnimatedImagePage
extends
StatelessWidget
{
const
AnimatedImagePage
({
Key
key
,
this
.
onFrame
})
:
super
(
key:
key
);
const
AnimatedImagePage
({
Key
?
key
,
this
.
onFrame
})
:
super
(
key:
key
);
final
ValueChanged
<
int
>
onFrame
;
final
ValueChanged
<
int
>
?
onFrame
;
@override
Widget
build
(
BuildContext
context
)
{
...
...
@@ -18,9 +18,9 @@ class AnimatedImagePage extends StatelessWidget {
body:
Image
.
asset
(
'animated_images/animated_flutter_lgtm.gif'
,
package:
'flutter_gallery_assets'
,
frameBuilder:
(
BuildContext
context
,
Widget
child
,
int
/*?*/
frame
,
bool
syncCall
)
{
frameBuilder:
(
BuildContext
context
,
Widget
child
,
int
?
frame
,
bool
syncCall
)
{
if
(
onFrame
!=
null
&&
frame
!=
null
)
{
onFrame
(
frame
);
onFrame
?.
call
(
frame
);
}
return
child
;
},
...
...
dev/benchmarks/macrobenchmarks/lib/src/animated_placeholder.dart
View file @
37bc7223
...
...
@@ -24,7 +24,7 @@ const String kBlueSquare = 'iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAASEl'
/// A 10x10 grid of animated looping placeholder gifts that fade into a
/// blue square.
class
AnimatedPlaceholderPage
extends
StatelessWidget
{
const
AnimatedPlaceholderPage
({
Key
key
})
:
super
(
key:
key
);
const
AnimatedPlaceholderPage
({
Key
?
key
})
:
super
(
key:
key
);
@override
Widget
build
(
BuildContext
context
)
{
...
...
dev/benchmarks/macrobenchmarks/lib/src/animation_with_microtasks.dart
View file @
37bc7223
...
...
@@ -5,7 +5,7 @@
import
'package:flutter/material.dart'
;
class
AnimationWithMicrotasks
extends
StatefulWidget
{
const
AnimationWithMicrotasks
({
Key
key
})
:
super
(
key:
key
);
const
AnimationWithMicrotasks
({
Key
?
key
})
:
super
(
key:
key
);
@override
State
<
AnimationWithMicrotasks
>
createState
()
=>
_AnimationWithMicrotasksState
();
...
...
dev/benchmarks/macrobenchmarks/lib/src/backdrop_filter.dart
View file @
37bc7223
...
...
@@ -7,7 +7,7 @@ import 'dart:ui';
import
'package:flutter/material.dart'
;
class
BackdropFilterPage
extends
StatefulWidget
{
const
BackdropFilterPage
({
Key
key
})
:
super
(
key:
key
);
const
BackdropFilterPage
({
Key
?
key
})
:
super
(
key:
key
);
@override
State
<
BackdropFilterPage
>
createState
()
=>
_BackdropFilterPageState
();
...
...
@@ -16,7 +16,7 @@ class BackdropFilterPage extends StatefulWidget {
class
_BackdropFilterPageState
extends
State
<
BackdropFilterPage
>
with
TickerProviderStateMixin
{
bool
_blurGroup
=
false
;
bool
_blurTexts
=
true
;
AnimationController
animation
;
late
AnimationController
animation
;
@override
void
initState
()
{
...
...
@@ -77,7 +77,7 @@ class _BackdropFilterPageState extends State<BackdropFilterPage> with TickerProv
child:
Center
(
child:
AnimatedBuilder
(
animation:
animation
,
builder:
(
BuildContext
c
,
Widget
w
)
{
builder:
(
BuildContext
c
,
Widget
?
w
)
{
final
int
val
=
(
animation
.
value
*
255
).
round
();
return
Container
(
width:
50
,
...
...
@@ -99,13 +99,13 @@ class _BackdropFilterPageState extends State<BackdropFilterPage> with TickerProv
const
Text
(
'Backdrop per txt:'
),
Checkbox
(
value:
_blurTexts
,
onChanged:
(
bool
v
)
=>
setState
(()
{
_blurTexts
=
v
;
}),
onChanged:
(
bool
?
v
)
=>
setState
(()
{
_blurTexts
=
v
??
false
;
}),
),
const
SizedBox
(
width:
10
),
const
Text
(
'Backdrop grid:'
),
Checkbox
(
value:
_blurGroup
,
onChanged:
(
bool
v
)
=>
setState
(()
{
_blurGroup
=
v
;
}),
onChanged:
(
bool
?
v
)
=>
setState
(()
{
_blurGroup
=
v
??
false
;
}),
),
],
),
...
...
dev/benchmarks/macrobenchmarks/lib/src/color_filter_and_fade.dart
View file @
37bc7223
...
...
@@ -9,7 +9,7 @@ import 'package:flutter/material.dart';
// This tests whether the Opacity layer raster cache works with color filters.
// See https://github.com/flutter/flutter/issues/51975.
class
ColorFilterAndFadePage
extends
StatefulWidget
{
const
ColorFilterAndFadePage
({
Key
key
})
:
super
(
key:
key
);
const
ColorFilterAndFadePage
({
Key
?
key
})
:
super
(
key:
key
);
@override
State
<
ColorFilterAndFadePage
>
createState
()
=>
_ColorFilterAndFadePageState
();
...
...
@@ -79,9 +79,9 @@ class _ColorFilterAndFadePageState extends State<ColorFilterAndFadePage> with Ti
const
Text
(
'Use Color Filter:'
),
Checkbox
(
value:
_useColorFilter
,
onChanged:
(
bool
value
)
{
onChanged:
(
bool
?
value
)
{
setState
(()
{
_useColorFilter
=
value
;
_useColorFilter
=
value
??
false
;
});
},
),
...
...
@@ -111,17 +111,23 @@ class _ColorFilterAndFadePageState extends State<ColorFilterAndFadePage> with Ti
_initAnimation
();
}
AnimationController
_controller
;
Animation
<
double
>
_opacityAnimation
;
@override
void
dispose
()
{
_controller
.
dispose
();
super
.
dispose
();
}
late
AnimationController
_controller
;
late
Animation
<
double
>
_opacityAnimation
;
bool
_useColorFilter
=
true
;
}
class
_ShadowWidget
extends
StatelessWidget
{
const
_ShadowWidget
({
@
required
this
.
width
,
@
required
this
.
height
,
@
required
this
.
useColorFilter
,
@
required
this
.
shadow
,
required
this
.
width
,
required
this
.
height
,
required
this
.
useColorFilter
,
required
this
.
shadow
,
});
final
double
width
;
...
...
@@ -148,7 +154,7 @@ class _ShadowWidget extends StatelessWidget {
}
class
_ShadowPainter
extends
CustomPainter
{
const
_ShadowPainter
({
this
.
useColorFilter
,
@
required
this
.
shadow
});
const
_ShadowPainter
({
required
this
.
useColorFilter
,
required
this
.
shadow
});
final
bool
useColorFilter
;
final
Shadow
shadow
;
...
...
dev/benchmarks/macrobenchmarks/lib/src/cubic_bezier.dart
View file @
37bc7223
...
...
@@ -8,7 +8,7 @@ import 'package:flutter/material.dart';
// Based on https://github.com/eseidelGoogle/bezier_perf/blob/master/lib/main.dart
class
CubicBezierPage
extends
StatelessWidget
{
const
CubicBezierPage
({
Key
key
})
:
super
(
key:
key
);
const
CubicBezierPage
({
Key
?
key
})
:
super
(
key:
key
);
@override
Widget
build
(
BuildContext
context
)
{
...
...
@@ -24,7 +24,7 @@ class CubicBezierPage extends StatelessWidget {
}
class
Bezier
extends
StatelessWidget
{
const
Bezier
(
this
.
color
,
this
.
scale
,
{
Key
key
,
this
.
blur
=
0.0
,
this
.
delay
=
0.0
})
:
super
(
key:
key
);
const
Bezier
(
this
.
color
,
this
.
scale
,
{
Key
?
key
,
this
.
blur
=
0.0
,
this
.
delay
=
0.0
})
:
super
(
key:
key
);
final
Color
color
;
final
double
scale
;
...
...
@@ -79,7 +79,7 @@ class Bezier extends StatelessWidget {
BezierPainter
(
Colors
.
grey
,
0.0
,
_getLogoPath
(),
false
),
size:
const
Size
(
100.0
,
100.0
),
),
AnimatedBezier
(
color
,
scale
,
blur:
blur
,
delay:
delay
),
AnimatedBezier
(
color
,
scale
,
blur:
blur
),
]);
}
}
...
...
@@ -88,17 +88,16 @@ class PathDetail {
PathDetail
(
this
.
path
,
{
this
.
translate
,
this
.
rotation
});
Path
path
;
List
<
double
>
translate
=
<
double
>[];
double
rotation
;
List
<
double
>
?
translate
=
<
double
>[];
double
?
rotation
;
}
class
AnimatedBezier
extends
StatefulWidget
{
const
AnimatedBezier
(
this
.
color
,
this
.
scale
,
{
Key
key
,
this
.
blur
=
0.0
,
this
.
delay
})
:
super
(
key:
key
);
const
AnimatedBezier
(
this
.
color
,
this
.
scale
,
{
Key
?
key
,
this
.
blur
=
0.0
})
:
super
(
key:
key
);
final
Color
color
;
final
double
scale
;
final
double
blur
;
final
double
delay
;
@override
State
createState
()
=>
AnimatedBezierState
();
...
...
@@ -113,9 +112,8 @@ class Point {
class
AnimatedBezierState
extends
State
<
AnimatedBezier
>
with
SingleTickerProviderStateMixin
{
double
scale
;
AnimationController
controller
;
CurvedAnimation
curve
;
late
AnimationController
controller
;
late
CurvedAnimation
curve
;
bool
isPlaying
=
false
;
List
<
List
<
Point
>>
pointList
=
<
List
<
Point
>>[
<
Point
>[],
...
...
@@ -365,11 +363,11 @@ class BezierPainter extends CustomPainter {
for
(
int
i
=
0
;
i
<
path
.
length
;
i
++)
{
if
(
path
[
i
].
translate
!=
null
)
{
canvas
.
translate
(
path
[
i
].
translate
[
0
],
path
[
i
].
translate
[
1
]);
canvas
.
translate
(
path
[
i
].
translate
![
0
],
path
[
i
].
translate
!
[
1
]);
}
if
(
path
[
i
].
rotation
!=
null
)
{
canvas
.
rotate
(
path
[
i
].
rotation
);
canvas
.
rotate
(
path
[
i
].
rotation
!
);
}
if
(
blur
>
0
)
{
...
...
dev/benchmarks/macrobenchmarks/lib/src/cull_opacity.dart
View file @
37bc7223
...
...
@@ -5,15 +5,15 @@
import
'package:flutter/material.dart'
;
class
CullOpacityPage
extends
StatefulWidget
{
const
CullOpacityPage
({
Key
key
})
:
super
(
key:
key
);
const
CullOpacityPage
({
Key
?
key
})
:
super
(
key:
key
);
@override
State
<
StatefulWidget
>
createState
()
=>
_CullOpacityPageState
();
}
class
_CullOpacityPageState
extends
State
<
CullOpacityPage
>
with
SingleTickerProviderStateMixin
{
Animation
<
double
>
_offsetY
;
AnimationController
_controller
;
late
Animation
<
double
>
_offsetY
;
late
AnimationController
_controller
;
@override
void
initState
()
{
...
...
dev/benchmarks/macrobenchmarks/lib/src/filtered_child_animation.dart
View file @
37bc7223
...
...
@@ -13,7 +13,7 @@ enum FilterType {
class
FilteredChildAnimationPage
extends
StatefulWidget
{
const
FilteredChildAnimationPage
(
this
.
initialFilterType
,
{
Key
key
,
Key
?
key
,
this
.
initialComplexChild
=
true
,
this
.
initialUseRepaintBoundary
=
true
,
})
:
super
(
key:
key
);
...
...
@@ -27,13 +27,13 @@ class FilteredChildAnimationPage extends StatefulWidget {
}
class
_FilteredChildAnimationPageState
extends
State
<
FilteredChildAnimationPage
>
with
SingleTickerProviderStateMixin
{
AnimationController
_controller
;
late
AnimationController
_controller
;
final
GlobalKey
_childKey
=
GlobalKey
(
debugLabel:
'child to animate'
);
Offset
_childCenter
=
Offset
.
zero
;
FilterType
_filterType
;
bool
_complexChild
;
bool
_useRepaintBoundary
;
FilterType
?
_filterType
;
late
bool
_complexChild
;
late
bool
_useRepaintBoundary
;
@override
void
initState
()
{
...
...
@@ -41,8 +41,8 @@ class _FilteredChildAnimationPageState extends State<FilteredChildAnimationPage>
_filterType
=
widget
.
initialFilterType
;
_complexChild
=
widget
.
initialComplexChild
;
_useRepaintBoundary
=
widget
.
initialUseRepaintBoundary
;
WidgetsBinding
.
instance
.
addPostFrameCallback
((
_
)
{
final
RenderBox
childBox
=
_childKey
.
currentContext
.
findRenderObject
()
as
RenderBox
;
WidgetsBinding
.
instance
!
.
addPostFrameCallback
((
_
)
{
final
RenderBox
childBox
=
_childKey
.
currentContext
!.
findRenderObject
()!
as
RenderBox
;
_childCenter
=
childBox
.
paintBounds
.
center
;
});
_controller
=
AnimationController
(
vsync:
this
,
duration:
const
Duration
(
seconds:
2
));
...
...
@@ -102,22 +102,23 @@ class _FilteredChildAnimationPageState extends State<FilteredChildAnimationPage>
);
}
Widget
_animate
({
Widget
child
,
bool
protectChild
})
{
Widget
_animate
({
required
Widget
child
,
required
bool
protectChild
})
{
if
(
_filterType
==
null
)
{
_controller
.
reset
();
return
child
;
}
final
FilterType
filterType
=
_filterType
!;
_controller
.
repeat
();
Widget
Function
(
BuildContext
,
Widget
)
builder
;
switch
(
_
filterType
)
{
Widget
Function
(
BuildContext
,
Widget
?
)
builder
;
switch
(
filterType
)
{
case
FilterType
.
opacity
:
builder
=
(
BuildContext
context
,
Widget
child
)
=>
Opacity
(
builder
=
(
BuildContext
context
,
Widget
?
child
)
=>
Opacity
(
opacity:
(
_controller
.
value
*
2.0
-
1.0
).
abs
(),
child:
child
,
);
break
;
case
FilterType
.
rotateTransform
:
builder
=
(
BuildContext
context
,
Widget
child
)
=>
Transform
(
builder
=
(
BuildContext
context
,
Widget
?
child
)
=>
Transform
(
transform:
Matrix4
.
rotationZ
(
_controller
.
value
*
2.0
*
pi
),
alignment:
Alignment
.
center
,
filterQuality:
FilterQuality
.
low
,
...
...
@@ -125,7 +126,7 @@ class _FilteredChildAnimationPageState extends State<FilteredChildAnimationPage>
);
break
;
case
FilterType
.
rotateFilter
:
builder
=
(
BuildContext
context
,
Widget
child
)
=>
ImageFiltered
(
builder
=
(
BuildContext
context
,
Widget
?
child
)
=>
ImageFiltered
(
imageFilter:
ImageFilter
.
matrix
((
Matrix4
.
identity
()
..
translate
(
_childCenter
.
dx
,
_childCenter
.
dy
)
...
...
@@ -176,17 +177,17 @@ class _FilteredChildAnimationPageState extends State<FilteredChildAnimationPage>
const
Text
(
'Opacity:'
),
Checkbox
(
value:
_filterType
==
FilterType
.
opacity
,
onChanged:
(
bool
b
)
=>
_setFilterType
(
FilterType
.
opacity
,
b
),
onChanged:
(
bool
?
b
)
=>
_setFilterType
(
FilterType
.
opacity
,
b
??
false
),
),
const
Text
(
'Tx Rotate:'
),
Checkbox
(
value:
_filterType
==
FilterType
.
rotateTransform
,
onChanged:
(
bool
b
)
=>
_setFilterType
(
FilterType
.
rotateTransform
,
b
),
onChanged:
(
bool
?
b
)
=>
_setFilterType
(
FilterType
.
rotateTransform
,
b
??
false
),
),
const
Text
(
'IF Rotate:'
),
Checkbox
(
value:
_filterType
==
FilterType
.
rotateFilter
,
onChanged:
(
bool
b
)
=>
_setFilterType
(
FilterType
.
rotateFilter
,
b
),
onChanged:
(
bool
?
b
)
=>
_setFilterType
(
FilterType
.
rotateFilter
,
b
??
false
),
),
],
),
...
...
@@ -196,12 +197,12 @@ class _FilteredChildAnimationPageState extends State<FilteredChildAnimationPage>
const
Text
(
'Complex child:'
),
Checkbox
(
value:
_complexChild
,
onChanged:
(
bool
b
)
=>
setState
(()
=>
_complexChild
=
b
),
onChanged:
(
bool
?
b
)
=>
setState
(()
=>
_complexChild
=
b
??
false
),
),
const
Text
(
'RPB on child:'
),
Checkbox
(
value:
_useRepaintBoundary
,
onChanged:
(
bool
b
)
=>
setState
(()
=>
_useRepaintBoundary
=
b
),
onChanged:
(
bool
?
b
)
=>
setState
(()
=>
_useRepaintBoundary
=
b
??
false
),
),
],
),
...
...
dev/benchmarks/macrobenchmarks/lib/src/fullscreen_textfield.dart
View file @
37bc7223
...
...
@@ -48,7 +48,7 @@ const String textLotsOfText = 'Lorem ipsum dolor sit amet, consectetur '
'🦻 👃 🫀 🫁 🧠 🦷 🦴 👀 👁 👅 👄 💋 🩸'
;
class
TextFieldPage
extends
StatelessWidget
{
const
TextFieldPage
({
Key
key
})
:
super
(
key:
key
);
const
TextFieldPage
({
Key
?
key
})
:
super
(
key:
key
);
@override
Widget
build
(
BuildContext
context
)
{
...
...
dev/benchmarks/macrobenchmarks/lib/src/heavy_grid_view.dart
View file @
37bc7223
...
...
@@ -5,7 +5,7 @@
import
'package:flutter/material.dart'
;
class
HeavyGridViewPage
extends
StatelessWidget
{
const
HeavyGridViewPage
({
Key
key
})
:
super
(
key:
key
);
const
HeavyGridViewPage
({
Key
?
key
})
:
super
(
key:
key
);
@override
Widget
build
(
BuildContext
context
)
{
...
...
@@ -21,7 +21,7 @@ class HeavyWidget extends StatelessWidget {
HeavyWidget
(
this
.
index
)
:
super
(
key:
ValueKey
<
int
>(
index
));
final
int
index
;
final
List
<
int
>
_weight
=
List
<
int
>.
filled
(
1000000
,
null
);
final
List
<
int
>
_weight
=
List
<
int
>.
filled
(
1000000
,
0
);
@override
Widget
build
(
BuildContext
context
)
{
...
...
dev/benchmarks/macrobenchmarks/lib/src/large_image_changer.dart
View file @
37bc7223
...
...
@@ -8,16 +8,16 @@ import 'package:flutter/material.dart';
/// Displays a new (from image cache's perspective) large image every 500ms.
class
LargeImageChangerPage
extends
StatefulWidget
{
const
LargeImageChangerPage
({
Key
key
})
:
super
(
key:
key
);
const
LargeImageChangerPage
({
Key
?
key
})
:
super
(
key:
key
);
@override
State
<
LargeImageChangerPage
>
createState
()
=>
_LargeImageChangerState
();
}
class
_LargeImageChangerState
extends
State
<
LargeImageChangerPage
>
{
Timer
_timer
;
Timer
?
_timer
;
int
imageIndex
=
0
;
ImageProvider
currentImage
;
late
ImageProvider
currentImage
;
@override
void
didChangeDependencies
()
{
...
...
dev/benchmarks/macrobenchmarks/lib/src/large_images.dart
View file @
37bc7223
...
...
@@ -7,11 +7,11 @@ import 'dart:typed_data';
import
'package:flutter/material.dart'
;
class
LargeImagesPage
extends
StatelessWidget
{
const
LargeImagesPage
({
Key
key
})
:
super
(
key:
key
);
const
LargeImagesPage
({
Key
?
key
})
:
super
(
key:
key
);
@override
Widget
build
(
BuildContext
context
)
{
final
ImageCache
imageCache
=
PaintingBinding
.
instance
.
imageCache
;
final
ImageCache
imageCache
=
PaintingBinding
.
instance
!.
imageCache
!
;
imageCache
.
maximumSize
=
30
;
imageCache
.
maximumSizeBytes
=
50
<<
20
;
return
GridView
.
builder
(
...
...
@@ -36,7 +36,7 @@ class DummyImage extends StatelessWidget {
// creating many copies of the image to trigger the memory issue.
return
snapshot
.
data
==
null
?
Container
()
:
Image
.
memory
(
snapshot
.
data
.
buffer
.
asUint8List
());
:
Image
.
memory
(
snapshot
.
data
!
.
buffer
.
asUint8List
());
},
);
}
...
...
dev/benchmarks/macrobenchmarks/lib/src/multi_widget_construction.dart
View file @
37bc7223
...
...
@@ -5,7 +5,7 @@
import
'package:flutter/material.dart'
;
class
MultiWidgetConstructTable
extends
StatefulWidget
{
const
MultiWidgetConstructTable
(
this
.
columnCount
,
this
.
rowCount
,
{
Key
key
})
const
MultiWidgetConstructTable
(
this
.
columnCount
,
this
.
rowCount
,
{
Key
?
key
})
:
super
(
key:
key
);
final
int
columnCount
;
...
...
@@ -24,7 +24,7 @@ class _MultiWidgetConstructTableState extends State<MultiWidgetConstructTable>
];
int
counter
=
0
;
AnimationController
_controller
;
late
AnimationController
_controller
;
@override
void
initState
()
{
...
...
@@ -53,9 +53,9 @@ class _MultiWidgetConstructTableState extends State<MultiWidgetConstructTable>
final
double
height
=
MediaQuery
.
of
(
context
).
size
.
height
/
widget
.
rowCount
;
final
double
colorPosition
=
_controller
.
value
;
final
int
c1Position
=
colorPosition
.
floor
();
final
Color
c1
=
colorList
[
c1Position
%
colorList
.
length
][
900
];
final
Color
c2
=
colorList
[(
c1Position
+
1
)
%
colorList
.
length
][
900
];
final
Color
baseColor
=
Color
.
lerp
(
c1
,
c2
,
colorPosition
-
c1Position
);
final
Color
c1
=
colorList
[
c1Position
%
colorList
.
length
][
900
]
!
;
final
Color
c2
=
colorList
[(
c1Position
+
1
)
%
colorList
.
length
][
900
]
!
;
final
Color
baseColor
=
Color
.
lerp
(
c1
,
c2
,
colorPosition
-
c1Position
)
!
;
counter
++;
return
Scaffold
(
body:
Table
(
...
...
@@ -82,7 +82,7 @@ class _MultiWidgetConstructTableState extends State<MultiWidgetConstructTable>
// This key forces rebuilding the element
key:
ValueKey
<
int
>(
widgetCounter
+
label
),
color:
Color
.
lerp
(
Colors
.
white
,
baseColor
,
label
/
totalLength
),
Colors
.
white
,
baseColor
,
label
/
totalLength
)
!
,
constraints:
BoxConstraints
.
expand
(
height:
height
),
child:
Text
(
'
${widgetCounter + label}
'
),
);
...
...
@@ -99,7 +99,7 @@ class _MultiWidgetConstructTableState extends State<MultiWidgetConstructTable>
// This class is intended to break the original Widget tree
class
MyContainer
extends
StatelessWidget
{
const
MyContainer
({
this
.
color
,
this
.
child
,
this
.
constraints
,
Key
key
})
const
MyContainer
({
required
this
.
color
,
required
this
.
child
,
required
this
.
constraints
,
Key
?
key
})
:
super
(
key:
key
);
final
Color
color
;
final
Widget
child
;
...
...
dev/benchmarks/macrobenchmarks/lib/src/picture_cache.dart
View file @
37bc7223
...
...
@@ -5,7 +5,7 @@
import
'package:flutter/material.dart'
;
class
PictureCachePage
extends
StatelessWidget
{
const
PictureCachePage
({
Key
key
})
:
super
(
key:
key
);
const
PictureCachePage
({
Key
?
key
})
:
super
(
key:
key
);
static
const
List
<
String
>
kTabNames
=
<
String
>[
'1'
,
'2'
,
'3'
,
'4'
,
'5'
];
...
...
@@ -45,7 +45,7 @@ class PictureCachePage extends StatelessWidget {
}
class
ListItem
extends
StatelessWidget
{
const
ListItem
({
Key
key
,
this
.
index
})
const
ListItem
({
Key
?
key
,
required
this
.
index
})
:
super
(
key:
key
);
final
int
index
;
...
...
dev/benchmarks/macrobenchmarks/lib/src/post_backdrop_filter.dart
View file @
37bc7223
...
...
@@ -7,7 +7,7 @@ import 'dart:ui';
import
'package:flutter/material.dart'
;
class
PostBackdropFilterPage
extends
StatefulWidget
{
const
PostBackdropFilterPage
({
Key
key
})
:
super
(
key:
key
);
const
PostBackdropFilterPage
({
Key
?
key
})
:
super
(
key:
key
);
@override
State
<
PostBackdropFilterPage
>
createState
()
=>
_PostBackdropFilterPageState
();
...
...
@@ -15,7 +15,7 @@ class PostBackdropFilterPage extends StatefulWidget {
class
_PostBackdropFilterPageState
extends
State
<
PostBackdropFilterPage
>
with
TickerProviderStateMixin
{
bool
_includeBackdropFilter
=
false
;
AnimationController
animation
;
late
AnimationController
animation
;
@override
void
initState
()
{
...
...
@@ -63,7 +63,7 @@ class _PostBackdropFilterPageState extends State<PostBackdropFilterPage> with Ti
child:
Center
(
child:
AnimatedBuilder
(
animation:
animation
,
builder:
(
BuildContext
c
,
Widget
w
)
{
builder:
(
BuildContext
c
,
Widget
?
w
)
{
final
int
val
=
(
animation
.
value
*
255
).
round
();
return
Container
(
width:
50
,
...
...
@@ -83,7 +83,7 @@ class _PostBackdropFilterPageState extends State<PostBackdropFilterPage> with Ti
Checkbox
(
key:
const
Key
(
'bdf-checkbox'
),
// this key is used by the driver test
value:
_includeBackdropFilter
,
onChanged:
(
bool
v
)
=>
setState
(()
{
_includeBackdropFilter
=
v
;
}),
onChanged:
(
bool
?
v
)
=>
setState
(()
{
_includeBackdropFilter
=
v
??
false
;
}),
),
MaterialButton
(
key:
const
Key
(
'bdf-animate'
),
// this key is used by the driver test
...
...
dev/benchmarks/macrobenchmarks/lib/src/simple_animation.dart
View file @
37bc7223
...
...
@@ -5,7 +5,7 @@
import
'package:flutter/material.dart'
;
class
SimpleAnimationPage
extends
StatelessWidget
{
const
SimpleAnimationPage
({
Key
key
})
:
super
(
key:
key
);
const
SimpleAnimationPage
({
Key
?
key
})
:
super
(
key:
key
);
@override
Widget
build
(
BuildContext
context
)
{
...
...
dev/benchmarks/macrobenchmarks/lib/src/simple_scroll.dart
View file @
37bc7223
...
...
@@ -5,7 +5,7 @@
import
'package:flutter/material.dart'
;
class
SimpleScroll
extends
StatelessWidget
{
const
SimpleScroll
({
Key
key
})
:
super
(
key:
key
);
const
SimpleScroll
({
Key
?
key
})
:
super
(
key:
key
);
@override
Widget
build
(
BuildContext
context
)
{
...
...
dev/benchmarks/macrobenchmarks/lib/src/stack_size.dart
View file @
37bc7223
...
...
@@ -81,7 +81,7 @@ final GetStackPointerCallback getStackPointer = () {
}();
class
StackSizePage
extends
StatelessWidget
{
const
StackSizePage
({
Key
key
})
:
super
(
key:
key
);
const
StackSizePage
({
Key
?
key
})
:
super
(
key:
key
);
@override
Widget
build
(
BuildContext
context
)
{
...
...
@@ -100,7 +100,7 @@ class StackSizePage extends StatelessWidget {
}
class
ParentWidget
extends
StatelessWidget
{
const
ParentWidget
({
Key
key
})
:
super
(
key:
key
);
const
ParentWidget
({
Key
?
key
})
:
super
(
key:
key
);
@override
Widget
build
(
BuildContext
context
)
{
...
...
@@ -110,7 +110,7 @@ class ParentWidget extends StatelessWidget {
}
class
ChildWidget
extends
StatelessWidget
{
const
ChildWidget
({
this
.
parentStackSize
,
Key
key
})
:
super
(
key:
key
);
const
ChildWidget
({
required
this
.
parentStackSize
,
Key
?
key
})
:
super
(
key:
key
);
final
int
parentStackSize
;
@override
...
...
dev/benchmarks/macrobenchmarks/lib/src/text.dart
View file @
37bc7223
...
...
@@ -5,7 +5,7 @@
import
'package:flutter/material.dart'
;
class
TextPage
extends
StatelessWidget
{
const
TextPage
({
Key
key
})
:
super
(
key:
key
);
const
TextPage
({
Key
?
key
})
:
super
(
key:
key
);
@override
Widget
build
(
BuildContext
context
)
{
...
...
dev/benchmarks/macrobenchmarks/lib/src/web/bench_build_image.dart
View file @
37bc7223
...
...
@@ -52,7 +52,7 @@ class BenchBuildImage extends WidgetRecorder {
}
class
_RotatingWidget
extends
StatefulWidget
{
const
_RotatingWidget
({
this
.
child
,
Key
key
})
:
super
(
key:
key
);
const
_RotatingWidget
({
required
this
.
child
,
Key
?
key
})
:
super
(
key:
key
);
final
Widget
child
;
...
...
@@ -61,7 +61,7 @@ class _RotatingWidget extends StatefulWidget {
}
class
_RotatingWidgetState
extends
State
<
_RotatingWidget
>
with
SingleTickerProviderStateMixin
{
AnimationController
controller
;
late
AnimationController
controller
;
@override
void
initState
()
{
...
...
@@ -72,11 +72,17 @@ class _RotatingWidgetState extends State<_RotatingWidget> with SingleTickerProvi
)..
repeat
();
}
@override
void
dispose
()
{
controller
.
dispose
();
super
.
dispose
();
}
@override
Widget
build
(
BuildContext
context
)
{
return
AnimatedBuilder
(
animation:
controller
,
builder:
(
BuildContext
context
,
Widget
child
)
{
builder:
(
BuildContext
context
,
Widget
?
child
)
{
return
Transform
(
transform:
Matrix4
.
identity
()..
rotateZ
(
2
*
math
.
pi
*
controller
.
value
),
child:
widget
.
child
,
...
...
@@ -84,5 +90,4 @@ class _RotatingWidgetState extends State<_RotatingWidget> with SingleTickerProvi
},
);
}
}
dev/benchmarks/macrobenchmarks/lib/src/web/bench_build_material_checkbox.dart
View file @
37bc7223
...
...
@@ -14,7 +14,7 @@ class BenchBuildMaterialCheckbox extends WidgetBuildRecorder {
static
const
String
benchmarkName
=
'build_material_checkbox'
;
static
bool
_isChecked
;
static
bool
?
_isChecked
;
@override
Widget
createWidget
()
{
...
...
@@ -33,7 +33,7 @@ class BenchBuildMaterialCheckbox extends WidgetBuildRecorder {
Row
_buildRow
()
{
if
(
_isChecked
==
null
)
{
_isChecked
=
true
;
}
else
if
(
_isChecked
)
{
}
else
if
(
_isChecked
!
)
{
_isChecked
=
false
;
}
else
{
_isChecked
=
null
;
...
...
@@ -45,7 +45,7 @@ class BenchBuildMaterialCheckbox extends WidgetBuildRecorder {
child:
Checkbox
(
value:
_isChecked
,
tristate:
true
,
onChanged:
(
bool
newValue
)
{
onChanged:
(
bool
?
newValue
)
{
// Intentionally empty.
},
),
...
...
dev/benchmarks/macrobenchmarks/lib/src/web/bench_card_infinite_scroll.dart
View file @
37bc7223
...
...
@@ -35,7 +35,7 @@ class BenchCardInfiniteScroll extends WidgetRecorder {
}
class
_InfiniteScrollCards
extends
StatefulWidget
{
const
_InfiniteScrollCards
(
this
.
initialOffset
,
this
.
finalOffset
,
{
Key
key
})
:
super
(
key:
key
);
const
_InfiniteScrollCards
(
this
.
initialOffset
,
this
.
finalOffset
,
{
Key
?
key
})
:
super
(
key:
key
);
final
double
initialOffset
;
final
double
finalOffset
;
...
...
@@ -47,8 +47,8 @@ class _InfiniteScrollCards extends StatefulWidget {
class
_InfiniteScrollCardsState
extends
State
<
_InfiniteScrollCards
>
{
static
const
Duration
stepDuration
=
Duration
(
seconds:
20
);
ScrollController
scrollController
;
double
offset
;
late
ScrollController
scrollController
;
late
double
offset
;
@override
void
initState
()
{
...
...
@@ -70,6 +70,12 @@ class _InfiniteScrollCardsState extends State<_InfiniteScrollCards> {
});
}
@override
void
dispose
()
{
scrollController
.
dispose
();
super
.
dispose
();
}
@override
Widget
build
(
BuildContext
context
)
{
return
ListView
.
builder
(
...
...
dev/benchmarks/macrobenchmarks/lib/src/web/bench_child_layers.dart
View file @
37bc7223
...
...
@@ -31,10 +31,10 @@ class BenchUpdateManyChildLayers extends SceneBuilderRecorder {
/// is correctly pumping frames.
double
wobbleCounter
=
0
;
List
<
Picture
>
_pictures
;
Size
windowSize
;
Size
cellSize
;
Size
rectSize
;
late
List
<
Picture
>
_pictures
;
late
Size
windowSize
;
late
Size
cellSize
;
late
Size
rectSize
;
@override
Future
<
void
>
setUpAll
()
async
{
...
...
@@ -55,7 +55,7 @@ class BenchUpdateManyChildLayers extends SceneBuilderRecorder {
}
}
OffsetEngineLayer
_rootLayer
;
OffsetEngineLayer
?
_rootLayer
;
final
Map
<
int
,
OffsetEngineLayer
>
_layers
=
<
int
,
OffsetEngineLayer
>{};
@override
...
...
@@ -64,7 +64,7 @@ class BenchUpdateManyChildLayers extends SceneBuilderRecorder {
for
(
int
row
=
0
;
row
<
kRows
;
row
++)
{
for
(
int
col
=
0
;
col
<
kColumns
;
col
++)
{
final
int
layerId
=
1000000
*
row
+
col
;
final
OffsetEngineLayer
oldLayer
=
_layers
[
layerId
];
final
OffsetEngineLayer
?
oldLayer
=
_layers
[
layerId
];
final
double
wobbleOffsetX
=
col
*
cellSize
.
width
+
(
wobbleCounter
-
5
).
abs
();
final
double
offsetY
=
row
*
cellSize
.
height
;
// Retain every other layer, so we exercise the update path 50% of the
...
...
dev/benchmarks/macrobenchmarks/lib/src/web/bench_dynamic_clip_on_static_picture.dart
View file @
37bc7223
...
...
@@ -93,9 +93,9 @@ class BenchDynamicClipOnStaticPicture extends SceneBuilderRecorder {
static
const
String
benchmarkName
=
'dynamic_clip_on_static_picture'
;
Size
screenSize
;
Size
clipSize
;
Picture
picture
;
late
Size
screenSize
;
late
Size
clipSize
;
late
Picture
picture
;
double
pictureVerticalOffset
=
0.0
;
@override
...
...
dev/benchmarks/macrobenchmarks/lib/src/web/bench_mouse_region_grid_hover.dart
View file @
37bc7223
...
...
@@ -14,7 +14,7 @@ import 'package:flutter_test/flutter_test.dart';
import
'recorder.dart'
;
class
_NestedMouseRegion
extends
StatelessWidget
{
const
_NestedMouseRegion
({
this
.
nests
,
this
.
child
});
const
_NestedMouseRegion
({
required
this
.
nests
,
required
this
.
child
});
final
int
nests
;
final
Widget
child
;
...
...
@@ -42,10 +42,10 @@ class BenchMouseRegionGridHover extends WidgetRecorder {
static
const
String
benchmarkName
=
'bench_mouse_region_grid_hover'
;
_Tester
_tester
;
late
_Tester
_tester
;
void
handleDataPoint
(
Duration
duration
)
{
profile
.
addDataPoint
(
'hitTestDuration'
,
duration
,
reported:
true
);
profile
!
.
addDataPoint
(
'hitTestDuration'
,
duration
,
reported:
true
);
}
// Use a non-trivial border to force Web to switch painter
...
...
@@ -66,7 +66,7 @@ class BenchMouseRegionGridHover extends WidgetRecorder {
void
frameDidDraw
()
{
if
(!
started
)
{
started
=
true
;
SchedulerBinding
.
instance
.
addPostFrameCallback
((
Duration
timeStamp
)
async
{
SchedulerBinding
.
instance
!
.
addPostFrameCallback
((
Duration
timeStamp
)
async
{
_tester
.
start
();
registerDidStop
(
_tester
.
stop
);
});
...
...
@@ -119,22 +119,22 @@ class BenchMouseRegionGridHover extends WidgetRecorder {
class
_UntilNextFrame
{
_UntilNextFrame
.
_
();
static
Completer
<
void
>
_completer
;
static
Completer
<
void
>
?
_completer
;
static
Future
<
void
>
wait
()
{
if
(
_UntilNextFrame
.
_completer
==
null
)
{
_UntilNextFrame
.
_completer
=
Completer
<
void
>();
SchedulerBinding
.
instance
.
addPostFrameCallback
((
_
)
{
_UntilNextFrame
.
_completer
.
complete
(
null
);
SchedulerBinding
.
instance
!
.
addPostFrameCallback
((
_
)
{
_UntilNextFrame
.
_completer
!
.
complete
(
null
);
_UntilNextFrame
.
_completer
=
null
;
});
}
return
_UntilNextFrame
.
_completer
.
future
;
return
_UntilNextFrame
.
_completer
!
.
future
;
}
}
class
_Tester
{
_Tester
({
this
.
onDataPoint
});
_Tester
({
required
this
.
onDataPoint
});
final
ValueSetter
<
Duration
>
onDataPoint
;
...
...
@@ -145,12 +145,12 @@ class _Tester {
TestGesture
get
gesture
{
return
_gesture
??=
TestGesture
(
dispatcher:
(
PointerEvent
event
)
async
{
RendererBinding
.
instance
.
handlePointerEvent
(
event
);
RendererBinding
.
instance
!
.
handlePointerEvent
(
event
);
},
kind:
PointerDeviceKind
.
mouse
,
);
}
TestGesture
_gesture
;
TestGesture
?
_gesture
;
Duration
currentTime
=
Duration
.
zero
;
...
...
dev/benchmarks/macrobenchmarks/lib/src/web/bench_mouse_region_grid_scroll.dart
View file @
37bc7223
...
...
@@ -41,7 +41,7 @@ class BenchMouseRegionGridScroll extends WidgetRecorder {
void
frameDidDraw
()
{
if
(!
started
)
{
started
=
true
;
SchedulerBinding
.
instance
.
addPostFrameCallback
((
Duration
timeStamp
)
async
{
SchedulerBinding
.
instance
!
.
addPostFrameCallback
((
Duration
timeStamp
)
async
{
_tester
.
start
();
registerDidStop
(
_tester
.
stop
);
});
...
...
@@ -91,17 +91,17 @@ class BenchMouseRegionGridScroll extends WidgetRecorder {
class
_UntilNextFrame
{
_UntilNextFrame
.
_
();
static
Completer
<
void
>
_completer
;
static
Completer
<
void
>
?
_completer
;
static
Future
<
void
>
wait
()
{
if
(
_UntilNextFrame
.
_completer
==
null
)
{
_UntilNextFrame
.
_completer
=
Completer
<
void
>();
SchedulerBinding
.
instance
.
addPostFrameCallback
((
_
)
{
_UntilNextFrame
.
_completer
.
complete
(
null
);
SchedulerBinding
.
instance
!
.
addPostFrameCallback
((
_
)
{
_UntilNextFrame
.
_completer
!
.
complete
(
null
);
_UntilNextFrame
.
_completer
=
null
;
});
}
return
_UntilNextFrame
.
_completer
.
future
;
return
_UntilNextFrame
.
_completer
!
.
future
;
}
}
...
...
@@ -117,12 +117,12 @@ class _Tester {
TestGesture
get
gesture
{
return
_gesture
??=
TestGesture
(
dispatcher:
(
PointerEvent
event
)
async
{
RendererBinding
.
instance
.
handlePointerEvent
(
event
);
RendererBinding
.
instance
!
.
handlePointerEvent
(
event
);
},
kind:
PointerDeviceKind
.
mouse
,
);
}
TestGesture
_gesture
;
TestGesture
?
_gesture
;
Duration
currentTime
=
Duration
.
zero
;
...
...
dev/benchmarks/macrobenchmarks/lib/src/web/bench_mouse_region_mixed_grid_hover.dart
View file @
37bc7223
...
...
@@ -14,7 +14,7 @@ import 'package:flutter_test/flutter_test.dart';
import
'recorder.dart'
;
class
_NestedMouseRegion
extends
StatelessWidget
{
const
_NestedMouseRegion
({
this
.
nests
,
this
.
child
});
const
_NestedMouseRegion
({
required
this
.
nests
,
required
this
.
child
});
final
int
nests
;
final
Widget
child
;
...
...
@@ -33,7 +33,7 @@ class _NestedMouseRegion extends StatelessWidget {
}
class
_NestedListener
extends
StatelessWidget
{
const
_NestedListener
({
this
.
nests
,
this
.
child
});
const
_NestedListener
({
required
this
.
nests
,
required
this
.
child
});
final
int
nests
;
final
Widget
child
;
...
...
@@ -61,10 +61,10 @@ class BenchMouseRegionMixedGridHover extends WidgetRecorder {
static
const
String
benchmarkName
=
'bench_mouse_region_mixed_grid_hover'
;
_Tester
_tester
;
late
_Tester
_tester
;
void
handleDataPoint
(
Duration
duration
)
{
profile
.
addDataPoint
(
'hitTestDuration'
,
duration
,
reported:
true
);
profile
!
.
addDataPoint
(
'hitTestDuration'
,
duration
,
reported:
true
);
}
// Use a non-trivial border to force Web to switch painter
...
...
@@ -85,7 +85,7 @@ class BenchMouseRegionMixedGridHover extends WidgetRecorder {
void
frameDidDraw
()
{
if
(!
started
)
{
started
=
true
;
SchedulerBinding
.
instance
.
addPostFrameCallback
((
Duration
timeStamp
)
async
{
SchedulerBinding
.
instance
!
.
addPostFrameCallback
((
Duration
timeStamp
)
async
{
_tester
.
start
();
registerDidStop
(
_tester
.
stop
);
});
...
...
@@ -141,22 +141,22 @@ class BenchMouseRegionMixedGridHover extends WidgetRecorder {
class
_UntilNextFrame
{
_UntilNextFrame
.
_
();
static
Completer
<
void
>
_completer
;
static
Completer
<
void
>
?
_completer
;
static
Future
<
void
>
wait
()
{
if
(
_UntilNextFrame
.
_completer
==
null
)
{
_UntilNextFrame
.
_completer
=
Completer
<
void
>();
SchedulerBinding
.
instance
.
addPostFrameCallback
((
_
)
{
_UntilNextFrame
.
_completer
.
complete
(
null
);
SchedulerBinding
.
instance
!
.
addPostFrameCallback
((
_
)
{
_UntilNextFrame
.
_completer
!
.
complete
(
null
);
_UntilNextFrame
.
_completer
=
null
;
});
}
return
_UntilNextFrame
.
_completer
.
future
;
return
_UntilNextFrame
.
_completer
!
.
future
;
}
}
class
_Tester
{
_Tester
({
this
.
onDataPoint
});
_Tester
({
required
this
.
onDataPoint
});
final
ValueSetter
<
Duration
>
onDataPoint
;
...
...
@@ -167,12 +167,12 @@ class _Tester {
TestGesture
get
gesture
{
return
_gesture
??=
TestGesture
(
dispatcher:
(
PointerEvent
event
)
async
{
RendererBinding
.
instance
.
handlePointerEvent
(
event
);
RendererBinding
.
instance
!
.
handlePointerEvent
(
event
);
},
kind:
PointerDeviceKind
.
mouse
,
);
}
TestGesture
_gesture
;
TestGesture
?
_gesture
;
Duration
currentTime
=
Duration
.
zero
;
...
...
dev/benchmarks/macrobenchmarks/lib/src/web/bench_pageview_scroll_linethrough.dart
View file @
37bc7223
...
...
@@ -26,7 +26,7 @@ class BenchPageViewScrollLineThrough extends WidgetRecorder {
}
class
_MyScrollContainer
extends
StatefulWidget
{
const
_MyScrollContainer
({
Key
key
})
:
super
(
key:
key
);
const
_MyScrollContainer
({
Key
?
key
})
:
super
(
key:
key
);
@override
State
<
_MyScrollContainer
>
createState
()
=>
_MyScrollContainerState
();
...
...
@@ -35,7 +35,7 @@ class _MyScrollContainer extends StatefulWidget {
class
_MyScrollContainerState
extends
State
<
_MyScrollContainer
>
{
static
const
Duration
stepDuration
=
Duration
(
milliseconds:
500
);
PageController
pageController
;
late
PageController
pageController
;
int
pageNumber
=
0
;
@override
...
...
@@ -56,8 +56,8 @@ class _MyScrollContainerState extends State<_MyScrollContainer> {
@override
void
dispose
()
{
super
.
dispose
();
pageController
.
dispose
();
super
.
dispose
();
}
@override
...
...
@@ -77,8 +77,8 @@ class _CustomPainter extends CustomPainter {
_CustomPainter
(
this
.
text
);
final
String
text
;
Paint
_linePainter
;
TextPainter
_textPainter
;
final
Paint
_linePainter
=
Paint
()
;
final
TextPainter
_textPainter
=
TextPainter
()
;
static
const
double
lineWidth
=
0.5
;
@override
...
...
@@ -91,14 +91,12 @@ class _CustomPainter extends CustomPainter {
const
double
viewPadding
=
5
;
const
double
circlePadding
=
4
;
yPosition
=
viewPadding
;
_textPainter
=
_textPainter
??
TextPainter
();
_textPainter
.
textDirection
=
TextDirection
.
ltr
;
_textPainter
.
textWidthBasis
=
TextWidthBasis
.
longestLine
;
_textPainter
.
textScaleFactor
=
1
;
const
TextStyle
textStyle
=
TextStyle
(
color:
Colors
.
black87
,
fontSize:
13
,
fontFamily:
'Roboto'
);
_linePainter
=
_linePainter
??
Paint
();
_linePainter
.
isAntiAlias
=
true
;
for
(
int
i
=
0
;
i
<
42
;
i
++)
{
_linePainter
.
color
=
Colors
.
white
;
...
...
dev/benchmarks/macrobenchmarks/lib/src/web/bench_paths_recording.dart
View file @
37bc7223
...
...
@@ -7,218 +7,218 @@ import 'dart:ui';
// The code below was generated by modify several parts of the engine
// May 2020 and running Flutter Gallery.
PathFillType
gFillType
;
Rect
gBounds
;
List
<
dynamic
>
allPaths
;
Path
path8
;
Path
path10
;
Path
path12
;
Path
path14
;
Path
path16
;
Path
path18
;
Path
path34
;
Path
path50
;
Path
path60
;
Path
path63
;
Path
path66
;
Path
path69
;
Path
path72
;
Path
path75
;
Path
path78
;
Path
path80
;
Path
path82
;
Path
path84
;
Path
path86
;
Path
path88
;
Path
path119
;
Path
path120
;
Path
path121
;
Path
path122
;
Path
path123
;
Path
path125
;
Path
path127
;
Path
path129
;
Path
path131
;
Path
path132
;
Path
path134
;
Path
path137
;
Path
path140
;
Path
path143
;
Path
path145
;
Path
path147
;
Path
path208
;
Path
path209
;
Path
path210
;
Path
path211
;
Path
path213
;
Path
path216
;
Path
path219
;
Path
path222
;
Path
path225
;
Path
path227
;
Path
path229
;
Path
path232
;
Path
path235
;
Path
path238
;
Path
path240
;
Path
path242
;
Path
path277
;
Path
path278
;
Path
path279
;
Path
path280
;
Path
path281
;
Path
path282
;
Path
path284
;
Path
path286
;
Path
path288
;
Path
path290
;
Path
path292
;
Path
path295
;
Path
path298
;
Path
path301
;
Path
path330
;
Path
path331
;
Path
path332
;
Path
path333
;
Path
path334
;
Path
path336
;
Path
path338
;
Path
path340
;
Path
path342
;
Path
path344
;
Path
path345
;
Path
path346
;
Path
path349
;
Path
path352
;
Path
path356
;
Path
path358
;
Path
path359
;
Path
path360
;
Path
path361
;
Path
path362
;
Path
path363
;
Path
path366
;
Path
path369
;
Path
path372
;
Path
path373
;
Path
path374
;
Path
path375
;
Path
path376
;
Path
path379
;
Path
path382
;
Path
path385
;
Path
path386
;
Path
path387
;
Path
path388
;
Path
path389
;
Path
path392
;
Path
path395
;
Path
path398
;
Path
path399
;
Path
path400
;
Path
path401
;
Path
path402
;
Path
path405
;
Path
path408
;
Path
path411
;
Path
path412
;
Path
path413
;
Path
path414
;
Path
path415
;
Path
path418
;
Path
path421
;
Path
path424
;
Path
path425
;
Path
path426
;
Path
path427
;
Path
path428
;
Path
path431
;
Path
path434
;
Path
path437
;
Path
path438
;
Path
path439
;
Path
path440
;
Path
path441
;
Path
path444
;
Path
path447
;
Path
path450
;
Path
path451
;
Path
path452
;
Path
path453
;
Path
path454
;
Path
path457
;
Path
path460
;
Path
path463
;
Path
path464
;
Path
path465
;
Path
path466
;
Path
path467
;
Path
path470
;
Path
path473
;
Path
path476
;
Path
path477
;
Path
path478
;
Path
path479
;
Path
path480
;
Path
path483
;
Path
path486
;
Path
path489
;
Path
path490
;
Path
path491
;
Path
path492
;
Path
path493
;
Path
path496
;
Path
path499
;
Path
path502
;
Path
path503
;
Path
path504
;
Path
path505
;
Path
path506
;
Path
path509
;
Path
path512
;
Path
path515
;
Path
path516
;
Path
path517
;
Path
path518
;
Path
path519
;
Path
path522
;
Path
path525
;
Path
path528
;
Path
path529
;
Path
path530
;
Path
path531
;
Path
path532
;
Path
path535
;
Path
path538
;
Path
path541
;
Path
path542
;
Path
path543
;
Path
path544
;
Path
path545
;
Path
path548
;
Path
path551
;
Path
path554
;
Path
path555
;
Path
path556
;
Path
path557
;
Path
path558
;
Path
path561
;
Path
path564
;
Path
path573
;
Path
path577
;
Path
path579
;
Path
path591
;
Path
path592
;
Path
path593
;
Path
path594
;
Path
path595
;
Path
path597
;
Path
path599
;
Path
path601
;
Path
path603
;
Path
path606
;
Path
path608
;
late
PathFillType
gFillType
;
late
Rect
gBounds
;
late
List
<
dynamic
>
allPaths
;
late
Path
path8
;
late
Path
path10
;
late
Path
path12
;
late
Path
path14
;
late
Path
path16
;
late
Path
path18
;
late
Path
path34
;
late
Path
path50
;
late
Path
path60
;
late
Path
path63
;
late
Path
path66
;
late
Path
path69
;
late
Path
path72
;
late
Path
path75
;
late
Path
path78
;
late
Path
path80
;
late
Path
path82
;
late
Path
path84
;
late
Path
path86
;
late
Path
path88
;
late
Path
path119
;
late
Path
path120
;
late
Path
path121
;
late
Path
path122
;
late
Path
path123
;
late
Path
path125
;
late
Path
path127
;
late
Path
path129
;
late
Path
path131
;
late
Path
path132
;
late
Path
path134
;
late
Path
path137
;
late
Path
path140
;
late
Path
path143
;
late
Path
path145
;
late
Path
path147
;
late
Path
path208
;
late
Path
path209
;
late
Path
path210
;
late
Path
path211
;
late
Path
path213
;
late
Path
path216
;
late
Path
path219
;
late
Path
path222
;
late
Path
path225
;
late
Path
path227
;
late
Path
path229
;
late
Path
path232
;
late
Path
path235
;
late
Path
path238
;
late
Path
path240
;
late
Path
path242
;
late
Path
path277
;
late
Path
path278
;
late
Path
path279
;
late
Path
path280
;
late
Path
path281
;
late
Path
path282
;
late
Path
path284
;
late
Path
path286
;
late
Path
path288
;
late
Path
path290
;
late
Path
path292
;
late
Path
path295
;
late
Path
path298
;
late
Path
path301
;
late
Path
path330
;
late
Path
path331
;
late
Path
path332
;
late
Path
path333
;
late
Path
path334
;
late
Path
path336
;
late
Path
path338
;
late
Path
path340
;
late
Path
path342
;
late
Path
path344
;
late
Path
path345
;
late
Path
path346
;
late
Path
path349
;
late
Path
path352
;
late
Path
path356
;
late
Path
path358
;
late
Path
path359
;
late
Path
path360
;
late
Path
path361
;
late
Path
path362
;
late
Path
path363
;
late
Path
path366
;
late
Path
path369
;
late
Path
path372
;
late
Path
path373
;
late
Path
path374
;
late
Path
path375
;
late
Path
path376
;
late
Path
path379
;
late
Path
path382
;
late
Path
path385
;
late
Path
path386
;
late
Path
path387
;
late
Path
path388
;
late
Path
path389
;
late
Path
path392
;
late
Path
path395
;
late
Path
path398
;
late
Path
path399
;
late
Path
path400
;
late
Path
path401
;
late
Path
path402
;
late
Path
path405
;
late
Path
path408
;
late
Path
path411
;
late
Path
path412
;
late
Path
path413
;
late
Path
path414
;
late
Path
path415
;
late
Path
path418
;
late
Path
path421
;
late
Path
path424
;
late
Path
path425
;
late
Path
path426
;
late
Path
path427
;
late
Path
path428
;
late
Path
path431
;
late
Path
path434
;
late
Path
path437
;
late
Path
path438
;
late
Path
path439
;
late
Path
path440
;
late
Path
path441
;
late
Path
path444
;
late
Path
path447
;
late
Path
path450
;
late
Path
path451
;
late
Path
path452
;
late
Path
path453
;
late
Path
path454
;
late
Path
path457
;
late
Path
path460
;
late
Path
path463
;
late
Path
path464
;
late
Path
path465
;
late
Path
path466
;
late
Path
path467
;
late
Path
path470
;
late
Path
path473
;
late
Path
path476
;
late
Path
path477
;
late
Path
path478
;
late
Path
path479
;
late
Path
path480
;
late
Path
path483
;
late
Path
path486
;
late
Path
path489
;
late
Path
path490
;
late
Path
path491
;
late
Path
path492
;
late
Path
path493
;
late
Path
path496
;
late
Path
path499
;
late
Path
path502
;
late
Path
path503
;
late
Path
path504
;
late
Path
path505
;
late
Path
path506
;
late
Path
path509
;
late
Path
path512
;
late
Path
path515
;
late
Path
path516
;
late
Path
path517
;
late
Path
path518
;
late
Path
path519
;
late
Path
path522
;
late
Path
path525
;
late
Path
path528
;
late
Path
path529
;
late
Path
path530
;
late
Path
path531
;
late
Path
path532
;
late
Path
path535
;
late
Path
path538
;
late
Path
path541
;
late
Path
path542
;
late
Path
path543
;
late
Path
path544
;
late
Path
path545
;
late
Path
path548
;
late
Path
path551
;
late
Path
path554
;
late
Path
path555
;
late
Path
path556
;
late
Path
path557
;
late
Path
path558
;
late
Path
path561
;
late
Path
path564
;
late
Path
path573
;
late
Path
path577
;
late
Path
path579
;
late
Path
path591
;
late
Path
path592
;
late
Path
path593
;
late
Path
path594
;
late
Path
path595
;
late
Path
path597
;
late
Path
path599
;
late
Path
path601
;
late
Path
path603
;
late
Path
path606
;
late
Path
path608
;
void
createPaths
(
)
{
allPaths
=
<
dynamic
>[];
...
...
dev/benchmarks/macrobenchmarks/lib/src/web/bench_picture_recording.dart
View file @
37bc7223
...
...
@@ -26,12 +26,12 @@ class BenchPictureRecording extends RawRecorder {
/// Cached paint used for drawing.
///
/// We want to avoid polluting the results with paint initialization logic.
Paint
paint
;
late
Paint
paint
;
/// A prelaid out and cached paragraph.
///
/// This is cached to remove text layout time from the benchmark time.
Paragraph
paragraph
;
late
Paragraph
paragraph
;
@override
Future
<
void
>
setUpAll
()
async
{
...
...
dev/benchmarks/macrobenchmarks/lib/src/web/bench_simple_lazy_text_scroll.dart
View file @
37bc7223
...
...
@@ -56,9 +56,9 @@ class BenchSimpleLazyTextScroll extends WidgetRecorder {
class
_TestScrollingWidget
extends
StatefulWidget
{
const
_TestScrollingWidget
({
@
required
this
.
initialScrollOffset
,
@
required
this
.
scrollDistance
,
@
required
this
.
scrollDuration
,
required
this
.
initialScrollOffset
,
required
this
.
scrollDistance
,
required
this
.
scrollDuration
,
});
final
double
initialScrollOffset
;
...
...
@@ -72,7 +72,7 @@ class _TestScrollingWidget extends StatefulWidget {
}
class
_TestScrollingWidgetState
extends
State
<
_TestScrollingWidget
>
{
ScrollController
scrollController
;
late
ScrollController
scrollController
;
@override
void
initState
()
{
...
...
@@ -98,6 +98,12 @@ class _TestScrollingWidgetState extends State<_TestScrollingWidget> {
});
}
@override
void
dispose
()
{
scrollController
.
dispose
();
super
.
dispose
();
}
@override
Widget
build
(
BuildContext
context
)
{
return
ListView
.
builder
(
...
...
dev/benchmarks/macrobenchmarks/lib/src/web/bench_text_layout.dart
View file @
37bc7223
...
...
@@ -31,7 +31,7 @@ class ParagraphGenerator {
/// font-size so that the engine doesn't reuse a cached ruler.
ui
.
Paragraph
generate
(
String
text
,
{
int
maxLines
,
int
?
maxLines
,
bool
hasEllipsis
=
false
,
})
{
final
ui
.
ParagraphBuilder
builder
=
ui
.
ParagraphBuilder
(
ui
.
ParagraphStyle
(
...
...
@@ -61,8 +61,8 @@ enum _TestMode {
/// Sends a platform message to the web engine to enable/disable the usage of
/// the canvas-based text measurement implementation.
void
_setTestMode
(
_TestMode
mode
)
{
bool
useCanvasText
;
// null means do not force DOM or canvas, works for CanvasKit
void
_setTestMode
(
_TestMode
?
mode
)
{
bool
?
useCanvasText
;
// null means do not force DOM or canvas, works for CanvasKit
switch
(
mode
)
{
case
_TestMode
.
useDomTextLayout
:
useCanvasText
=
false
;
...
...
@@ -148,11 +148,11 @@ class BenchTextLayout extends RawRecorder {
}
void
recordParagraphOperations
({
@
required
Profile
profile
,
@
required
ui
.
Paragraph
paragraph
,
@
required
String
text
,
@
required
String
keyPrefix
,
@
required
double
maxWidth
,
required
Profile
profile
,
required
ui
.
Paragraph
paragraph
,
required
String
text
,
required
String
keyPrefix
,
required
double
maxWidth
,
})
{
profile
.
record
(
'
$keyPrefix
.layout'
,
()
{
paragraph
.
layout
(
ui
.
ParagraphConstraints
(
width:
maxWidth
));
...
...
@@ -277,7 +277,7 @@ class BenchBuildColorsGrid extends WidgetBuildRecorder {
// updates the value of [showWidget] in preparation for the next frame.
// TODO(yjbanov): https://github.com/flutter/flutter/issues/53877
if
(
showWidget
&&
_mode
!=
_TestMode
.
useCanvasKit
)
{
profile
.
addDataPoint
(
profile
!
.
addDataPoint
(
'text_layout'
,
Duration
(
microseconds:
_textLayoutMicros
.
toInt
()),
reported:
true
,
...
...
@@ -299,15 +299,13 @@ class BenchBuildColorsGrid extends WidgetBuildRecorder {
const
double
kColorItemHeight
=
48.0
;
class
Palette
{
Palette
({
this
.
name
,
this
.
primary
,
this
.
accent
,
this
.
threshold
=
900
});
Palette
({
required
this
.
name
,
required
this
.
primary
,
this
.
accent
,
this
.
threshold
=
900
});
final
String
name
;
final
MaterialColor
primary
;
final
MaterialAccentColor
accent
;
final
MaterialAccentColor
?
accent
;
final
int
threshold
;
// titles for indices > threshold are white, otherwise black
bool
get
isValid
=>
name
!=
null
&&
primary
!=
null
&&
threshold
!=
null
;
}
final
List
<
Palette
>
allPalettes
=
<
Palette
>[
...
...
@@ -390,9 +388,9 @@ final List<Palette> allPalettes = <Palette>[
class
ColorItem
extends
StatelessWidget
{
const
ColorItem
({
Key
key
,
@
required
this
.
index
,
@
required
this
.
color
,
Key
?
key
,
required
this
.
index
,
required
this
.
color
,
this
.
prefix
=
''
,
})
:
assert
(
index
!=
null
),
assert
(
color
!=
null
),
...
...
@@ -432,11 +430,10 @@ class ColorItem extends StatelessWidget {
}
class
PaletteTabView
extends
StatelessWidget
{
PaletteTabView
({
Key
key
,
@required
this
.
colors
,
})
:
assert
(
colors
!=
null
&&
colors
.
isValid
),
super
(
key:
key
);
const
PaletteTabView
({
Key
?
key
,
required
this
.
colors
,
})
:
super
(
key:
key
);
final
Palette
colors
;
...
...
@@ -458,9 +455,9 @@ class PaletteTabView extends StatelessWidget {
Widget
build
(
BuildContext
context
)
{
final
TextTheme
textTheme
=
Theme
.
of
(
context
).
textTheme
;
final
TextStyle
whiteTextStyle
=
textTheme
.
bodyText2
.
copyWith
(
color:
Colors
.
white
);
textTheme
.
bodyText2
!
.
copyWith
(
color:
Colors
.
white
);
final
TextStyle
blackTextStyle
=
textTheme
.
bodyText2
.
copyWith
(
color:
Colors
.
black
);
textTheme
.
bodyText2
!
.
copyWith
(
color:
Colors
.
black
);
return
Scrollbar
(
child:
ListView
(
itemExtent:
kColorItemHeight
,
...
...
@@ -468,7 +465,7 @@ class PaletteTabView extends StatelessWidget {
...
primaryKeys
.
map
<
Widget
>((
int
index
)
{
return
DefaultTextStyle
(
style:
index
>
colors
.
threshold
?
whiteTextStyle
:
blackTextStyle
,
child:
ColorItem
(
index:
index
,
color:
colors
.
primary
[
index
]),
child:
ColorItem
(
index:
index
,
color:
colors
.
primary
[
index
]
!
),
);
}),
if
(
colors
.
accent
!=
null
)
...
...
@@ -477,7 +474,7 @@ class PaletteTabView extends StatelessWidget {
style:
index
>
colors
.
threshold
?
whiteTextStyle
:
blackTextStyle
,
child:
ColorItem
(
index:
index
,
color:
colors
.
accent
[
index
]
,
prefix:
'A'
),
index:
index
,
color:
colors
.
accent
![
index
]!
,
prefix:
'A'
),
);
}),
],
...
...
@@ -487,7 +484,7 @@ class PaletteTabView extends StatelessWidget {
}
class
ColorsDemo
extends
StatelessWidget
{
const
ColorsDemo
({
Key
key
})
:
super
(
key:
key
);
const
ColorsDemo
({
Key
?
key
})
:
super
(
key:
key
);
@override
Widget
build
(
BuildContext
context
)
{
...
...
dev/benchmarks/macrobenchmarks/lib/src/web/bench_text_out_of_picture_bounds.dart
View file @
37bc7223
...
...
@@ -54,8 +54,8 @@ class BenchTextOutOfPictureBounds extends SceneBuilderRecorder {
static
const
String
benchmarkName
=
'text_out_of_picture_bounds'
;
List
<
Paragraph
>
singleLineParagraphs
;
List
<
Paragraph
>
multiLineParagraphs
;
late
List
<
Paragraph
>
singleLineParagraphs
;
late
List
<
Paragraph
>
multiLineParagraphs
;
@override
void
onDrawFrame
(
SceneBuilder
sceneBuilder
)
{
...
...
dev/benchmarks/macrobenchmarks/lib/src/web/bench_wrapbox_scroll.dart
View file @
37bc7223
...
...
@@ -29,16 +29,14 @@ class BenchWrapBoxScroll extends WidgetRecorder {
}
class
MyHomePage
extends
StatefulWidget
{
const
MyHomePage
({
Key
key
,
this
.
title
})
:
super
(
key:
key
);
final
String
title
;
const
MyHomePage
({
Key
?
key
})
:
super
(
key:
key
);
@override
State
<
MyHomePage
>
createState
()
=>
_MyHomePageState
();
}
class
_MyHomePageState
extends
State
<
MyHomePage
>
{
ScrollController
scrollController
;
late
ScrollController
scrollController
;
int
block
=
0
;
static
const
Duration
stepDuration
=
Duration
(
milliseconds:
500
);
static
const
double
stepDistance
=
400
;
...
...
@@ -61,8 +59,8 @@ class _MyHomePageState extends State<MyHomePage> {
@override
void
dispose
()
{
super
.
dispose
();
scrollController
.
dispose
();
super
.
dispose
();
}
@override
...
...
@@ -84,7 +82,7 @@ class _MyHomePageState extends State<MyHomePage> {
}
class
ProductPreview
extends
StatelessWidget
{
const
ProductPreview
(
this
.
previewIndex
,
{
Key
key
})
:
super
(
key:
key
);
const
ProductPreview
(
this
.
previewIndex
,
{
Key
?
key
})
:
super
(
key:
key
);
final
int
previewIndex
;
...
...
@@ -143,8 +141,8 @@ class ProductPreview extends StatelessWidget {
class
ProductOption
extends
StatelessWidget
{
const
ProductOption
({
Key
key
,
@
required
this
.
optionText
,
Key
?
key
,
required
this
.
optionText
,
})
:
super
(
key:
key
);
final
String
optionText
;
...
...
dev/benchmarks/macrobenchmarks/lib/src/web/recorder.dart
View file @
37bc7223
This diff is collapsed.
Click to expand it.
dev/benchmarks/macrobenchmarks/lib/src/web/test_data.dart
View file @
37bc7223
...
...
@@ -5,8 +5,6 @@
import
'dart:math'
as
math
;
import
'dart:ui'
;
import
'package:meta/meta.dart'
;
// Used to randomize data.
//
// Using constant seed for reproducibility.
...
...
@@ -34,11 +32,11 @@ final List<String> lipsum = 'Lorem ipsum dolor sit amet, consectetur adipiscing
/// Generates strings and builds pre-laid out paragraphs to be used by
/// benchmarks.
List
<
Paragraph
>
generateLaidOutParagraphs
({
@
required
int
paragraphCount
,
@
required
int
minWordCountPerParagraph
,
@
required
int
maxWordCountPerParagraph
,
@
required
double
widthConstraint
,
@
required
Color
color
,
required
int
paragraphCount
,
required
int
minWordCountPerParagraph
,
required
int
maxWordCountPerParagraph
,
required
double
widthConstraint
,
required
Color
color
,
})
{
final
List
<
Paragraph
>
strings
=
<
Paragraph
>[];
int
wordPointer
=
0
;
// points to the next word in lipsum to extract
...
...
dev/benchmarks/macrobenchmarks/lib/web_benchmarks.dart
View file @
37bc7223
...
...
@@ -93,7 +93,7 @@ Future<void> main() async {
}
Future
<
void
>
_runBenchmark
(
String
benchmarkName
)
async
{
final
RecorderFactory
recorderFactory
=
benchmarks
[
benchmarkName
];
final
RecorderFactory
?
recorderFactory
=
benchmarks
[
benchmarkName
];
if
(
recorderFactory
==
null
)
{
_fallbackToManual
(
'Benchmark
$benchmarkName
not found.'
);
...
...
@@ -145,7 +145,7 @@ Future<void> _runBenchmark(String benchmarkName) async {
}
void
_fallbackToManual
(
String
error
)
{
html
.
document
.
body
.
appendHtml
(
'''
html
.
document
.
body
!
.
appendHtml
(
'''
<div id="manual-panel">
<h3>
$error
</h3>
...
...
@@ -163,9 +163,9 @@ void _fallbackToManual(String error) {
'''
,
validator:
html
.
NodeValidatorBuilder
()..
allowHtml5
()..
allowInlineStyles
());
for
(
final
String
benchmarkName
in
benchmarks
.
keys
)
{
final
html
.
Element
button
=
html
.
document
.
querySelector
(
'#
$benchmarkName
'
);
final
html
.
Element
button
=
html
.
document
.
querySelector
(
'#
$benchmarkName
'
)
!
;
button
.
addEventListener
(
'click'
,
(
_
)
{
final
html
.
Element
manualPanel
=
html
.
document
.
querySelector
(
'#manual-panel'
);
final
html
.
Element
?
manualPanel
=
html
.
document
.
querySelector
(
'#manual-panel'
);
manualPanel
?.
remove
();
_runBenchmark
(
benchmarkName
);
});
...
...
@@ -174,14 +174,14 @@ void _fallbackToManual(String error) {
/// Visualizes results on the Web page for manual inspection.
void
_printResultsToScreen
(
Profile
profile
)
{
html
.
document
.
body
.
remove
();
html
.
document
.
body
!
.
remove
();
html
.
document
.
body
=
html
.
BodyElement
();
html
.
document
.
body
.
appendHtml
(
'<h2>
${profile.name}
</h2>'
);
html
.
document
.
body
!
.
appendHtml
(
'<h2>
${profile.name}
</h2>'
);
profile
.
scoreData
.
forEach
((
String
scoreKey
,
Timeseries
timeseries
)
{
html
.
document
.
body
.
appendHtml
(
'<h2>
$scoreKey
</h2>'
);
html
.
document
.
body
.
appendHtml
(
'<pre>
${timeseries.computeStats()}
</pre>'
);
html
.
document
.
body
.
append
(
TimeseriesVisualization
(
timeseries
).
render
());
html
.
document
.
body
!
.
appendHtml
(
'<h2>
$scoreKey
</h2>'
);
html
.
document
.
body
!
.
appendHtml
(
'<pre>
${timeseries.computeStats()}
</pre>'
);
html
.
document
.
body
!
.
append
(
TimeseriesVisualization
(
timeseries
).
render
());
});
}
...
...
@@ -190,7 +190,7 @@ class TimeseriesVisualization {
TimeseriesVisualization
(
this
.
_timeseries
)
{
_stats
=
_timeseries
.
computeStats
();
_canvas
=
html
.
CanvasElement
();
_screenWidth
=
html
.
window
.
screen
.
width
;
_screenWidth
=
html
.
window
.
screen
!.
width
!
;
_canvas
.
width
=
_screenWidth
;
_canvas
.
height
=
(
_kCanvasHeight
*
html
.
window
.
devicePixelRatio
).
round
();
_canvas
.
style
...
...
@@ -211,13 +211,13 @@ class TimeseriesVisualization {
static
const
double
_kCanvasHeight
=
200
;
final
Timeseries
_timeseries
;
TimeseriesStats
_stats
;
html
.
CanvasElement
_canvas
;
html
.
CanvasRenderingContext2D
_ctx
;
int
_screenWidth
;
late
TimeseriesStats
_stats
;
late
html
.
CanvasElement
_canvas
;
late
html
.
CanvasRenderingContext2D
_ctx
;
late
int
_screenWidth
;
// Used to normalize benchmark values to chart height.
double
_maxValueChartRange
;
late
double
_maxValueChartRange
;
/// Converts a sample value to vertical canvas coordinates.
///
...
...
@@ -300,7 +300,7 @@ class LocalBenchmarkServerClient {
/// This happens when you run benchmarks using plain `flutter run` rather than
/// devicelab test harness. The test harness spins up a special server that
/// provides API for automatically picking the next benchmark to run.
bool
isInManualMode
;
bool
isInManualMode
=
false
;
/// Asks the local server for the name of the next benchmark to run.
///
...
...
@@ -323,7 +323,7 @@ class LocalBenchmarkServerClient {
}
isInManualMode
=
false
;
return
request
.
responseText
;
return
request
.
responseText
!
;
}
void
_checkNotManualMode
()
{
...
...
@@ -405,11 +405,11 @@ class LocalBenchmarkServerClient {
/// crash on 404, which we use to detect `flutter run`.
Future
<
html
.
HttpRequest
>
_requestXhr
(
String
url
,
{
String
method
,
bool
withCredentials
,
String
responseType
,
String
mimeType
,
Map
<
String
,
String
>
requestHeaders
,
String
?
method
,
bool
?
withCredentials
,
String
?
responseType
,
String
?
mimeType
,
Map
<
String
,
String
>
?
requestHeaders
,
dynamic
sendData
,
})
{
final
Completer
<
html
.
HttpRequest
>
completer
=
Completer
<
html
.
HttpRequest
>();
...
...
dev/benchmarks/macrobenchmarks/pubspec.yaml
View file @
37bc7223
...
...
@@ -2,7 +2,7 @@ name: macrobenchmarks
description
:
Performance benchmarks using flutter drive.
environment
:
sdk
:
"
>=2.
2.2
<3.0.0"
sdk
:
"
>=2.
12.0
<3.0.0"
dependencies
:
flutter
:
...
...
dev/benchmarks/macrobenchmarks/test/frame_policy.dart
View file @
37bc7223
...
...
@@ -74,7 +74,7 @@ void main() {
frameCount
=
0
;
delays
=
await
tester
.
handlePointerEventRecord
(
records
);
await
tester
.
pumpAndSettle
();
binding
.
reportData
[
'fullyLive'
]
=
_summarizeResult
(
frameCount
,
delays
);
binding
.
reportData
!
[
'fullyLive'
]
=
_summarizeResult
(
frameCount
,
delays
);
await
tester
.
idle
();
},
);
...
...
dev/benchmarks/macrobenchmarks/test/util.dart
View file @
37bc7223
...
...
@@ -13,10 +13,10 @@ typedef ControlCallback = Future<void> Function(WidgetController controller);
void
macroPerfTestE2E
(
String
testName
,
String
routeName
,
{
Duration
pageDelay
,
Duration
?
pageDelay
,
Duration
duration
=
const
Duration
(
seconds:
3
),
ControlCallback
body
,
ControlCallback
setup
,
ControlCallback
?
body
,
ControlCallback
?
setup
,
})
{
final
WidgetsBinding
_binding
=
IntegrationTestWidgetsFlutterBinding
.
ensureInitialized
();
assert
(
_binding
is
IntegrationTestWidgetsFlutterBinding
);
...
...
dev/benchmarks/macrobenchmarks/test_driver/animated_image.dart
View file @
37bc7223
...
...
@@ -15,7 +15,7 @@ import 'package:macrobenchmarks/src/animated_image.dart';
/// set number of image frames to render.
Future
<
void
>
main
()
async
{
final
Completer
<
void
>
waiter
=
Completer
<
void
>();
enableFlutterDriverExtension
(
handler:
(
String
request
)
async
{
enableFlutterDriverExtension
(
handler:
(
String
?
request
)
async
{
if
(
request
!=
'waitForAnimation'
)
{
throw
UnsupportedError
(
'Unrecognized request
$request
'
);
}
...
...
dev/benchmarks/macrobenchmarks/test_driver/e2e_test.dart
View file @
37bc7223
...
...
@@ -5,9 +5,9 @@
import
'package:integration_test/integration_test_driver.dart'
as
driver
;
Future
<
void
>
main
()
=>
driver
.
integrationDriver
(
responseDataCallback:
(
Map
<
String
,
dynamic
>
data
)
async
{
responseDataCallback:
(
Map
<
String
,
dynamic
>
?
data
)
async
{
await
driver
.
writeResponseData
(
data
[
'performance'
]
as
Map
<
String
,
dynamic
>,
data
?
[
'performance'
]
as
Map
<
String
,
dynamic
>,
testOutputFilename:
'e2e_perf_summary'
,
);
}
...
...
dev/benchmarks/macrobenchmarks/test_driver/frame_policy_test.dart
View file @
37bc7223
...
...
@@ -7,11 +7,11 @@ import 'dart:io';
import
'package:integration_test/integration_test_driver.dart'
as
driver
;
Future
<
void
>
main
()
=>
driver
.
integrationDriver
(
responseDataCallback:
(
Map
<
String
,
dynamic
>
data
)
async
{
responseDataCallback:
(
Map
<
String
,
dynamic
>
?
data
)
async
{
final
Map
<
String
,
dynamic
>
benchmarkLiveResult
=
data
[
'benchmarkLive'
]
as
Map
<
String
,
dynamic
>;
data
?
[
'benchmarkLive'
]
as
Map
<
String
,
dynamic
>;
final
Map
<
String
,
dynamic
>
fullyLiveResult
=
data
[
'fullyLive'
]
as
Map
<
String
,
dynamic
>;
data
?
[
'fullyLive'
]
as
Map
<
String
,
dynamic
>;
if
(
benchmarkLiveResult
[
'frame_count'
]
as
int
<
10
||
fullyLiveResult
[
'frame_count'
]
as
int
<
10
)
{
...
...
dev/benchmarks/macrobenchmarks/test_driver/large_image_changer.dart
View file @
37bc7223
...
...
@@ -11,7 +11,7 @@ import 'package:macrobenchmarks/common.dart';
import
'package:macrobenchmarks/main.dart'
;
Future
<
void
>
main
()
async
{
enableFlutterDriverExtension
(
handler:
(
String
message
)
async
{
enableFlutterDriverExtension
(
handler:
(
String
?
message
)
async
{
if
(
message
==
'getTargetPlatform'
)
{
return
defaultTargetPlatform
.
toString
();
}
...
...
dev/benchmarks/macrobenchmarks/test_driver/large_image_changer_test.dart
View file @
37bc7223
...
...
@@ -14,7 +14,7 @@ Future<void> main() async {
final
String
targetPlatform
=
await
driver
.
requestData
(
'getTargetPlatform'
);
Timeline
timeline
;
Timeline
?
timeline
;
switch
(
targetPlatform
)
{
case
'TargetPlatform.iOS'
:
{
...
...
dev/benchmarks/macrobenchmarks/test_driver/stack_size_perf_test.dart
View file @
37bc7223
...
...
@@ -16,7 +16,7 @@ const JsonEncoder _prettyEncoder = JsonEncoder.withIndent(' ');
void
main
(
)
{
test
(
'stack_size'
,
()
async
{
int
stackSizeInBytes
;
late
int
stackSizeInBytes
;
await
runDriverTestForRoute
(
kStackSizeRouteName
,
(
FlutterDriver
driver
)
async
{
final
String
stackSize
=
await
driver
.
getText
(
find
.
byValueKey
(
kStackSizeKey
));
expect
(
stackSize
.
isNotEmpty
,
isTrue
);
...
...
dev/benchmarks/macrobenchmarks/test_driver/util.dart
View file @
37bc7223
...
...
@@ -34,13 +34,13 @@ Future<void> runDriverTestForRoute(String routeName, DriverTestCallBack body) as
void
macroPerfTest
(
String
testName
,
String
routeName
,
{
Duration
pageDelay
,
Duration
?
pageDelay
,
Duration
duration
=
const
Duration
(
seconds:
3
),
Future
<
void
>
Function
(
FlutterDriver
driver
)
driverOps
,
Future
<
void
>
Function
(
FlutterDriver
driver
)
setupOps
,
Future
<
void
>
Function
(
FlutterDriver
driver
)
?
driverOps
,
Future
<
void
>
Function
(
FlutterDriver
driver
)
?
setupOps
,
})
{
test
(
testName
,
()
async
{
Timeline
timeline
;
late
Timeline
timeline
;
await
runDriverTestForRoute
(
routeName
,
(
FlutterDriver
driver
)
async
{
if
(
pageDelay
!=
null
)
{
// Wait for the page to load
...
...
@@ -48,7 +48,7 @@ void macroPerfTest(
}
if
(
setupOps
!=
null
)
{
await
setupOps
(
driver
);
await
setupOps
(
driver
);
}
timeline
=
await
driver
.
traceAction
(()
async
{
...
...
dev/benchmarks/macrobenchmarks/test_memory/heavy_gridview.dart
View file @
37bc7223
...
...
@@ -10,8 +10,8 @@ import 'package:macrobenchmarks/main.dart';
Future
<
void
>
endOfAnimation
()
async
{
do
{
await
SchedulerBinding
.
instance
.
endOfFrame
;
}
while
(
SchedulerBinding
.
instance
.
hasScheduledFrame
);
await
SchedulerBinding
.
instance
!
.
endOfFrame
;
}
while
(
SchedulerBinding
.
instance
!
.
hasScheduledFrame
);
}
Future
<
void
>
main
()
async
{
...
...
dev/benchmarks/macrobenchmarks/test_memory/large_images.dart
View file @
37bc7223
...
...
@@ -10,8 +10,8 @@ import 'package:macrobenchmarks/main.dart';
Future
<
void
>
endOfAnimation
()
async
{
do
{
await
SchedulerBinding
.
instance
.
endOfFrame
;
}
while
(
SchedulerBinding
.
instance
.
hasScheduledFrame
);
await
SchedulerBinding
.
instance
!
.
endOfFrame
;
}
while
(
SchedulerBinding
.
instance
!
.
hasScheduledFrame
);
}
Future
<
void
>
main
()
async
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment