Migrate dev/benchmarks/macrobenchmarks to null safety. (#85501)
This commit is contained in:
parent
d16b27bb3f
commit
37bc722339
@ -31,7 +31,7 @@ const String kMacrobenchmarks = 'Macrobenchmarks';
|
|||||||
void main() => runApp(const MacrobenchmarksApp());
|
void main() => runApp(const MacrobenchmarksApp());
|
||||||
|
|
||||||
class MacrobenchmarksApp extends StatelessWidget {
|
class MacrobenchmarksApp extends StatelessWidget {
|
||||||
const MacrobenchmarksApp({Key key, this.initialRoute = '/'}) : super(key: key);
|
const MacrobenchmarksApp({Key? key, this.initialRoute = '/'}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -68,7 +68,7 @@ class MacrobenchmarksApp extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class HomePage extends StatelessWidget {
|
class HomePage extends StatelessWidget {
|
||||||
const HomePage({Key key}) : super(key: key);
|
const HomePage({Key? key}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
@ -5,9 +5,9 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class AnimatedImagePage extends StatelessWidget {
|
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
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -18,9 +18,9 @@ class AnimatedImagePage extends StatelessWidget {
|
|||||||
body: Image.asset(
|
body: Image.asset(
|
||||||
'animated_images/animated_flutter_lgtm.gif',
|
'animated_images/animated_flutter_lgtm.gif',
|
||||||
package: 'flutter_gallery_assets',
|
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) {
|
if (onFrame != null && frame != null) {
|
||||||
onFrame(frame);
|
onFrame?.call(frame);
|
||||||
}
|
}
|
||||||
return child;
|
return child;
|
||||||
},
|
},
|
||||||
|
@ -24,7 +24,7 @@ const String kBlueSquare = 'iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAASEl'
|
|||||||
/// A 10x10 grid of animated looping placeholder gifts that fade into a
|
/// A 10x10 grid of animated looping placeholder gifts that fade into a
|
||||||
/// blue square.
|
/// blue square.
|
||||||
class AnimatedPlaceholderPage extends StatelessWidget {
|
class AnimatedPlaceholderPage extends StatelessWidget {
|
||||||
const AnimatedPlaceholderPage({Key key}) : super(key: key);
|
const AnimatedPlaceholderPage({Key? key}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class AnimationWithMicrotasks extends StatefulWidget {
|
class AnimationWithMicrotasks extends StatefulWidget {
|
||||||
const AnimationWithMicrotasks({Key key}) : super(key: key);
|
const AnimationWithMicrotasks({Key? key}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<AnimationWithMicrotasks> createState() => _AnimationWithMicrotasksState();
|
State<AnimationWithMicrotasks> createState() => _AnimationWithMicrotasksState();
|
||||||
|
@ -7,7 +7,7 @@ import 'dart:ui';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class BackdropFilterPage extends StatefulWidget {
|
class BackdropFilterPage extends StatefulWidget {
|
||||||
const BackdropFilterPage({Key key}) : super(key: key);
|
const BackdropFilterPage({Key? key}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<BackdropFilterPage> createState() => _BackdropFilterPageState();
|
State<BackdropFilterPage> createState() => _BackdropFilterPageState();
|
||||||
@ -16,7 +16,7 @@ class BackdropFilterPage extends StatefulWidget {
|
|||||||
class _BackdropFilterPageState extends State<BackdropFilterPage> with TickerProviderStateMixin {
|
class _BackdropFilterPageState extends State<BackdropFilterPage> with TickerProviderStateMixin {
|
||||||
bool _blurGroup = false;
|
bool _blurGroup = false;
|
||||||
bool _blurTexts = true;
|
bool _blurTexts = true;
|
||||||
AnimationController animation;
|
late AnimationController animation;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@ -77,7 +77,7 @@ class _BackdropFilterPageState extends State<BackdropFilterPage> with TickerProv
|
|||||||
child: Center(
|
child: Center(
|
||||||
child: AnimatedBuilder(
|
child: AnimatedBuilder(
|
||||||
animation: animation,
|
animation: animation,
|
||||||
builder: (BuildContext c, Widget w) {
|
builder: (BuildContext c, Widget? w) {
|
||||||
final int val = (animation.value * 255).round();
|
final int val = (animation.value * 255).round();
|
||||||
return Container(
|
return Container(
|
||||||
width: 50,
|
width: 50,
|
||||||
@ -99,13 +99,13 @@ class _BackdropFilterPageState extends State<BackdropFilterPage> with TickerProv
|
|||||||
const Text('Backdrop per txt:'),
|
const Text('Backdrop per txt:'),
|
||||||
Checkbox(
|
Checkbox(
|
||||||
value: _blurTexts,
|
value: _blurTexts,
|
||||||
onChanged: (bool v) => setState(() { _blurTexts = v; }),
|
onChanged: (bool? v) => setState(() { _blurTexts = v ?? false; }),
|
||||||
),
|
),
|
||||||
const SizedBox(width: 10),
|
const SizedBox(width: 10),
|
||||||
const Text('Backdrop grid:'),
|
const Text('Backdrop grid:'),
|
||||||
Checkbox(
|
Checkbox(
|
||||||
value: _blurGroup,
|
value: _blurGroup,
|
||||||
onChanged: (bool v) => setState(() { _blurGroup = v; }),
|
onChanged: (bool? v) => setState(() { _blurGroup = v ?? false; }),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
@ -9,7 +9,7 @@ import 'package:flutter/material.dart';
|
|||||||
// This tests whether the Opacity layer raster cache works with color filters.
|
// This tests whether the Opacity layer raster cache works with color filters.
|
||||||
// See https://github.com/flutter/flutter/issues/51975.
|
// See https://github.com/flutter/flutter/issues/51975.
|
||||||
class ColorFilterAndFadePage extends StatefulWidget {
|
class ColorFilterAndFadePage extends StatefulWidget {
|
||||||
const ColorFilterAndFadePage({Key key}) : super(key: key);
|
const ColorFilterAndFadePage({Key? key}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<ColorFilterAndFadePage> createState() => _ColorFilterAndFadePageState();
|
State<ColorFilterAndFadePage> createState() => _ColorFilterAndFadePageState();
|
||||||
@ -79,9 +79,9 @@ class _ColorFilterAndFadePageState extends State<ColorFilterAndFadePage> with Ti
|
|||||||
const Text('Use Color Filter:'),
|
const Text('Use Color Filter:'),
|
||||||
Checkbox(
|
Checkbox(
|
||||||
value: _useColorFilter,
|
value: _useColorFilter,
|
||||||
onChanged: (bool value) {
|
onChanged: (bool? value) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_useColorFilter = value;
|
_useColorFilter = value ?? false;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@ -111,17 +111,23 @@ class _ColorFilterAndFadePageState extends State<ColorFilterAndFadePage> with Ti
|
|||||||
_initAnimation();
|
_initAnimation();
|
||||||
}
|
}
|
||||||
|
|
||||||
AnimationController _controller;
|
@override
|
||||||
Animation<double> _opacityAnimation;
|
void dispose() {
|
||||||
|
_controller.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
late AnimationController _controller;
|
||||||
|
late Animation<double> _opacityAnimation;
|
||||||
bool _useColorFilter = true;
|
bool _useColorFilter = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
class _ShadowWidget extends StatelessWidget {
|
class _ShadowWidget extends StatelessWidget {
|
||||||
const _ShadowWidget({
|
const _ShadowWidget({
|
||||||
@required this.width,
|
required this.width,
|
||||||
@required this.height,
|
required this.height,
|
||||||
@required this.useColorFilter,
|
required this.useColorFilter,
|
||||||
@required this.shadow,
|
required this.shadow,
|
||||||
});
|
});
|
||||||
|
|
||||||
final double width;
|
final double width;
|
||||||
@ -148,7 +154,7 @@ class _ShadowWidget extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _ShadowPainter extends CustomPainter {
|
class _ShadowPainter extends CustomPainter {
|
||||||
const _ShadowPainter({this.useColorFilter, @required this.shadow});
|
const _ShadowPainter({required this.useColorFilter, required this.shadow});
|
||||||
|
|
||||||
final bool useColorFilter;
|
final bool useColorFilter;
|
||||||
final Shadow shadow;
|
final Shadow shadow;
|
||||||
|
@ -8,7 +8,7 @@ import 'package:flutter/material.dart';
|
|||||||
|
|
||||||
// Based on https://github.com/eseidelGoogle/bezier_perf/blob/master/lib/main.dart
|
// Based on https://github.com/eseidelGoogle/bezier_perf/blob/master/lib/main.dart
|
||||||
class CubicBezierPage extends StatelessWidget {
|
class CubicBezierPage extends StatelessWidget {
|
||||||
const CubicBezierPage({Key key}) : super(key: key);
|
const CubicBezierPage({Key? key}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -24,7 +24,7 @@ class CubicBezierPage extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class Bezier 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 Color color;
|
||||||
final double scale;
|
final double scale;
|
||||||
@ -79,7 +79,7 @@ class Bezier extends StatelessWidget {
|
|||||||
BezierPainter(Colors.grey, 0.0, _getLogoPath(), false),
|
BezierPainter(Colors.grey, 0.0, _getLogoPath(), false),
|
||||||
size: const Size(100.0, 100.0),
|
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});
|
PathDetail(this.path, {this.translate, this.rotation});
|
||||||
|
|
||||||
Path path;
|
Path path;
|
||||||
List<double> translate = <double>[];
|
List<double>? translate = <double>[];
|
||||||
double rotation;
|
double? rotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
class AnimatedBezier extends StatefulWidget {
|
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 Color color;
|
||||||
final double scale;
|
final double scale;
|
||||||
final double blur;
|
final double blur;
|
||||||
final double delay;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State createState() => AnimatedBezierState();
|
State createState() => AnimatedBezierState();
|
||||||
@ -113,9 +112,8 @@ class Point {
|
|||||||
|
|
||||||
class AnimatedBezierState extends State<AnimatedBezier>
|
class AnimatedBezierState extends State<AnimatedBezier>
|
||||||
with SingleTickerProviderStateMixin {
|
with SingleTickerProviderStateMixin {
|
||||||
double scale;
|
late AnimationController controller;
|
||||||
AnimationController controller;
|
late CurvedAnimation curve;
|
||||||
CurvedAnimation curve;
|
|
||||||
bool isPlaying = false;
|
bool isPlaying = false;
|
||||||
List<List<Point>> pointList = <List<Point>>[
|
List<List<Point>> pointList = <List<Point>>[
|
||||||
<Point>[],
|
<Point>[],
|
||||||
@ -365,11 +363,11 @@ class BezierPainter extends CustomPainter {
|
|||||||
|
|
||||||
for (int i = 0; i < path.length; i++) {
|
for (int i = 0; i < path.length; i++) {
|
||||||
if (path[i].translate != null) {
|
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) {
|
if (path[i].rotation != null) {
|
||||||
canvas.rotate(path[i].rotation);
|
canvas.rotate(path[i].rotation!);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (blur > 0) {
|
if (blur > 0) {
|
||||||
|
@ -5,15 +5,15 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class CullOpacityPage extends StatefulWidget {
|
class CullOpacityPage extends StatefulWidget {
|
||||||
const CullOpacityPage({Key key}) : super(key: key);
|
const CullOpacityPage({Key? key}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<StatefulWidget> createState() => _CullOpacityPageState();
|
State<StatefulWidget> createState() => _CullOpacityPageState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _CullOpacityPageState extends State<CullOpacityPage> with SingleTickerProviderStateMixin {
|
class _CullOpacityPageState extends State<CullOpacityPage> with SingleTickerProviderStateMixin {
|
||||||
Animation<double> _offsetY;
|
late Animation<double> _offsetY;
|
||||||
AnimationController _controller;
|
late AnimationController _controller;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
|
@ -13,7 +13,7 @@ enum FilterType {
|
|||||||
|
|
||||||
class FilteredChildAnimationPage extends StatefulWidget {
|
class FilteredChildAnimationPage extends StatefulWidget {
|
||||||
const FilteredChildAnimationPage(this.initialFilterType, {
|
const FilteredChildAnimationPage(this.initialFilterType, {
|
||||||
Key key,
|
Key? key,
|
||||||
this.initialComplexChild = true,
|
this.initialComplexChild = true,
|
||||||
this.initialUseRepaintBoundary = true,
|
this.initialUseRepaintBoundary = true,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
@ -27,13 +27,13 @@ class FilteredChildAnimationPage extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _FilteredChildAnimationPageState extends State<FilteredChildAnimationPage> with SingleTickerProviderStateMixin {
|
class _FilteredChildAnimationPageState extends State<FilteredChildAnimationPage> with SingleTickerProviderStateMixin {
|
||||||
AnimationController _controller;
|
late AnimationController _controller;
|
||||||
final GlobalKey _childKey = GlobalKey(debugLabel: 'child to animate');
|
final GlobalKey _childKey = GlobalKey(debugLabel: 'child to animate');
|
||||||
Offset _childCenter = Offset.zero;
|
Offset _childCenter = Offset.zero;
|
||||||
|
|
||||||
FilterType _filterType;
|
FilterType? _filterType;
|
||||||
bool _complexChild;
|
late bool _complexChild;
|
||||||
bool _useRepaintBoundary;
|
late bool _useRepaintBoundary;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@ -41,8 +41,8 @@ class _FilteredChildAnimationPageState extends State<FilteredChildAnimationPage>
|
|||||||
_filterType = widget.initialFilterType;
|
_filterType = widget.initialFilterType;
|
||||||
_complexChild = widget.initialComplexChild;
|
_complexChild = widget.initialComplexChild;
|
||||||
_useRepaintBoundary = widget.initialUseRepaintBoundary;
|
_useRepaintBoundary = widget.initialUseRepaintBoundary;
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance!.addPostFrameCallback((_) {
|
||||||
final RenderBox childBox = _childKey.currentContext.findRenderObject() as RenderBox;
|
final RenderBox childBox = _childKey.currentContext!.findRenderObject()! as RenderBox;
|
||||||
_childCenter = childBox.paintBounds.center;
|
_childCenter = childBox.paintBounds.center;
|
||||||
});
|
});
|
||||||
_controller = AnimationController(vsync: this, duration: const Duration(seconds: 2));
|
_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) {
|
if (_filterType == null) {
|
||||||
_controller.reset();
|
_controller.reset();
|
||||||
return child;
|
return child;
|
||||||
}
|
}
|
||||||
|
final FilterType filterType = _filterType!;
|
||||||
_controller.repeat();
|
_controller.repeat();
|
||||||
Widget Function(BuildContext, Widget) builder;
|
Widget Function(BuildContext, Widget?) builder;
|
||||||
switch (_filterType) {
|
switch (filterType) {
|
||||||
case FilterType.opacity:
|
case FilterType.opacity:
|
||||||
builder = (BuildContext context, Widget child) => Opacity(
|
builder = (BuildContext context, Widget? child) => Opacity(
|
||||||
opacity: (_controller.value * 2.0 - 1.0).abs(),
|
opacity: (_controller.value * 2.0 - 1.0).abs(),
|
||||||
child: child,
|
child: child,
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case FilterType.rotateTransform:
|
case FilterType.rotateTransform:
|
||||||
builder = (BuildContext context, Widget child) => Transform(
|
builder = (BuildContext context, Widget? child) => Transform(
|
||||||
transform: Matrix4.rotationZ(_controller.value * 2.0 * pi),
|
transform: Matrix4.rotationZ(_controller.value * 2.0 * pi),
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
filterQuality: FilterQuality.low,
|
filterQuality: FilterQuality.low,
|
||||||
@ -125,7 +126,7 @@ class _FilteredChildAnimationPageState extends State<FilteredChildAnimationPage>
|
|||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case FilterType.rotateFilter:
|
case FilterType.rotateFilter:
|
||||||
builder = (BuildContext context, Widget child) => ImageFiltered(
|
builder = (BuildContext context, Widget? child) => ImageFiltered(
|
||||||
imageFilter: ImageFilter.matrix((
|
imageFilter: ImageFilter.matrix((
|
||||||
Matrix4.identity()
|
Matrix4.identity()
|
||||||
..translate(_childCenter.dx, _childCenter.dy)
|
..translate(_childCenter.dx, _childCenter.dy)
|
||||||
@ -176,17 +177,17 @@ class _FilteredChildAnimationPageState extends State<FilteredChildAnimationPage>
|
|||||||
const Text('Opacity:'),
|
const Text('Opacity:'),
|
||||||
Checkbox(
|
Checkbox(
|
||||||
value: _filterType == FilterType.opacity,
|
value: _filterType == FilterType.opacity,
|
||||||
onChanged: (bool b) => _setFilterType(FilterType.opacity, b),
|
onChanged: (bool? b) => _setFilterType(FilterType.opacity, b ?? false),
|
||||||
),
|
),
|
||||||
const Text('Tx Rotate:'),
|
const Text('Tx Rotate:'),
|
||||||
Checkbox(
|
Checkbox(
|
||||||
value: _filterType == FilterType.rotateTransform,
|
value: _filterType == FilterType.rotateTransform,
|
||||||
onChanged: (bool b) => _setFilterType(FilterType.rotateTransform, b),
|
onChanged: (bool? b) => _setFilterType(FilterType.rotateTransform, b ?? false),
|
||||||
),
|
),
|
||||||
const Text('IF Rotate:'),
|
const Text('IF Rotate:'),
|
||||||
Checkbox(
|
Checkbox(
|
||||||
value: _filterType == FilterType.rotateFilter,
|
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:'),
|
const Text('Complex child:'),
|
||||||
Checkbox(
|
Checkbox(
|
||||||
value: _complexChild,
|
value: _complexChild,
|
||||||
onChanged: (bool b) => setState(() => _complexChild = b),
|
onChanged: (bool? b) => setState(() => _complexChild = b ?? false),
|
||||||
),
|
),
|
||||||
const Text('RPB on child:'),
|
const Text('RPB on child:'),
|
||||||
Checkbox(
|
Checkbox(
|
||||||
value: _useRepaintBoundary,
|
value: _useRepaintBoundary,
|
||||||
onChanged: (bool b) => setState(() => _useRepaintBoundary = b),
|
onChanged: (bool? b) => setState(() => _useRepaintBoundary = b ?? false),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
@ -48,7 +48,7 @@ const String textLotsOfText = 'Lorem ipsum dolor sit amet, consectetur '
|
|||||||
'🦻 👃 🫀 🫁 🧠 🦷 🦴 👀 👁 👅 👄 💋 🩸';
|
'🦻 👃 🫀 🫁 🧠 🦷 🦴 👀 👁 👅 👄 💋 🩸';
|
||||||
|
|
||||||
class TextFieldPage extends StatelessWidget {
|
class TextFieldPage extends StatelessWidget {
|
||||||
const TextFieldPage({Key key}) : super(key: key);
|
const TextFieldPage({Key? key}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class HeavyGridViewPage extends StatelessWidget {
|
class HeavyGridViewPage extends StatelessWidget {
|
||||||
const HeavyGridViewPage({Key key}) : super(key: key);
|
const HeavyGridViewPage({Key? key}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -21,7 +21,7 @@ class HeavyWidget extends StatelessWidget {
|
|||||||
HeavyWidget(this.index) : super(key: ValueKey<int>(index));
|
HeavyWidget(this.index) : super(key: ValueKey<int>(index));
|
||||||
|
|
||||||
final int index;
|
final int index;
|
||||||
final List<int> _weight = List<int>.filled(1000000, null);
|
final List<int> _weight = List<int>.filled(1000000, 0);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
@ -8,16 +8,16 @@ import 'package:flutter/material.dart';
|
|||||||
|
|
||||||
/// Displays a new (from image cache's perspective) large image every 500ms.
|
/// Displays a new (from image cache's perspective) large image every 500ms.
|
||||||
class LargeImageChangerPage extends StatefulWidget {
|
class LargeImageChangerPage extends StatefulWidget {
|
||||||
const LargeImageChangerPage({Key key}) : super(key: key);
|
const LargeImageChangerPage({Key? key}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<LargeImageChangerPage> createState() => _LargeImageChangerState();
|
State<LargeImageChangerPage> createState() => _LargeImageChangerState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _LargeImageChangerState extends State<LargeImageChangerPage> {
|
class _LargeImageChangerState extends State<LargeImageChangerPage> {
|
||||||
Timer _timer;
|
Timer? _timer;
|
||||||
int imageIndex = 0;
|
int imageIndex = 0;
|
||||||
ImageProvider currentImage;
|
late ImageProvider currentImage;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void didChangeDependencies() {
|
void didChangeDependencies() {
|
||||||
|
@ -7,11 +7,11 @@ import 'dart:typed_data';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class LargeImagesPage extends StatelessWidget {
|
class LargeImagesPage extends StatelessWidget {
|
||||||
const LargeImagesPage({Key key}) : super(key: key);
|
const LargeImagesPage({Key? key}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final ImageCache imageCache = PaintingBinding.instance.imageCache;
|
final ImageCache imageCache = PaintingBinding.instance!.imageCache!;
|
||||||
imageCache.maximumSize = 30;
|
imageCache.maximumSize = 30;
|
||||||
imageCache.maximumSizeBytes = 50 << 20;
|
imageCache.maximumSizeBytes = 50 << 20;
|
||||||
return GridView.builder(
|
return GridView.builder(
|
||||||
@ -36,7 +36,7 @@ class DummyImage extends StatelessWidget {
|
|||||||
// creating many copies of the image to trigger the memory issue.
|
// creating many copies of the image to trigger the memory issue.
|
||||||
return snapshot.data == null
|
return snapshot.data == null
|
||||||
? Container()
|
? Container()
|
||||||
: Image.memory(snapshot.data.buffer.asUint8List());
|
: Image.memory(snapshot.data!.buffer.asUint8List());
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class MultiWidgetConstructTable extends StatefulWidget {
|
class MultiWidgetConstructTable extends StatefulWidget {
|
||||||
const MultiWidgetConstructTable(this.columnCount, this.rowCount, {Key key})
|
const MultiWidgetConstructTable(this.columnCount, this.rowCount, {Key? key})
|
||||||
: super(key: key);
|
: super(key: key);
|
||||||
|
|
||||||
final int columnCount;
|
final int columnCount;
|
||||||
@ -24,7 +24,7 @@ class _MultiWidgetConstructTableState extends State<MultiWidgetConstructTable>
|
|||||||
];
|
];
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
|
|
||||||
AnimationController _controller;
|
late AnimationController _controller;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@ -53,9 +53,9 @@ class _MultiWidgetConstructTableState extends State<MultiWidgetConstructTable>
|
|||||||
final double height = MediaQuery.of(context).size.height / widget.rowCount;
|
final double height = MediaQuery.of(context).size.height / widget.rowCount;
|
||||||
final double colorPosition = _controller.value;
|
final double colorPosition = _controller.value;
|
||||||
final int c1Position = colorPosition.floor();
|
final int c1Position = colorPosition.floor();
|
||||||
final Color c1 = colorList[c1Position % colorList.length][900];
|
final Color c1 = colorList[c1Position % colorList.length][900]!;
|
||||||
final Color c2 = colorList[(c1Position + 1) % colorList.length][900];
|
final Color c2 = colorList[(c1Position + 1) % colorList.length][900]!;
|
||||||
final Color baseColor = Color.lerp(c1, c2, colorPosition - c1Position);
|
final Color baseColor = Color.lerp(c1, c2, colorPosition - c1Position)!;
|
||||||
counter++;
|
counter++;
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
body: Table(
|
body: Table(
|
||||||
@ -82,7 +82,7 @@ class _MultiWidgetConstructTableState extends State<MultiWidgetConstructTable>
|
|||||||
// This key forces rebuilding the element
|
// This key forces rebuilding the element
|
||||||
key: ValueKey<int>(widgetCounter + label),
|
key: ValueKey<int>(widgetCounter + label),
|
||||||
color: Color.lerp(
|
color: Color.lerp(
|
||||||
Colors.white, baseColor, label / totalLength),
|
Colors.white, baseColor, label / totalLength)!,
|
||||||
constraints: BoxConstraints.expand(height: height),
|
constraints: BoxConstraints.expand(height: height),
|
||||||
child: Text('${widgetCounter + label}'),
|
child: Text('${widgetCounter + label}'),
|
||||||
);
|
);
|
||||||
@ -99,7 +99,7 @@ class _MultiWidgetConstructTableState extends State<MultiWidgetConstructTable>
|
|||||||
|
|
||||||
// This class is intended to break the original Widget tree
|
// This class is intended to break the original Widget tree
|
||||||
class MyContainer extends StatelessWidget {
|
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);
|
: super(key: key);
|
||||||
final Color color;
|
final Color color;
|
||||||
final Widget child;
|
final Widget child;
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class PictureCachePage extends StatelessWidget {
|
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'];
|
static const List<String> kTabNames = <String>['1', '2', '3', '4', '5'];
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ class PictureCachePage extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class ListItem extends StatelessWidget {
|
class ListItem extends StatelessWidget {
|
||||||
const ListItem({Key key, this.index})
|
const ListItem({Key? key, required this.index})
|
||||||
: super(key: key);
|
: super(key: key);
|
||||||
|
|
||||||
final int index;
|
final int index;
|
||||||
|
@ -7,7 +7,7 @@ import 'dart:ui';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class PostBackdropFilterPage extends StatefulWidget {
|
class PostBackdropFilterPage extends StatefulWidget {
|
||||||
const PostBackdropFilterPage({Key key}) : super(key: key);
|
const PostBackdropFilterPage({Key? key}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<PostBackdropFilterPage> createState() => _PostBackdropFilterPageState();
|
State<PostBackdropFilterPage> createState() => _PostBackdropFilterPageState();
|
||||||
@ -15,7 +15,7 @@ class PostBackdropFilterPage extends StatefulWidget {
|
|||||||
|
|
||||||
class _PostBackdropFilterPageState extends State<PostBackdropFilterPage> with TickerProviderStateMixin {
|
class _PostBackdropFilterPageState extends State<PostBackdropFilterPage> with TickerProviderStateMixin {
|
||||||
bool _includeBackdropFilter = false;
|
bool _includeBackdropFilter = false;
|
||||||
AnimationController animation;
|
late AnimationController animation;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@ -63,7 +63,7 @@ class _PostBackdropFilterPageState extends State<PostBackdropFilterPage> with Ti
|
|||||||
child: Center(
|
child: Center(
|
||||||
child: AnimatedBuilder(
|
child: AnimatedBuilder(
|
||||||
animation: animation,
|
animation: animation,
|
||||||
builder: (BuildContext c, Widget w) {
|
builder: (BuildContext c, Widget? w) {
|
||||||
final int val = (animation.value * 255).round();
|
final int val = (animation.value * 255).round();
|
||||||
return Container(
|
return Container(
|
||||||
width: 50,
|
width: 50,
|
||||||
@ -83,7 +83,7 @@ class _PostBackdropFilterPageState extends State<PostBackdropFilterPage> with Ti
|
|||||||
Checkbox(
|
Checkbox(
|
||||||
key: const Key('bdf-checkbox'), // this key is used by the driver test
|
key: const Key('bdf-checkbox'), // this key is used by the driver test
|
||||||
value: _includeBackdropFilter,
|
value: _includeBackdropFilter,
|
||||||
onChanged: (bool v) => setState(() { _includeBackdropFilter = v; }),
|
onChanged: (bool? v) => setState(() { _includeBackdropFilter = v ?? false; }),
|
||||||
),
|
),
|
||||||
MaterialButton(
|
MaterialButton(
|
||||||
key: const Key('bdf-animate'), // this key is used by the driver test
|
key: const Key('bdf-animate'), // this key is used by the driver test
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class SimpleAnimationPage extends StatelessWidget {
|
class SimpleAnimationPage extends StatelessWidget {
|
||||||
const SimpleAnimationPage({Key key}) : super(key: key);
|
const SimpleAnimationPage({Key? key}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class SimpleScroll extends StatelessWidget {
|
class SimpleScroll extends StatelessWidget {
|
||||||
const SimpleScroll({Key key}) : super(key: key);
|
const SimpleScroll({Key? key}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
@ -81,7 +81,7 @@ final GetStackPointerCallback getStackPointer = () {
|
|||||||
}();
|
}();
|
||||||
|
|
||||||
class StackSizePage extends StatelessWidget {
|
class StackSizePage extends StatelessWidget {
|
||||||
const StackSizePage({Key key}) : super(key: key);
|
const StackSizePage({Key? key}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -100,7 +100,7 @@ class StackSizePage extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class ParentWidget extends StatelessWidget {
|
class ParentWidget extends StatelessWidget {
|
||||||
const ParentWidget({Key key}) : super(key: key);
|
const ParentWidget({Key? key}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -110,7 +110,7 @@ class ParentWidget extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class ChildWidget 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;
|
final int parentStackSize;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class TextPage extends StatelessWidget {
|
class TextPage extends StatelessWidget {
|
||||||
const TextPage({Key key}) : super(key: key);
|
const TextPage({Key? key}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
@ -52,7 +52,7 @@ class BenchBuildImage extends WidgetRecorder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _RotatingWidget extends StatefulWidget {
|
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;
|
final Widget child;
|
||||||
|
|
||||||
@ -61,7 +61,7 @@ class _RotatingWidget extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _RotatingWidgetState extends State<_RotatingWidget> with SingleTickerProviderStateMixin {
|
class _RotatingWidgetState extends State<_RotatingWidget> with SingleTickerProviderStateMixin {
|
||||||
AnimationController controller;
|
late AnimationController controller;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@ -72,11 +72,17 @@ class _RotatingWidgetState extends State<_RotatingWidget> with SingleTickerProvi
|
|||||||
)..repeat();
|
)..repeat();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
controller.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return AnimatedBuilder(
|
return AnimatedBuilder(
|
||||||
animation: controller,
|
animation: controller,
|
||||||
builder: (BuildContext context, Widget child) {
|
builder: (BuildContext context, Widget? child) {
|
||||||
return Transform(
|
return Transform(
|
||||||
transform: Matrix4.identity()..rotateZ(2 * math.pi * controller.value),
|
transform: Matrix4.identity()..rotateZ(2 * math.pi * controller.value),
|
||||||
child: widget.child,
|
child: widget.child,
|
||||||
@ -84,5 +90,4 @@ class _RotatingWidgetState extends State<_RotatingWidget> with SingleTickerProvi
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ class BenchBuildMaterialCheckbox extends WidgetBuildRecorder {
|
|||||||
|
|
||||||
static const String benchmarkName = 'build_material_checkbox';
|
static const String benchmarkName = 'build_material_checkbox';
|
||||||
|
|
||||||
static bool _isChecked;
|
static bool? _isChecked;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget createWidget() {
|
Widget createWidget() {
|
||||||
@ -33,7 +33,7 @@ class BenchBuildMaterialCheckbox extends WidgetBuildRecorder {
|
|||||||
Row _buildRow() {
|
Row _buildRow() {
|
||||||
if (_isChecked == null) {
|
if (_isChecked == null) {
|
||||||
_isChecked = true;
|
_isChecked = true;
|
||||||
} else if (_isChecked) {
|
} else if (_isChecked!) {
|
||||||
_isChecked = false;
|
_isChecked = false;
|
||||||
} else {
|
} else {
|
||||||
_isChecked = null;
|
_isChecked = null;
|
||||||
@ -45,7 +45,7 @@ class BenchBuildMaterialCheckbox extends WidgetBuildRecorder {
|
|||||||
child: Checkbox(
|
child: Checkbox(
|
||||||
value: _isChecked,
|
value: _isChecked,
|
||||||
tristate: true,
|
tristate: true,
|
||||||
onChanged: (bool newValue) {
|
onChanged: (bool? newValue) {
|
||||||
// Intentionally empty.
|
// Intentionally empty.
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
@ -35,7 +35,7 @@ class BenchCardInfiniteScroll extends WidgetRecorder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _InfiniteScrollCards extends StatefulWidget {
|
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 initialOffset;
|
||||||
final double finalOffset;
|
final double finalOffset;
|
||||||
@ -47,8 +47,8 @@ class _InfiniteScrollCards extends StatefulWidget {
|
|||||||
class _InfiniteScrollCardsState extends State<_InfiniteScrollCards> {
|
class _InfiniteScrollCardsState extends State<_InfiniteScrollCards> {
|
||||||
static const Duration stepDuration = Duration(seconds: 20);
|
static const Duration stepDuration = Duration(seconds: 20);
|
||||||
|
|
||||||
ScrollController scrollController;
|
late ScrollController scrollController;
|
||||||
double offset;
|
late double offset;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@ -70,6 +70,12 @@ class _InfiniteScrollCardsState extends State<_InfiniteScrollCards> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
scrollController.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return ListView.builder(
|
return ListView.builder(
|
||||||
|
@ -31,10 +31,10 @@ class BenchUpdateManyChildLayers extends SceneBuilderRecorder {
|
|||||||
/// is correctly pumping frames.
|
/// is correctly pumping frames.
|
||||||
double wobbleCounter = 0;
|
double wobbleCounter = 0;
|
||||||
|
|
||||||
List<Picture> _pictures;
|
late List<Picture> _pictures;
|
||||||
Size windowSize;
|
late Size windowSize;
|
||||||
Size cellSize;
|
late Size cellSize;
|
||||||
Size rectSize;
|
late Size rectSize;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> setUpAll() async {
|
Future<void> setUpAll() async {
|
||||||
@ -55,7 +55,7 @@ class BenchUpdateManyChildLayers extends SceneBuilderRecorder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
OffsetEngineLayer _rootLayer;
|
OffsetEngineLayer? _rootLayer;
|
||||||
final Map<int, OffsetEngineLayer> _layers = <int, OffsetEngineLayer>{};
|
final Map<int, OffsetEngineLayer> _layers = <int, OffsetEngineLayer>{};
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -64,7 +64,7 @@ class BenchUpdateManyChildLayers extends SceneBuilderRecorder {
|
|||||||
for (int row = 0; row < kRows; row++) {
|
for (int row = 0; row < kRows; row++) {
|
||||||
for (int col = 0; col < kColumns; col++) {
|
for (int col = 0; col < kColumns; col++) {
|
||||||
final int layerId = 1000000 * row + 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 wobbleOffsetX = col * cellSize.width + (wobbleCounter - 5).abs();
|
||||||
final double offsetY = row * cellSize.height;
|
final double offsetY = row * cellSize.height;
|
||||||
// Retain every other layer, so we exercise the update path 50% of the
|
// Retain every other layer, so we exercise the update path 50% of the
|
||||||
|
@ -93,9 +93,9 @@ class BenchDynamicClipOnStaticPicture extends SceneBuilderRecorder {
|
|||||||
|
|
||||||
static const String benchmarkName = 'dynamic_clip_on_static_picture';
|
static const String benchmarkName = 'dynamic_clip_on_static_picture';
|
||||||
|
|
||||||
Size screenSize;
|
late Size screenSize;
|
||||||
Size clipSize;
|
late Size clipSize;
|
||||||
Picture picture;
|
late Picture picture;
|
||||||
double pictureVerticalOffset = 0.0;
|
double pictureVerticalOffset = 0.0;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -14,7 +14,7 @@ import 'package:flutter_test/flutter_test.dart';
|
|||||||
import 'recorder.dart';
|
import 'recorder.dart';
|
||||||
|
|
||||||
class _NestedMouseRegion extends StatelessWidget {
|
class _NestedMouseRegion extends StatelessWidget {
|
||||||
const _NestedMouseRegion({this.nests, this.child});
|
const _NestedMouseRegion({required this.nests, required this.child});
|
||||||
|
|
||||||
final int nests;
|
final int nests;
|
||||||
final Widget child;
|
final Widget child;
|
||||||
@ -42,10 +42,10 @@ class BenchMouseRegionGridHover extends WidgetRecorder {
|
|||||||
|
|
||||||
static const String benchmarkName = 'bench_mouse_region_grid_hover';
|
static const String benchmarkName = 'bench_mouse_region_grid_hover';
|
||||||
|
|
||||||
_Tester _tester;
|
late _Tester _tester;
|
||||||
|
|
||||||
void handleDataPoint(Duration duration) {
|
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
|
// Use a non-trivial border to force Web to switch painter
|
||||||
@ -66,7 +66,7 @@ class BenchMouseRegionGridHover extends WidgetRecorder {
|
|||||||
void frameDidDraw() {
|
void frameDidDraw() {
|
||||||
if (!started) {
|
if (!started) {
|
||||||
started = true;
|
started = true;
|
||||||
SchedulerBinding.instance.addPostFrameCallback((Duration timeStamp) async {
|
SchedulerBinding.instance!.addPostFrameCallback((Duration timeStamp) async {
|
||||||
_tester.start();
|
_tester.start();
|
||||||
registerDidStop(_tester.stop);
|
registerDidStop(_tester.stop);
|
||||||
});
|
});
|
||||||
@ -119,22 +119,22 @@ class BenchMouseRegionGridHover extends WidgetRecorder {
|
|||||||
class _UntilNextFrame {
|
class _UntilNextFrame {
|
||||||
_UntilNextFrame._();
|
_UntilNextFrame._();
|
||||||
|
|
||||||
static Completer<void> _completer;
|
static Completer<void>? _completer;
|
||||||
|
|
||||||
static Future<void> wait() {
|
static Future<void> wait() {
|
||||||
if (_UntilNextFrame._completer == null) {
|
if (_UntilNextFrame._completer == null) {
|
||||||
_UntilNextFrame._completer = Completer<void>();
|
_UntilNextFrame._completer = Completer<void>();
|
||||||
SchedulerBinding.instance.addPostFrameCallback((_) {
|
SchedulerBinding.instance!.addPostFrameCallback((_) {
|
||||||
_UntilNextFrame._completer.complete(null);
|
_UntilNextFrame._completer!.complete(null);
|
||||||
_UntilNextFrame._completer = null;
|
_UntilNextFrame._completer = null;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return _UntilNextFrame._completer.future;
|
return _UntilNextFrame._completer!.future;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class _Tester {
|
class _Tester {
|
||||||
_Tester({this.onDataPoint});
|
_Tester({required this.onDataPoint});
|
||||||
|
|
||||||
final ValueSetter<Duration> onDataPoint;
|
final ValueSetter<Duration> onDataPoint;
|
||||||
|
|
||||||
@ -145,12 +145,12 @@ class _Tester {
|
|||||||
TestGesture get gesture {
|
TestGesture get gesture {
|
||||||
return _gesture ??= TestGesture(
|
return _gesture ??= TestGesture(
|
||||||
dispatcher: (PointerEvent event) async {
|
dispatcher: (PointerEvent event) async {
|
||||||
RendererBinding.instance.handlePointerEvent(event);
|
RendererBinding.instance!.handlePointerEvent(event);
|
||||||
},
|
},
|
||||||
kind: PointerDeviceKind.mouse,
|
kind: PointerDeviceKind.mouse,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
TestGesture _gesture;
|
TestGesture? _gesture;
|
||||||
|
|
||||||
Duration currentTime = Duration.zero;
|
Duration currentTime = Duration.zero;
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ class BenchMouseRegionGridScroll extends WidgetRecorder {
|
|||||||
void frameDidDraw() {
|
void frameDidDraw() {
|
||||||
if (!started) {
|
if (!started) {
|
||||||
started = true;
|
started = true;
|
||||||
SchedulerBinding.instance.addPostFrameCallback((Duration timeStamp) async {
|
SchedulerBinding.instance!.addPostFrameCallback((Duration timeStamp) async {
|
||||||
_tester.start();
|
_tester.start();
|
||||||
registerDidStop(_tester.stop);
|
registerDidStop(_tester.stop);
|
||||||
});
|
});
|
||||||
@ -91,17 +91,17 @@ class BenchMouseRegionGridScroll extends WidgetRecorder {
|
|||||||
class _UntilNextFrame {
|
class _UntilNextFrame {
|
||||||
_UntilNextFrame._();
|
_UntilNextFrame._();
|
||||||
|
|
||||||
static Completer<void> _completer;
|
static Completer<void>? _completer;
|
||||||
|
|
||||||
static Future<void> wait() {
|
static Future<void> wait() {
|
||||||
if (_UntilNextFrame._completer == null) {
|
if (_UntilNextFrame._completer == null) {
|
||||||
_UntilNextFrame._completer = Completer<void>();
|
_UntilNextFrame._completer = Completer<void>();
|
||||||
SchedulerBinding.instance.addPostFrameCallback((_) {
|
SchedulerBinding.instance!.addPostFrameCallback((_) {
|
||||||
_UntilNextFrame._completer.complete(null);
|
_UntilNextFrame._completer!.complete(null);
|
||||||
_UntilNextFrame._completer = null;
|
_UntilNextFrame._completer = null;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return _UntilNextFrame._completer.future;
|
return _UntilNextFrame._completer!.future;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,12 +117,12 @@ class _Tester {
|
|||||||
TestGesture get gesture {
|
TestGesture get gesture {
|
||||||
return _gesture ??= TestGesture(
|
return _gesture ??= TestGesture(
|
||||||
dispatcher: (PointerEvent event) async {
|
dispatcher: (PointerEvent event) async {
|
||||||
RendererBinding.instance.handlePointerEvent(event);
|
RendererBinding.instance!.handlePointerEvent(event);
|
||||||
},
|
},
|
||||||
kind: PointerDeviceKind.mouse,
|
kind: PointerDeviceKind.mouse,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
TestGesture _gesture;
|
TestGesture? _gesture;
|
||||||
|
|
||||||
Duration currentTime = Duration.zero;
|
Duration currentTime = Duration.zero;
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ import 'package:flutter_test/flutter_test.dart';
|
|||||||
import 'recorder.dart';
|
import 'recorder.dart';
|
||||||
|
|
||||||
class _NestedMouseRegion extends StatelessWidget {
|
class _NestedMouseRegion extends StatelessWidget {
|
||||||
const _NestedMouseRegion({this.nests, this.child});
|
const _NestedMouseRegion({required this.nests, required this.child});
|
||||||
|
|
||||||
final int nests;
|
final int nests;
|
||||||
final Widget child;
|
final Widget child;
|
||||||
@ -33,7 +33,7 @@ class _NestedMouseRegion extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _NestedListener extends StatelessWidget {
|
class _NestedListener extends StatelessWidget {
|
||||||
const _NestedListener({this.nests, this.child});
|
const _NestedListener({required this.nests, required this.child});
|
||||||
|
|
||||||
final int nests;
|
final int nests;
|
||||||
final Widget child;
|
final Widget child;
|
||||||
@ -61,10 +61,10 @@ class BenchMouseRegionMixedGridHover extends WidgetRecorder {
|
|||||||
|
|
||||||
static const String benchmarkName = 'bench_mouse_region_mixed_grid_hover';
|
static const String benchmarkName = 'bench_mouse_region_mixed_grid_hover';
|
||||||
|
|
||||||
_Tester _tester;
|
late _Tester _tester;
|
||||||
|
|
||||||
void handleDataPoint(Duration duration) {
|
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
|
// Use a non-trivial border to force Web to switch painter
|
||||||
@ -85,7 +85,7 @@ class BenchMouseRegionMixedGridHover extends WidgetRecorder {
|
|||||||
void frameDidDraw() {
|
void frameDidDraw() {
|
||||||
if (!started) {
|
if (!started) {
|
||||||
started = true;
|
started = true;
|
||||||
SchedulerBinding.instance.addPostFrameCallback((Duration timeStamp) async {
|
SchedulerBinding.instance!.addPostFrameCallback((Duration timeStamp) async {
|
||||||
_tester.start();
|
_tester.start();
|
||||||
registerDidStop(_tester.stop);
|
registerDidStop(_tester.stop);
|
||||||
});
|
});
|
||||||
@ -141,22 +141,22 @@ class BenchMouseRegionMixedGridHover extends WidgetRecorder {
|
|||||||
class _UntilNextFrame {
|
class _UntilNextFrame {
|
||||||
_UntilNextFrame._();
|
_UntilNextFrame._();
|
||||||
|
|
||||||
static Completer<void> _completer;
|
static Completer<void>? _completer;
|
||||||
|
|
||||||
static Future<void> wait() {
|
static Future<void> wait() {
|
||||||
if (_UntilNextFrame._completer == null) {
|
if (_UntilNextFrame._completer == null) {
|
||||||
_UntilNextFrame._completer = Completer<void>();
|
_UntilNextFrame._completer = Completer<void>();
|
||||||
SchedulerBinding.instance.addPostFrameCallback((_) {
|
SchedulerBinding.instance!.addPostFrameCallback((_) {
|
||||||
_UntilNextFrame._completer.complete(null);
|
_UntilNextFrame._completer!.complete(null);
|
||||||
_UntilNextFrame._completer = null;
|
_UntilNextFrame._completer = null;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return _UntilNextFrame._completer.future;
|
return _UntilNextFrame._completer!.future;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class _Tester {
|
class _Tester {
|
||||||
_Tester({this.onDataPoint});
|
_Tester({required this.onDataPoint});
|
||||||
|
|
||||||
final ValueSetter<Duration> onDataPoint;
|
final ValueSetter<Duration> onDataPoint;
|
||||||
|
|
||||||
@ -167,12 +167,12 @@ class _Tester {
|
|||||||
TestGesture get gesture {
|
TestGesture get gesture {
|
||||||
return _gesture ??= TestGesture(
|
return _gesture ??= TestGesture(
|
||||||
dispatcher: (PointerEvent event) async {
|
dispatcher: (PointerEvent event) async {
|
||||||
RendererBinding.instance.handlePointerEvent(event);
|
RendererBinding.instance!.handlePointerEvent(event);
|
||||||
},
|
},
|
||||||
kind: PointerDeviceKind.mouse,
|
kind: PointerDeviceKind.mouse,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
TestGesture _gesture;
|
TestGesture? _gesture;
|
||||||
|
|
||||||
Duration currentTime = Duration.zero;
|
Duration currentTime = Duration.zero;
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ class BenchPageViewScrollLineThrough extends WidgetRecorder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _MyScrollContainer extends StatefulWidget {
|
class _MyScrollContainer extends StatefulWidget {
|
||||||
const _MyScrollContainer({Key key}) : super(key: key);
|
const _MyScrollContainer({Key? key}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<_MyScrollContainer> createState() => _MyScrollContainerState();
|
State<_MyScrollContainer> createState() => _MyScrollContainerState();
|
||||||
@ -35,7 +35,7 @@ class _MyScrollContainer extends StatefulWidget {
|
|||||||
class _MyScrollContainerState extends State<_MyScrollContainer> {
|
class _MyScrollContainerState extends State<_MyScrollContainer> {
|
||||||
static const Duration stepDuration = Duration(milliseconds: 500);
|
static const Duration stepDuration = Duration(milliseconds: 500);
|
||||||
|
|
||||||
PageController pageController;
|
late PageController pageController;
|
||||||
int pageNumber = 0;
|
int pageNumber = 0;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -56,8 +56,8 @@ class _MyScrollContainerState extends State<_MyScrollContainer> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
super.dispose();
|
|
||||||
pageController.dispose();
|
pageController.dispose();
|
||||||
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -77,8 +77,8 @@ class _CustomPainter extends CustomPainter {
|
|||||||
_CustomPainter(this.text);
|
_CustomPainter(this.text);
|
||||||
|
|
||||||
final String text;
|
final String text;
|
||||||
Paint _linePainter;
|
final Paint _linePainter = Paint();
|
||||||
TextPainter _textPainter;
|
final TextPainter _textPainter = TextPainter();
|
||||||
static const double lineWidth = 0.5;
|
static const double lineWidth = 0.5;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -91,14 +91,12 @@ class _CustomPainter extends CustomPainter {
|
|||||||
const double viewPadding = 5;
|
const double viewPadding = 5;
|
||||||
const double circlePadding = 4;
|
const double circlePadding = 4;
|
||||||
yPosition = viewPadding;
|
yPosition = viewPadding;
|
||||||
_textPainter = _textPainter ?? TextPainter();
|
|
||||||
_textPainter.textDirection = TextDirection.ltr;
|
_textPainter.textDirection = TextDirection.ltr;
|
||||||
_textPainter.textWidthBasis = TextWidthBasis.longestLine;
|
_textPainter.textWidthBasis = TextWidthBasis.longestLine;
|
||||||
_textPainter.textScaleFactor = 1;
|
_textPainter.textScaleFactor = 1;
|
||||||
const TextStyle textStyle =
|
const TextStyle textStyle =
|
||||||
TextStyle(color: Colors.black87, fontSize: 13, fontFamily: 'Roboto');
|
TextStyle(color: Colors.black87, fontSize: 13, fontFamily: 'Roboto');
|
||||||
|
|
||||||
_linePainter = _linePainter ?? Paint();
|
|
||||||
_linePainter.isAntiAlias = true;
|
_linePainter.isAntiAlias = true;
|
||||||
for (int i = 0; i < 42; i++) {
|
for (int i = 0; i < 42; i++) {
|
||||||
_linePainter.color = Colors.white;
|
_linePainter.color = Colors.white;
|
||||||
|
@ -7,218 +7,218 @@ import 'dart:ui';
|
|||||||
// The code below was generated by modify several parts of the engine
|
// The code below was generated by modify several parts of the engine
|
||||||
// May 2020 and running Flutter Gallery.
|
// May 2020 and running Flutter Gallery.
|
||||||
|
|
||||||
PathFillType gFillType;
|
late PathFillType gFillType;
|
||||||
Rect gBounds;
|
late Rect gBounds;
|
||||||
List<dynamic> allPaths;
|
late List<dynamic> allPaths;
|
||||||
|
|
||||||
Path path8;
|
late Path path8;
|
||||||
Path path10;
|
late Path path10;
|
||||||
Path path12;
|
late Path path12;
|
||||||
Path path14;
|
late Path path14;
|
||||||
Path path16;
|
late Path path16;
|
||||||
Path path18;
|
late Path path18;
|
||||||
Path path34;
|
late Path path34;
|
||||||
Path path50;
|
late Path path50;
|
||||||
Path path60;
|
late Path path60;
|
||||||
Path path63;
|
late Path path63;
|
||||||
Path path66;
|
late Path path66;
|
||||||
Path path69;
|
late Path path69;
|
||||||
Path path72;
|
late Path path72;
|
||||||
Path path75;
|
late Path path75;
|
||||||
Path path78;
|
late Path path78;
|
||||||
Path path80;
|
late Path path80;
|
||||||
Path path82;
|
late Path path82;
|
||||||
Path path84;
|
late Path path84;
|
||||||
Path path86;
|
late Path path86;
|
||||||
Path path88;
|
late Path path88;
|
||||||
Path path119;
|
late Path path119;
|
||||||
Path path120;
|
late Path path120;
|
||||||
Path path121;
|
late Path path121;
|
||||||
Path path122;
|
late Path path122;
|
||||||
Path path123;
|
late Path path123;
|
||||||
Path path125;
|
late Path path125;
|
||||||
Path path127;
|
late Path path127;
|
||||||
Path path129;
|
late Path path129;
|
||||||
Path path131;
|
late Path path131;
|
||||||
Path path132;
|
late Path path132;
|
||||||
Path path134;
|
late Path path134;
|
||||||
Path path137;
|
late Path path137;
|
||||||
Path path140;
|
late Path path140;
|
||||||
Path path143;
|
late Path path143;
|
||||||
Path path145;
|
late Path path145;
|
||||||
Path path147;
|
late Path path147;
|
||||||
Path path208;
|
late Path path208;
|
||||||
Path path209;
|
late Path path209;
|
||||||
Path path210;
|
late Path path210;
|
||||||
Path path211;
|
late Path path211;
|
||||||
Path path213;
|
late Path path213;
|
||||||
Path path216;
|
late Path path216;
|
||||||
Path path219;
|
late Path path219;
|
||||||
Path path222;
|
late Path path222;
|
||||||
Path path225;
|
late Path path225;
|
||||||
Path path227;
|
late Path path227;
|
||||||
Path path229;
|
late Path path229;
|
||||||
Path path232;
|
late Path path232;
|
||||||
Path path235;
|
late Path path235;
|
||||||
Path path238;
|
late Path path238;
|
||||||
Path path240;
|
late Path path240;
|
||||||
Path path242;
|
late Path path242;
|
||||||
Path path277;
|
late Path path277;
|
||||||
Path path278;
|
late Path path278;
|
||||||
Path path279;
|
late Path path279;
|
||||||
Path path280;
|
late Path path280;
|
||||||
Path path281;
|
late Path path281;
|
||||||
Path path282;
|
late Path path282;
|
||||||
Path path284;
|
late Path path284;
|
||||||
Path path286;
|
late Path path286;
|
||||||
Path path288;
|
late Path path288;
|
||||||
Path path290;
|
late Path path290;
|
||||||
Path path292;
|
late Path path292;
|
||||||
Path path295;
|
late Path path295;
|
||||||
Path path298;
|
late Path path298;
|
||||||
Path path301;
|
late Path path301;
|
||||||
Path path330;
|
late Path path330;
|
||||||
Path path331;
|
late Path path331;
|
||||||
Path path332;
|
late Path path332;
|
||||||
Path path333;
|
late Path path333;
|
||||||
Path path334;
|
late Path path334;
|
||||||
Path path336;
|
late Path path336;
|
||||||
Path path338;
|
late Path path338;
|
||||||
Path path340;
|
late Path path340;
|
||||||
Path path342;
|
late Path path342;
|
||||||
Path path344;
|
late Path path344;
|
||||||
Path path345;
|
late Path path345;
|
||||||
Path path346;
|
late Path path346;
|
||||||
Path path349;
|
late Path path349;
|
||||||
Path path352;
|
late Path path352;
|
||||||
Path path356;
|
late Path path356;
|
||||||
Path path358;
|
late Path path358;
|
||||||
Path path359;
|
late Path path359;
|
||||||
Path path360;
|
late Path path360;
|
||||||
Path path361;
|
late Path path361;
|
||||||
Path path362;
|
late Path path362;
|
||||||
Path path363;
|
late Path path363;
|
||||||
Path path366;
|
late Path path366;
|
||||||
Path path369;
|
late Path path369;
|
||||||
Path path372;
|
late Path path372;
|
||||||
Path path373;
|
late Path path373;
|
||||||
Path path374;
|
late Path path374;
|
||||||
Path path375;
|
late Path path375;
|
||||||
Path path376;
|
late Path path376;
|
||||||
Path path379;
|
late Path path379;
|
||||||
Path path382;
|
late Path path382;
|
||||||
Path path385;
|
late Path path385;
|
||||||
Path path386;
|
late Path path386;
|
||||||
Path path387;
|
late Path path387;
|
||||||
Path path388;
|
late Path path388;
|
||||||
Path path389;
|
late Path path389;
|
||||||
Path path392;
|
late Path path392;
|
||||||
Path path395;
|
late Path path395;
|
||||||
Path path398;
|
late Path path398;
|
||||||
Path path399;
|
late Path path399;
|
||||||
Path path400;
|
late Path path400;
|
||||||
Path path401;
|
late Path path401;
|
||||||
Path path402;
|
late Path path402;
|
||||||
Path path405;
|
late Path path405;
|
||||||
Path path408;
|
late Path path408;
|
||||||
Path path411;
|
late Path path411;
|
||||||
Path path412;
|
late Path path412;
|
||||||
Path path413;
|
late Path path413;
|
||||||
Path path414;
|
late Path path414;
|
||||||
Path path415;
|
late Path path415;
|
||||||
Path path418;
|
late Path path418;
|
||||||
Path path421;
|
late Path path421;
|
||||||
Path path424;
|
late Path path424;
|
||||||
Path path425;
|
late Path path425;
|
||||||
Path path426;
|
late Path path426;
|
||||||
Path path427;
|
late Path path427;
|
||||||
Path path428;
|
late Path path428;
|
||||||
Path path431;
|
late Path path431;
|
||||||
Path path434;
|
late Path path434;
|
||||||
Path path437;
|
late Path path437;
|
||||||
Path path438;
|
late Path path438;
|
||||||
Path path439;
|
late Path path439;
|
||||||
Path path440;
|
late Path path440;
|
||||||
Path path441;
|
late Path path441;
|
||||||
Path path444;
|
late Path path444;
|
||||||
Path path447;
|
late Path path447;
|
||||||
Path path450;
|
late Path path450;
|
||||||
Path path451;
|
late Path path451;
|
||||||
Path path452;
|
late Path path452;
|
||||||
Path path453;
|
late Path path453;
|
||||||
Path path454;
|
late Path path454;
|
||||||
Path path457;
|
late Path path457;
|
||||||
Path path460;
|
late Path path460;
|
||||||
Path path463;
|
late Path path463;
|
||||||
Path path464;
|
late Path path464;
|
||||||
Path path465;
|
late Path path465;
|
||||||
Path path466;
|
late Path path466;
|
||||||
Path path467;
|
late Path path467;
|
||||||
Path path470;
|
late Path path470;
|
||||||
Path path473;
|
late Path path473;
|
||||||
Path path476;
|
late Path path476;
|
||||||
Path path477;
|
late Path path477;
|
||||||
Path path478;
|
late Path path478;
|
||||||
Path path479;
|
late Path path479;
|
||||||
Path path480;
|
late Path path480;
|
||||||
Path path483;
|
late Path path483;
|
||||||
Path path486;
|
late Path path486;
|
||||||
Path path489;
|
late Path path489;
|
||||||
Path path490;
|
late Path path490;
|
||||||
Path path491;
|
late Path path491;
|
||||||
Path path492;
|
late Path path492;
|
||||||
Path path493;
|
late Path path493;
|
||||||
Path path496;
|
late Path path496;
|
||||||
Path path499;
|
late Path path499;
|
||||||
Path path502;
|
late Path path502;
|
||||||
Path path503;
|
late Path path503;
|
||||||
Path path504;
|
late Path path504;
|
||||||
Path path505;
|
late Path path505;
|
||||||
Path path506;
|
late Path path506;
|
||||||
Path path509;
|
late Path path509;
|
||||||
Path path512;
|
late Path path512;
|
||||||
Path path515;
|
late Path path515;
|
||||||
Path path516;
|
late Path path516;
|
||||||
Path path517;
|
late Path path517;
|
||||||
Path path518;
|
late Path path518;
|
||||||
Path path519;
|
late Path path519;
|
||||||
Path path522;
|
late Path path522;
|
||||||
Path path525;
|
late Path path525;
|
||||||
Path path528;
|
late Path path528;
|
||||||
Path path529;
|
late Path path529;
|
||||||
Path path530;
|
late Path path530;
|
||||||
Path path531;
|
late Path path531;
|
||||||
Path path532;
|
late Path path532;
|
||||||
Path path535;
|
late Path path535;
|
||||||
Path path538;
|
late Path path538;
|
||||||
Path path541;
|
late Path path541;
|
||||||
Path path542;
|
late Path path542;
|
||||||
Path path543;
|
late Path path543;
|
||||||
Path path544;
|
late Path path544;
|
||||||
Path path545;
|
late Path path545;
|
||||||
Path path548;
|
late Path path548;
|
||||||
Path path551;
|
late Path path551;
|
||||||
Path path554;
|
late Path path554;
|
||||||
Path path555;
|
late Path path555;
|
||||||
Path path556;
|
late Path path556;
|
||||||
Path path557;
|
late Path path557;
|
||||||
Path path558;
|
late Path path558;
|
||||||
Path path561;
|
late Path path561;
|
||||||
Path path564;
|
late Path path564;
|
||||||
Path path573;
|
late Path path573;
|
||||||
Path path577;
|
late Path path577;
|
||||||
Path path579;
|
late Path path579;
|
||||||
Path path591;
|
late Path path591;
|
||||||
Path path592;
|
late Path path592;
|
||||||
Path path593;
|
late Path path593;
|
||||||
Path path594;
|
late Path path594;
|
||||||
Path path595;
|
late Path path595;
|
||||||
Path path597;
|
late Path path597;
|
||||||
Path path599;
|
late Path path599;
|
||||||
Path path601;
|
late Path path601;
|
||||||
Path path603;
|
late Path path603;
|
||||||
Path path606;
|
late Path path606;
|
||||||
Path path608;
|
late Path path608;
|
||||||
|
|
||||||
void createPaths() {
|
void createPaths() {
|
||||||
allPaths = <dynamic>[];
|
allPaths = <dynamic>[];
|
||||||
|
@ -26,12 +26,12 @@ class BenchPictureRecording extends RawRecorder {
|
|||||||
/// Cached paint used for drawing.
|
/// Cached paint used for drawing.
|
||||||
///
|
///
|
||||||
/// We want to avoid polluting the results with paint initialization logic.
|
/// We want to avoid polluting the results with paint initialization logic.
|
||||||
Paint paint;
|
late Paint paint;
|
||||||
|
|
||||||
/// A prelaid out and cached paragraph.
|
/// A prelaid out and cached paragraph.
|
||||||
///
|
///
|
||||||
/// This is cached to remove text layout time from the benchmark time.
|
/// This is cached to remove text layout time from the benchmark time.
|
||||||
Paragraph paragraph;
|
late Paragraph paragraph;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> setUpAll() async {
|
Future<void> setUpAll() async {
|
||||||
|
@ -56,9 +56,9 @@ class BenchSimpleLazyTextScroll extends WidgetRecorder {
|
|||||||
|
|
||||||
class _TestScrollingWidget extends StatefulWidget {
|
class _TestScrollingWidget extends StatefulWidget {
|
||||||
const _TestScrollingWidget({
|
const _TestScrollingWidget({
|
||||||
@required this.initialScrollOffset,
|
required this.initialScrollOffset,
|
||||||
@required this.scrollDistance,
|
required this.scrollDistance,
|
||||||
@required this.scrollDuration,
|
required this.scrollDuration,
|
||||||
});
|
});
|
||||||
|
|
||||||
final double initialScrollOffset;
|
final double initialScrollOffset;
|
||||||
@ -72,7 +72,7 @@ class _TestScrollingWidget extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _TestScrollingWidgetState extends State<_TestScrollingWidget> {
|
class _TestScrollingWidgetState extends State<_TestScrollingWidget> {
|
||||||
ScrollController scrollController;
|
late ScrollController scrollController;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@ -98,6 +98,12 @@ class _TestScrollingWidgetState extends State<_TestScrollingWidget> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
scrollController.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return ListView.builder(
|
return ListView.builder(
|
||||||
|
@ -31,7 +31,7 @@ class ParagraphGenerator {
|
|||||||
/// font-size so that the engine doesn't reuse a cached ruler.
|
/// font-size so that the engine doesn't reuse a cached ruler.
|
||||||
ui.Paragraph generate(
|
ui.Paragraph generate(
|
||||||
String text, {
|
String text, {
|
||||||
int maxLines,
|
int? maxLines,
|
||||||
bool hasEllipsis = false,
|
bool hasEllipsis = false,
|
||||||
}) {
|
}) {
|
||||||
final ui.ParagraphBuilder builder = ui.ParagraphBuilder(ui.ParagraphStyle(
|
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
|
/// Sends a platform message to the web engine to enable/disable the usage of
|
||||||
/// the canvas-based text measurement implementation.
|
/// the canvas-based text measurement implementation.
|
||||||
void _setTestMode(_TestMode mode) {
|
void _setTestMode(_TestMode? mode) {
|
||||||
bool useCanvasText; // null means do not force DOM or canvas, works for CanvasKit
|
bool? useCanvasText; // null means do not force DOM or canvas, works for CanvasKit
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case _TestMode.useDomTextLayout:
|
case _TestMode.useDomTextLayout:
|
||||||
useCanvasText = false;
|
useCanvasText = false;
|
||||||
@ -148,11 +148,11 @@ class BenchTextLayout extends RawRecorder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void recordParagraphOperations({
|
void recordParagraphOperations({
|
||||||
@required Profile profile,
|
required Profile profile,
|
||||||
@required ui.Paragraph paragraph,
|
required ui.Paragraph paragraph,
|
||||||
@required String text,
|
required String text,
|
||||||
@required String keyPrefix,
|
required String keyPrefix,
|
||||||
@required double maxWidth,
|
required double maxWidth,
|
||||||
}) {
|
}) {
|
||||||
profile.record('$keyPrefix.layout', () {
|
profile.record('$keyPrefix.layout', () {
|
||||||
paragraph.layout(ui.ParagraphConstraints(width: maxWidth));
|
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.
|
// updates the value of [showWidget] in preparation for the next frame.
|
||||||
// TODO(yjbanov): https://github.com/flutter/flutter/issues/53877
|
// TODO(yjbanov): https://github.com/flutter/flutter/issues/53877
|
||||||
if (showWidget && _mode != _TestMode.useCanvasKit) {
|
if (showWidget && _mode != _TestMode.useCanvasKit) {
|
||||||
profile.addDataPoint(
|
profile!.addDataPoint(
|
||||||
'text_layout',
|
'text_layout',
|
||||||
Duration(microseconds: _textLayoutMicros.toInt()),
|
Duration(microseconds: _textLayoutMicros.toInt()),
|
||||||
reported: true,
|
reported: true,
|
||||||
@ -299,15 +299,13 @@ class BenchBuildColorsGrid extends WidgetBuildRecorder {
|
|||||||
const double kColorItemHeight = 48.0;
|
const double kColorItemHeight = 48.0;
|
||||||
|
|
||||||
class Palette {
|
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 String name;
|
||||||
final MaterialColor primary;
|
final MaterialColor primary;
|
||||||
final MaterialAccentColor accent;
|
final MaterialAccentColor? accent;
|
||||||
final int
|
final int
|
||||||
threshold; // titles for indices > threshold are white, otherwise black
|
threshold; // titles for indices > threshold are white, otherwise black
|
||||||
|
|
||||||
bool get isValid => name != null && primary != null && threshold != null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<Palette> allPalettes = <Palette>[
|
final List<Palette> allPalettes = <Palette>[
|
||||||
@ -390,9 +388,9 @@ final List<Palette> allPalettes = <Palette>[
|
|||||||
|
|
||||||
class ColorItem extends StatelessWidget {
|
class ColorItem extends StatelessWidget {
|
||||||
const ColorItem({
|
const ColorItem({
|
||||||
Key key,
|
Key? key,
|
||||||
@required this.index,
|
required this.index,
|
||||||
@required this.color,
|
required this.color,
|
||||||
this.prefix = '',
|
this.prefix = '',
|
||||||
}) : assert(index != null),
|
}) : assert(index != null),
|
||||||
assert(color != null),
|
assert(color != null),
|
||||||
@ -432,11 +430,10 @@ class ColorItem extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class PaletteTabView extends StatelessWidget {
|
class PaletteTabView extends StatelessWidget {
|
||||||
PaletteTabView({
|
const PaletteTabView({
|
||||||
Key key,
|
Key? key,
|
||||||
@required this.colors,
|
required this.colors,
|
||||||
}) : assert(colors != null && colors.isValid),
|
}) : super(key: key);
|
||||||
super(key: key);
|
|
||||||
|
|
||||||
final Palette colors;
|
final Palette colors;
|
||||||
|
|
||||||
@ -458,9 +455,9 @@ class PaletteTabView extends StatelessWidget {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final TextTheme textTheme = Theme.of(context).textTheme;
|
final TextTheme textTheme = Theme.of(context).textTheme;
|
||||||
final TextStyle whiteTextStyle =
|
final TextStyle whiteTextStyle =
|
||||||
textTheme.bodyText2.copyWith(color: Colors.white);
|
textTheme.bodyText2!.copyWith(color: Colors.white);
|
||||||
final TextStyle blackTextStyle =
|
final TextStyle blackTextStyle =
|
||||||
textTheme.bodyText2.copyWith(color: Colors.black);
|
textTheme.bodyText2!.copyWith(color: Colors.black);
|
||||||
return Scrollbar(
|
return Scrollbar(
|
||||||
child: ListView(
|
child: ListView(
|
||||||
itemExtent: kColorItemHeight,
|
itemExtent: kColorItemHeight,
|
||||||
@ -468,7 +465,7 @@ class PaletteTabView extends StatelessWidget {
|
|||||||
...primaryKeys.map<Widget>((int index) {
|
...primaryKeys.map<Widget>((int index) {
|
||||||
return DefaultTextStyle(
|
return DefaultTextStyle(
|
||||||
style: index > colors.threshold ? whiteTextStyle : blackTextStyle,
|
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)
|
if (colors.accent != null)
|
||||||
@ -477,7 +474,7 @@ class PaletteTabView extends StatelessWidget {
|
|||||||
style:
|
style:
|
||||||
index > colors.threshold ? whiteTextStyle : blackTextStyle,
|
index > colors.threshold ? whiteTextStyle : blackTextStyle,
|
||||||
child: ColorItem(
|
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 {
|
class ColorsDemo extends StatelessWidget {
|
||||||
const ColorsDemo({Key key}) : super(key: key);
|
const ColorsDemo({Key? key}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
@ -54,8 +54,8 @@ class BenchTextOutOfPictureBounds extends SceneBuilderRecorder {
|
|||||||
|
|
||||||
static const String benchmarkName = 'text_out_of_picture_bounds';
|
static const String benchmarkName = 'text_out_of_picture_bounds';
|
||||||
|
|
||||||
List<Paragraph> singleLineParagraphs;
|
late List<Paragraph> singleLineParagraphs;
|
||||||
List<Paragraph> multiLineParagraphs;
|
late List<Paragraph> multiLineParagraphs;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onDrawFrame(SceneBuilder sceneBuilder) {
|
void onDrawFrame(SceneBuilder sceneBuilder) {
|
||||||
|
@ -29,16 +29,14 @@ class BenchWrapBoxScroll extends WidgetRecorder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class MyHomePage extends StatefulWidget {
|
class MyHomePage extends StatefulWidget {
|
||||||
const MyHomePage({Key key, this.title}) : super(key: key);
|
const MyHomePage({Key? key}) : super(key: key);
|
||||||
|
|
||||||
final String title;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<MyHomePage> createState() => _MyHomePageState();
|
State<MyHomePage> createState() => _MyHomePageState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _MyHomePageState extends State<MyHomePage> {
|
class _MyHomePageState extends State<MyHomePage> {
|
||||||
ScrollController scrollController;
|
late ScrollController scrollController;
|
||||||
int block = 0;
|
int block = 0;
|
||||||
static const Duration stepDuration = Duration(milliseconds: 500);
|
static const Duration stepDuration = Duration(milliseconds: 500);
|
||||||
static const double stepDistance = 400;
|
static const double stepDistance = 400;
|
||||||
@ -61,8 +59,8 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
super.dispose();
|
|
||||||
scrollController.dispose();
|
scrollController.dispose();
|
||||||
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -84,7 +82,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class ProductPreview extends StatelessWidget {
|
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;
|
final int previewIndex;
|
||||||
|
|
||||||
@ -143,8 +141,8 @@ class ProductPreview extends StatelessWidget {
|
|||||||
|
|
||||||
class ProductOption extends StatelessWidget {
|
class ProductOption extends StatelessWidget {
|
||||||
const ProductOption({
|
const ProductOption({
|
||||||
Key key,
|
Key? key,
|
||||||
@required this.optionText,
|
required this.optionText,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
final String optionText;
|
final String optionText;
|
||||||
|
@ -63,7 +63,7 @@ class Runner {
|
|||||||
///
|
///
|
||||||
/// All arguments must not be null.
|
/// All arguments must not be null.
|
||||||
Runner({
|
Runner({
|
||||||
@required this.recorder,
|
required this.recorder,
|
||||||
this.setUpAllDidRun = _dummyAsyncVoidCallback,
|
this.setUpAllDidRun = _dummyAsyncVoidCallback,
|
||||||
this.tearDownAllWillRun = _dummyAsyncVoidCallback,
|
this.tearDownAllWillRun = _dummyAsyncVoidCallback,
|
||||||
});
|
});
|
||||||
@ -113,13 +113,13 @@ abstract class Recorder {
|
|||||||
/// Returns the recorded profile.
|
/// Returns the recorded profile.
|
||||||
///
|
///
|
||||||
/// This value is only available while the benchmark is running.
|
/// This value is only available while the benchmark is running.
|
||||||
Profile get profile;
|
Profile? get profile;
|
||||||
|
|
||||||
/// Whether the benchmark should continue running.
|
/// Whether the benchmark should continue running.
|
||||||
///
|
///
|
||||||
/// Returns `false` if the benchmark collected enough data and it's time to
|
/// Returns `false` if the benchmark collected enough data and it's time to
|
||||||
/// stop.
|
/// stop.
|
||||||
bool shouldContinue() => profile.shouldContinue();
|
bool shouldContinue() => profile?.shouldContinue() ?? true;
|
||||||
|
|
||||||
/// Called once before all runs of this benchmark recorder.
|
/// Called once before all runs of this benchmark recorder.
|
||||||
///
|
///
|
||||||
@ -161,7 +161,7 @@ abstract class Recorder {
|
|||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
abstract class RawRecorder extends Recorder {
|
abstract class RawRecorder extends Recorder {
|
||||||
RawRecorder({@required String name}) : super._(name, false);
|
RawRecorder({required String name}) : super._(name, false);
|
||||||
|
|
||||||
/// The body of the benchmark.
|
/// The body of the benchmark.
|
||||||
///
|
///
|
||||||
@ -169,8 +169,8 @@ abstract class RawRecorder extends Recorder {
|
|||||||
void body(Profile profile);
|
void body(Profile profile);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Profile get profile => _profile;
|
Profile? get profile => _profile;
|
||||||
Profile _profile;
|
Profile? _profile;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@nonVirtual
|
@nonVirtual
|
||||||
@ -178,9 +178,9 @@ abstract class RawRecorder extends Recorder {
|
|||||||
_profile = Profile(name: name);
|
_profile = Profile(name: name);
|
||||||
do {
|
do {
|
||||||
await Future<void>.delayed(Duration.zero);
|
await Future<void>.delayed(Duration.zero);
|
||||||
body(_profile);
|
body(_profile!);
|
||||||
} while (shouldContinue());
|
} while (shouldContinue());
|
||||||
return _profile;
|
return _profile!;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -210,11 +210,11 @@ abstract class RawRecorder extends Recorder {
|
|||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
abstract class SceneBuilderRecorder extends Recorder {
|
abstract class SceneBuilderRecorder extends Recorder {
|
||||||
SceneBuilderRecorder({@required String name}) : super._(name, true);
|
SceneBuilderRecorder({required String name}) : super._(name, true);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Profile get profile => _profile;
|
Profile? get profile => _profile;
|
||||||
Profile _profile;
|
Profile? _profile;
|
||||||
|
|
||||||
/// Called from [dart:ui.PlatformDispatcher.onBeginFrame].
|
/// Called from [dart:ui.PlatformDispatcher.onBeginFrame].
|
||||||
@mustCallSuper
|
@mustCallSuper
|
||||||
@ -235,7 +235,7 @@ abstract class SceneBuilderRecorder extends Recorder {
|
|||||||
|
|
||||||
window.onBeginFrame = (_) {
|
window.onBeginFrame = (_) {
|
||||||
try {
|
try {
|
||||||
startMeasureFrame(profile);
|
startMeasureFrame(profile!);
|
||||||
onBeginFrame();
|
onBeginFrame();
|
||||||
} catch (error, stackTrace) {
|
} catch (error, stackTrace) {
|
||||||
profileCompleter.completeError(error, stackTrace);
|
profileCompleter.completeError(error, stackTrace);
|
||||||
@ -244,12 +244,12 @@ abstract class SceneBuilderRecorder extends Recorder {
|
|||||||
};
|
};
|
||||||
window.onDrawFrame = () {
|
window.onDrawFrame = () {
|
||||||
try {
|
try {
|
||||||
_profile.record('drawFrameDuration', () {
|
_profile!.record('drawFrameDuration', () {
|
||||||
final SceneBuilder sceneBuilder = SceneBuilder();
|
final SceneBuilder sceneBuilder = SceneBuilder();
|
||||||
onDrawFrame(sceneBuilder);
|
onDrawFrame(sceneBuilder);
|
||||||
_profile.record('sceneBuildDuration', () {
|
_profile!.record('sceneBuildDuration', () {
|
||||||
final Scene scene = sceneBuilder.build();
|
final Scene scene = sceneBuilder.build();
|
||||||
_profile.record('windowRenderDuration', () {
|
_profile!.record('windowRenderDuration', () {
|
||||||
window.render(scene);
|
window.render(scene);
|
||||||
}, reported: false);
|
}, reported: false);
|
||||||
}, reported: false);
|
}, reported: false);
|
||||||
@ -334,7 +334,7 @@ abstract class SceneBuilderRecorder extends Recorder {
|
|||||||
/// ```
|
/// ```
|
||||||
abstract class WidgetRecorder extends Recorder implements FrameRecorder {
|
abstract class WidgetRecorder extends Recorder implements FrameRecorder {
|
||||||
WidgetRecorder({
|
WidgetRecorder({
|
||||||
@required String name,
|
required String name,
|
||||||
this.useCustomWarmUp = false,
|
this.useCustomWarmUp = false,
|
||||||
}) : super._(name, true);
|
}) : super._(name, true);
|
||||||
|
|
||||||
@ -352,18 +352,18 @@ abstract class WidgetRecorder extends Recorder implements FrameRecorder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Profile profile;
|
Profile? profile;
|
||||||
Completer<void> _runCompleter;
|
Completer<void>? _runCompleter;
|
||||||
|
|
||||||
/// Whether to delimit warm-up frames in a custom way.
|
/// Whether to delimit warm-up frames in a custom way.
|
||||||
final bool useCustomWarmUp;
|
final bool useCustomWarmUp;
|
||||||
|
|
||||||
Stopwatch _drawFrameStopwatch;
|
late Stopwatch _drawFrameStopwatch;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@mustCallSuper
|
@mustCallSuper
|
||||||
void frameWillDraw() {
|
void frameWillDraw() {
|
||||||
startMeasureFrame(profile);
|
startMeasureFrame(profile!);
|
||||||
_drawFrameStopwatch = Stopwatch()..start();
|
_drawFrameStopwatch = Stopwatch()..start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -371,20 +371,20 @@ abstract class WidgetRecorder extends Recorder implements FrameRecorder {
|
|||||||
@mustCallSuper
|
@mustCallSuper
|
||||||
void frameDidDraw() {
|
void frameDidDraw() {
|
||||||
endMeasureFrame();
|
endMeasureFrame();
|
||||||
profile.addDataPoint('drawFrameDuration', _drawFrameStopwatch.elapsed, reported: true);
|
profile!.addDataPoint('drawFrameDuration', _drawFrameStopwatch.elapsed, reported: true);
|
||||||
|
|
||||||
if (shouldContinue()) {
|
if (shouldContinue()) {
|
||||||
window.scheduleFrame();
|
window.scheduleFrame();
|
||||||
} else {
|
} else {
|
||||||
for (final VoidCallback fn in _didStopCallbacks)
|
for (final VoidCallback fn in _didStopCallbacks)
|
||||||
fn();
|
fn();
|
||||||
_runCompleter.complete();
|
_runCompleter!.complete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void _onError(dynamic error, StackTrace stackTrace) {
|
void _onError(Object error, StackTrace? stackTrace) {
|
||||||
_runCompleter.completeError(error, stackTrace);
|
_runCompleter!.completeError(error, stackTrace);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -413,7 +413,7 @@ abstract class WidgetRecorder extends Recorder implements FrameRecorder {
|
|||||||
binding._beginRecording(this, widget);
|
binding._beginRecording(this, widget);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await _runCompleter.future;
|
await _runCompleter!.future;
|
||||||
return localProfile;
|
return localProfile;
|
||||||
} finally {
|
} finally {
|
||||||
stopListeningToEngineBenchmarkValues(kProfilePrerollFrame);
|
stopListeningToEngineBenchmarkValues(kProfilePrerollFrame);
|
||||||
@ -432,7 +432,7 @@ abstract class WidgetRecorder extends Recorder implements FrameRecorder {
|
|||||||
/// performance of frames that render the widget and ignoring the frames that
|
/// performance of frames that render the widget and ignoring the frames that
|
||||||
/// clear the screen.
|
/// clear the screen.
|
||||||
abstract class WidgetBuildRecorder extends Recorder implements FrameRecorder {
|
abstract class WidgetBuildRecorder extends Recorder implements FrameRecorder {
|
||||||
WidgetBuildRecorder({@required String name}) : super._(name, true);
|
WidgetBuildRecorder({required String name}) : super._(name, true);
|
||||||
|
|
||||||
/// Creates a widget to be benchmarked.
|
/// Creates a widget to be benchmarked.
|
||||||
///
|
///
|
||||||
@ -448,10 +448,10 @@ abstract class WidgetBuildRecorder extends Recorder implements FrameRecorder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Profile profile;
|
Profile? profile;
|
||||||
Completer<void> _runCompleter;
|
Completer<void>? _runCompleter;
|
||||||
|
|
||||||
Stopwatch _drawFrameStopwatch;
|
late Stopwatch _drawFrameStopwatch;
|
||||||
|
|
||||||
/// Whether in this frame we should call [createWidget] and render it.
|
/// Whether in this frame we should call [createWidget] and render it.
|
||||||
///
|
///
|
||||||
@ -459,9 +459,9 @@ abstract class WidgetBuildRecorder extends Recorder implements FrameRecorder {
|
|||||||
bool showWidget = true;
|
bool showWidget = true;
|
||||||
|
|
||||||
/// The state that hosts the widget under test.
|
/// The state that hosts the widget under test.
|
||||||
_WidgetBuildRecorderHostState _hostState;
|
late _WidgetBuildRecorderHostState _hostState;
|
||||||
|
|
||||||
Widget _getWidgetForFrame() {
|
Widget? _getWidgetForFrame() {
|
||||||
if (showWidget) {
|
if (showWidget) {
|
||||||
return createWidget();
|
return createWidget();
|
||||||
} else {
|
} else {
|
||||||
@ -473,7 +473,7 @@ abstract class WidgetBuildRecorder extends Recorder implements FrameRecorder {
|
|||||||
@mustCallSuper
|
@mustCallSuper
|
||||||
void frameWillDraw() {
|
void frameWillDraw() {
|
||||||
if (showWidget) {
|
if (showWidget) {
|
||||||
startMeasureFrame(profile);
|
startMeasureFrame(profile!);
|
||||||
_drawFrameStopwatch = Stopwatch()..start();
|
_drawFrameStopwatch = Stopwatch()..start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -484,7 +484,7 @@ abstract class WidgetBuildRecorder extends Recorder implements FrameRecorder {
|
|||||||
// Only record frames that show the widget.
|
// Only record frames that show the widget.
|
||||||
if (showWidget) {
|
if (showWidget) {
|
||||||
endMeasureFrame();
|
endMeasureFrame();
|
||||||
profile.addDataPoint('drawFrameDuration', _drawFrameStopwatch.elapsed, reported: true);
|
profile!.addDataPoint('drawFrameDuration', _drawFrameStopwatch.elapsed, reported: true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shouldContinue()) {
|
if (shouldContinue()) {
|
||||||
@ -493,13 +493,13 @@ abstract class WidgetBuildRecorder extends Recorder implements FrameRecorder {
|
|||||||
} else {
|
} else {
|
||||||
for (final VoidCallback fn in _didStopCallbacks)
|
for (final VoidCallback fn in _didStopCallbacks)
|
||||||
fn();
|
fn();
|
||||||
_runCompleter.complete();
|
_runCompleter!.complete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void _onError(dynamic error, StackTrace stackTrace) {
|
void _onError(Object error, StackTrace? stackTrace) {
|
||||||
_runCompleter.completeError(error, stackTrace);
|
_runCompleter!.completeError(error, stackTrace);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -511,7 +511,7 @@ abstract class WidgetBuildRecorder extends Recorder implements FrameRecorder {
|
|||||||
binding._beginRecording(this, _WidgetBuildRecorderHost(this));
|
binding._beginRecording(this, _WidgetBuildRecorderHost(this));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await _runCompleter.future;
|
await _runCompleter!.future;
|
||||||
return localProfile;
|
return localProfile;
|
||||||
} finally {
|
} finally {
|
||||||
_runCompleter = null;
|
_runCompleter = null;
|
||||||
@ -578,11 +578,11 @@ class Timeseries {
|
|||||||
|
|
||||||
/// The number of frames ignored as warm-up frames, used only
|
/// The number of frames ignored as warm-up frames, used only
|
||||||
/// when [useCustomWarmUp] is true.
|
/// when [useCustomWarmUp] is true.
|
||||||
int _warmUpFrameCount;
|
int? _warmUpFrameCount;
|
||||||
|
|
||||||
/// The number of frames ignored as warm-up frames.
|
/// The number of frames ignored as warm-up frames.
|
||||||
int get warmUpFrameCount => useCustomWarmUp
|
int get warmUpFrameCount => useCustomWarmUp
|
||||||
? _warmUpFrameCount
|
? _warmUpFrameCount!
|
||||||
: count - _kMeasuredSampleCount;
|
: count - _kMeasuredSampleCount;
|
||||||
|
|
||||||
/// List of all the values that have been recorded.
|
/// List of all the values that have been recorded.
|
||||||
@ -664,7 +664,7 @@ class Timeseries {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Adds a value to this timeseries.
|
/// Adds a value to this timeseries.
|
||||||
void add(double value, {@required bool isWarmUpValue}) {
|
void add(double value, {required bool isWarmUpValue}) {
|
||||||
if (value < 0.0) {
|
if (value < 0.0) {
|
||||||
throw StateError(
|
throw StateError(
|
||||||
'Timeseries $name: negative metric values are not supported. Got: $value',
|
'Timeseries $name: negative metric values are not supported. Got: $value',
|
||||||
@ -672,7 +672,7 @@ class Timeseries {
|
|||||||
}
|
}
|
||||||
_allValues.add(value);
|
_allValues.add(value);
|
||||||
if (useCustomWarmUp && isWarmUpValue) {
|
if (useCustomWarmUp && isWarmUpValue) {
|
||||||
_warmUpFrameCount += 1;
|
_warmUpFrameCount = (_warmUpFrameCount ?? 0) + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -683,15 +683,15 @@ class Timeseries {
|
|||||||
@sealed
|
@sealed
|
||||||
class TimeseriesStats {
|
class TimeseriesStats {
|
||||||
const TimeseriesStats({
|
const TimeseriesStats({
|
||||||
@required this.name,
|
required this.name,
|
||||||
@required this.average,
|
required this.average,
|
||||||
@required this.outlierCutOff,
|
required this.outlierCutOff,
|
||||||
@required this.outlierAverage,
|
required this.outlierAverage,
|
||||||
@required this.standardDeviation,
|
required this.standardDeviation,
|
||||||
@required this.noise,
|
required this.noise,
|
||||||
@required this.cleanSampleCount,
|
required this.cleanSampleCount,
|
||||||
@required this.outlierSampleCount,
|
required this.outlierSampleCount,
|
||||||
@required this.samples,
|
required this.samples,
|
||||||
});
|
});
|
||||||
|
|
||||||
/// The label used to refer to the corresponding timeseries.
|
/// The label used to refer to the corresponding timeseries.
|
||||||
@ -764,9 +764,9 @@ class TimeseriesStats {
|
|||||||
@sealed
|
@sealed
|
||||||
class AnnotatedSample {
|
class AnnotatedSample {
|
||||||
const AnnotatedSample({
|
const AnnotatedSample({
|
||||||
@required this.magnitude,
|
required this.magnitude,
|
||||||
@required this.isOutlier,
|
required this.isOutlier,
|
||||||
@required this.isWarmUpValue,
|
required this.isWarmUpValue,
|
||||||
});
|
});
|
||||||
|
|
||||||
/// The non-negative raw result of the measurement.
|
/// The non-negative raw result of the measurement.
|
||||||
@ -787,7 +787,7 @@ class AnnotatedSample {
|
|||||||
|
|
||||||
/// Base class for a profile collected from running a benchmark.
|
/// Base class for a profile collected from running a benchmark.
|
||||||
class Profile {
|
class Profile {
|
||||||
Profile({@required this.name, this.useCustomWarmUp = false})
|
Profile({required this.name, this.useCustomWarmUp = false})
|
||||||
: assert(name != null),
|
: assert(name != null),
|
||||||
_isWarmingUp = useCustomWarmUp;
|
_isWarmingUp = useCustomWarmUp;
|
||||||
|
|
||||||
@ -824,7 +824,7 @@ class Profile {
|
|||||||
final Map<String, dynamic> extraData = <String, dynamic>{};
|
final Map<String, dynamic> extraData = <String, dynamic>{};
|
||||||
|
|
||||||
/// Invokes [callback] and records the duration of its execution under [key].
|
/// Invokes [callback] and records the duration of its execution under [key].
|
||||||
Duration record(String key, VoidCallback callback, { @required bool reported }) {
|
Duration record(String key, VoidCallback callback, { required bool reported }) {
|
||||||
final Duration duration = timeAction(callback);
|
final Duration duration = timeAction(callback);
|
||||||
addDataPoint(key, duration, reported: reported);
|
addDataPoint(key, duration, reported: reported);
|
||||||
return duration;
|
return duration;
|
||||||
@ -836,7 +836,7 @@ class Profile {
|
|||||||
///
|
///
|
||||||
/// Set [reported] to `false` to store the data, but not show it on the
|
/// Set [reported] to `false` to store the data, but not show it on the
|
||||||
/// dashboard UI.
|
/// dashboard UI.
|
||||||
void addDataPoint(String key, Duration duration, { @required bool reported }) {
|
void addDataPoint(String key, Duration duration, { required bool reported }) {
|
||||||
scoreData.putIfAbsent(
|
scoreData.putIfAbsent(
|
||||||
key,
|
key,
|
||||||
() => Timeseries(key, reported, useCustomWarmUp: useCustomWarmUp),
|
() => Timeseries(key, reported, useCustomWarmUp: useCustomWarmUp),
|
||||||
@ -860,7 +860,7 @@ class Profile {
|
|||||||
|
|
||||||
// We have recorded something, but do we have enough samples? If every
|
// We have recorded something, but do we have enough samples? If every
|
||||||
// timeseries has collected enough samples, stop the benchmark.
|
// timeseries has collected enough samples, stop the benchmark.
|
||||||
return !scoreData.keys.every((String key) => scoreData[key].count >= kTotalSampleCount);
|
return !scoreData.keys.every((String key) => scoreData[key]!.count >= kTotalSampleCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a JSON representation of the profile that will be sent to the
|
/// Returns a JSON representation of the profile that will be sent to the
|
||||||
@ -873,7 +873,7 @@ class Profile {
|
|||||||
};
|
};
|
||||||
|
|
||||||
for (final String key in scoreData.keys) {
|
for (final String key in scoreData.keys) {
|
||||||
final Timeseries timeseries = scoreData[key];
|
final Timeseries timeseries = scoreData[key]!;
|
||||||
|
|
||||||
if (timeseries.isReported) {
|
if (timeseries.isReported) {
|
||||||
scoreKeys.add('$key.average');
|
scoreKeys.add('$key.average');
|
||||||
@ -900,7 +900,7 @@ class Profile {
|
|||||||
final StringBuffer buffer = StringBuffer();
|
final StringBuffer buffer = StringBuffer();
|
||||||
buffer.writeln('name: $name');
|
buffer.writeln('name: $name');
|
||||||
for (final String key in scoreData.keys) {
|
for (final String key in scoreData.keys) {
|
||||||
final Timeseries timeseries = scoreData[key];
|
final Timeseries timeseries = scoreData[key]!;
|
||||||
final TimeseriesStats stats = timeseries.computeStats();
|
final TimeseriesStats stats = timeseries.computeStats();
|
||||||
buffer.writeln(stats.toString());
|
buffer.writeln(stats.toString());
|
||||||
}
|
}
|
||||||
@ -967,7 +967,7 @@ abstract class FrameRecorder {
|
|||||||
/// Reports an error.
|
/// Reports an error.
|
||||||
///
|
///
|
||||||
/// The implementation is expected to halt benchmark execution as soon as possible.
|
/// The implementation is expected to halt benchmark execution as soon as possible.
|
||||||
void _onError(dynamic error, StackTrace stackTrace);
|
void _onError(Object error, StackTrace? stackTrace);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A variant of [WidgetsBinding] that collaborates with a [Recorder] to decide
|
/// A variant of [WidgetsBinding] that collaborates with a [Recorder] to decide
|
||||||
@ -992,10 +992,10 @@ class _RecordingWidgetsBinding extends BindingBase
|
|||||||
if (WidgetsBinding.instance == null) {
|
if (WidgetsBinding.instance == null) {
|
||||||
_RecordingWidgetsBinding();
|
_RecordingWidgetsBinding();
|
||||||
}
|
}
|
||||||
return WidgetsBinding.instance as _RecordingWidgetsBinding;
|
return WidgetsBinding.instance! as _RecordingWidgetsBinding;
|
||||||
}
|
}
|
||||||
|
|
||||||
FrameRecorder _recorder;
|
FrameRecorder? _recorder;
|
||||||
bool _hasErrored = false;
|
bool _hasErrored = false;
|
||||||
|
|
||||||
/// To short-circuit all frame lifecycle methods when the benchmark has
|
/// To short-circuit all frame lifecycle methods when the benchmark has
|
||||||
@ -1008,7 +1008,7 @@ class _RecordingWidgetsBinding extends BindingBase
|
|||||||
'Cannot call _RecordingWidgetsBinding._beginRecording more than once',
|
'Cannot call _RecordingWidgetsBinding._beginRecording more than once',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
final FlutterExceptionHandler originalOnError = FlutterError.onError;
|
final FlutterExceptionHandler? originalOnError = FlutterError.onError;
|
||||||
|
|
||||||
recorder.registerDidStop(() {
|
recorder.registerDidStop(() {
|
||||||
_benchmarkStopped = true;
|
_benchmarkStopped = true;
|
||||||
@ -1017,22 +1017,22 @@ class _RecordingWidgetsBinding extends BindingBase
|
|||||||
// Fail hard and fast on errors. Benchmarks should not have any errors.
|
// Fail hard and fast on errors. Benchmarks should not have any errors.
|
||||||
FlutterError.onError = (FlutterErrorDetails details) {
|
FlutterError.onError = (FlutterErrorDetails details) {
|
||||||
_haltBenchmarkWithError(details.exception, details.stack);
|
_haltBenchmarkWithError(details.exception, details.stack);
|
||||||
originalOnError(details);
|
originalOnError?.call(details);
|
||||||
};
|
};
|
||||||
_recorder = recorder;
|
_recorder = recorder;
|
||||||
runApp(widget);
|
runApp(widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _haltBenchmarkWithError(dynamic error, StackTrace stackTrace) {
|
void _haltBenchmarkWithError(Object error, StackTrace? stackTrace) {
|
||||||
if (_hasErrored) {
|
if (_hasErrored) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_recorder._onError(error, stackTrace);
|
_recorder?._onError(error, stackTrace);
|
||||||
_hasErrored = true;
|
_hasErrored = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void handleBeginFrame(Duration rawTimeStamp) {
|
void handleBeginFrame(Duration? rawTimeStamp) {
|
||||||
// Don't keep on truckin' if there's an error or the benchmark has stopped.
|
// Don't keep on truckin' if there's an error or the benchmark has stopped.
|
||||||
if (_hasErrored || _benchmarkStopped) {
|
if (_hasErrored || _benchmarkStopped) {
|
||||||
return;
|
return;
|
||||||
@ -1061,9 +1061,9 @@ class _RecordingWidgetsBinding extends BindingBase
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
_recorder.frameWillDraw();
|
_recorder?.frameWillDraw();
|
||||||
super.handleDrawFrame();
|
super.handleDrawFrame();
|
||||||
_recorder.frameDidDraw();
|
_recorder?.frameDidDraw();
|
||||||
} catch (error, stackTrace) {
|
} catch (error, stackTrace) {
|
||||||
_haltBenchmarkWithError(error, stackTrace);
|
_haltBenchmarkWithError(error, stackTrace);
|
||||||
rethrow;
|
rethrow;
|
||||||
@ -1189,7 +1189,7 @@ void stopListeningToEngineBenchmarkValues(String name) {
|
|||||||
//
|
//
|
||||||
// If there are no listeners registered for [name], ignores the value.
|
// If there are no listeners registered for [name], ignores the value.
|
||||||
void _dispatchEngineBenchmarkValue(String name, double value) {
|
void _dispatchEngineBenchmarkValue(String name, double value) {
|
||||||
final EngineBenchmarkValueListener listener = _engineBenchmarkListeners[name];
|
final EngineBenchmarkValueListener? listener = _engineBenchmarkListeners[name];
|
||||||
if (listener != null) {
|
if (listener != null) {
|
||||||
listener(value);
|
listener(value);
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,6 @@
|
|||||||
import 'dart:math' as math;
|
import 'dart:math' as math;
|
||||||
import 'dart:ui';
|
import 'dart:ui';
|
||||||
|
|
||||||
import 'package:meta/meta.dart';
|
|
||||||
|
|
||||||
// Used to randomize data.
|
// Used to randomize data.
|
||||||
//
|
//
|
||||||
// Using constant seed for reproducibility.
|
// 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
|
/// Generates strings and builds pre-laid out paragraphs to be used by
|
||||||
/// benchmarks.
|
/// benchmarks.
|
||||||
List<Paragraph> generateLaidOutParagraphs({
|
List<Paragraph> generateLaidOutParagraphs({
|
||||||
@required int paragraphCount,
|
required int paragraphCount,
|
||||||
@required int minWordCountPerParagraph,
|
required int minWordCountPerParagraph,
|
||||||
@required int maxWordCountPerParagraph,
|
required int maxWordCountPerParagraph,
|
||||||
@required double widthConstraint,
|
required double widthConstraint,
|
||||||
@required Color color,
|
required Color color,
|
||||||
}) {
|
}) {
|
||||||
final List<Paragraph> strings = <Paragraph>[];
|
final List<Paragraph> strings = <Paragraph>[];
|
||||||
int wordPointer = 0; // points to the next word in lipsum to extract
|
int wordPointer = 0; // points to the next word in lipsum to extract
|
||||||
|
@ -93,7 +93,7 @@ Future<void> main() async {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _runBenchmark(String benchmarkName) async {
|
Future<void> _runBenchmark(String benchmarkName) async {
|
||||||
final RecorderFactory recorderFactory = benchmarks[benchmarkName];
|
final RecorderFactory? recorderFactory = benchmarks[benchmarkName];
|
||||||
|
|
||||||
if (recorderFactory == null) {
|
if (recorderFactory == null) {
|
||||||
_fallbackToManual('Benchmark $benchmarkName not found.');
|
_fallbackToManual('Benchmark $benchmarkName not found.');
|
||||||
@ -145,7 +145,7 @@ Future<void> _runBenchmark(String benchmarkName) async {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _fallbackToManual(String error) {
|
void _fallbackToManual(String error) {
|
||||||
html.document.body.appendHtml('''
|
html.document.body!.appendHtml('''
|
||||||
<div id="manual-panel">
|
<div id="manual-panel">
|
||||||
<h3>$error</h3>
|
<h3>$error</h3>
|
||||||
|
|
||||||
@ -163,9 +163,9 @@ void _fallbackToManual(String error) {
|
|||||||
''', validator: html.NodeValidatorBuilder()..allowHtml5()..allowInlineStyles());
|
''', validator: html.NodeValidatorBuilder()..allowHtml5()..allowInlineStyles());
|
||||||
|
|
||||||
for (final String benchmarkName in benchmarks.keys) {
|
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', (_) {
|
button.addEventListener('click', (_) {
|
||||||
final html.Element manualPanel = html.document.querySelector('#manual-panel');
|
final html.Element? manualPanel = html.document.querySelector('#manual-panel');
|
||||||
manualPanel?.remove();
|
manualPanel?.remove();
|
||||||
_runBenchmark(benchmarkName);
|
_runBenchmark(benchmarkName);
|
||||||
});
|
});
|
||||||
@ -174,14 +174,14 @@ void _fallbackToManual(String error) {
|
|||||||
|
|
||||||
/// Visualizes results on the Web page for manual inspection.
|
/// Visualizes results on the Web page for manual inspection.
|
||||||
void _printResultsToScreen(Profile profile) {
|
void _printResultsToScreen(Profile profile) {
|
||||||
html.document.body.remove();
|
html.document.body!.remove();
|
||||||
html.document.body = html.BodyElement();
|
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) {
|
profile.scoreData.forEach((String scoreKey, Timeseries timeseries) {
|
||||||
html.document.body.appendHtml('<h2>$scoreKey</h2>');
|
html.document.body!.appendHtml('<h2>$scoreKey</h2>');
|
||||||
html.document.body.appendHtml('<pre>${timeseries.computeStats()}</pre>');
|
html.document.body!.appendHtml('<pre>${timeseries.computeStats()}</pre>');
|
||||||
html.document.body.append(TimeseriesVisualization(timeseries).render());
|
html.document.body!.append(TimeseriesVisualization(timeseries).render());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -190,7 +190,7 @@ class TimeseriesVisualization {
|
|||||||
TimeseriesVisualization(this._timeseries) {
|
TimeseriesVisualization(this._timeseries) {
|
||||||
_stats = _timeseries.computeStats();
|
_stats = _timeseries.computeStats();
|
||||||
_canvas = html.CanvasElement();
|
_canvas = html.CanvasElement();
|
||||||
_screenWidth = html.window.screen.width;
|
_screenWidth = html.window.screen!.width!;
|
||||||
_canvas.width = _screenWidth;
|
_canvas.width = _screenWidth;
|
||||||
_canvas.height = (_kCanvasHeight * html.window.devicePixelRatio).round();
|
_canvas.height = (_kCanvasHeight * html.window.devicePixelRatio).round();
|
||||||
_canvas.style
|
_canvas.style
|
||||||
@ -211,13 +211,13 @@ class TimeseriesVisualization {
|
|||||||
static const double _kCanvasHeight = 200;
|
static const double _kCanvasHeight = 200;
|
||||||
|
|
||||||
final Timeseries _timeseries;
|
final Timeseries _timeseries;
|
||||||
TimeseriesStats _stats;
|
late TimeseriesStats _stats;
|
||||||
html.CanvasElement _canvas;
|
late html.CanvasElement _canvas;
|
||||||
html.CanvasRenderingContext2D _ctx;
|
late html.CanvasRenderingContext2D _ctx;
|
||||||
int _screenWidth;
|
late int _screenWidth;
|
||||||
|
|
||||||
// Used to normalize benchmark values to chart height.
|
// Used to normalize benchmark values to chart height.
|
||||||
double _maxValueChartRange;
|
late double _maxValueChartRange;
|
||||||
|
|
||||||
/// Converts a sample value to vertical canvas coordinates.
|
/// 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
|
/// This happens when you run benchmarks using plain `flutter run` rather than
|
||||||
/// devicelab test harness. The test harness spins up a special server that
|
/// devicelab test harness. The test harness spins up a special server that
|
||||||
/// provides API for automatically picking the next benchmark to run.
|
/// 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.
|
/// Asks the local server for the name of the next benchmark to run.
|
||||||
///
|
///
|
||||||
@ -323,7 +323,7 @@ class LocalBenchmarkServerClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
isInManualMode = false;
|
isInManualMode = false;
|
||||||
return request.responseText;
|
return request.responseText!;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _checkNotManualMode() {
|
void _checkNotManualMode() {
|
||||||
@ -405,11 +405,11 @@ class LocalBenchmarkServerClient {
|
|||||||
/// crash on 404, which we use to detect `flutter run`.
|
/// crash on 404, which we use to detect `flutter run`.
|
||||||
Future<html.HttpRequest> _requestXhr(
|
Future<html.HttpRequest> _requestXhr(
|
||||||
String url, {
|
String url, {
|
||||||
String method,
|
String? method,
|
||||||
bool withCredentials,
|
bool? withCredentials,
|
||||||
String responseType,
|
String? responseType,
|
||||||
String mimeType,
|
String? mimeType,
|
||||||
Map<String, String> requestHeaders,
|
Map<String, String>? requestHeaders,
|
||||||
dynamic sendData,
|
dynamic sendData,
|
||||||
}) {
|
}) {
|
||||||
final Completer<html.HttpRequest> completer = Completer<html.HttpRequest>();
|
final Completer<html.HttpRequest> completer = Completer<html.HttpRequest>();
|
||||||
|
@ -2,7 +2,7 @@ name: macrobenchmarks
|
|||||||
description: Performance benchmarks using flutter drive.
|
description: Performance benchmarks using flutter drive.
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=2.2.2 <3.0.0"
|
sdk: ">=2.12.0 <3.0.0"
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
flutter:
|
flutter:
|
||||||
|
@ -74,7 +74,7 @@ void main() {
|
|||||||
frameCount = 0;
|
frameCount = 0;
|
||||||
delays = await tester.handlePointerEventRecord(records);
|
delays = await tester.handlePointerEventRecord(records);
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
binding.reportData['fullyLive'] = _summarizeResult(frameCount, delays);
|
binding.reportData!['fullyLive'] = _summarizeResult(frameCount, delays);
|
||||||
await tester.idle();
|
await tester.idle();
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
@ -13,10 +13,10 @@ typedef ControlCallback = Future<void> Function(WidgetController controller);
|
|||||||
void macroPerfTestE2E(
|
void macroPerfTestE2E(
|
||||||
String testName,
|
String testName,
|
||||||
String routeName, {
|
String routeName, {
|
||||||
Duration pageDelay,
|
Duration? pageDelay,
|
||||||
Duration duration = const Duration(seconds: 3),
|
Duration duration = const Duration(seconds: 3),
|
||||||
ControlCallback body,
|
ControlCallback? body,
|
||||||
ControlCallback setup,
|
ControlCallback? setup,
|
||||||
}) {
|
}) {
|
||||||
final WidgetsBinding _binding = IntegrationTestWidgetsFlutterBinding.ensureInitialized();
|
final WidgetsBinding _binding = IntegrationTestWidgetsFlutterBinding.ensureInitialized();
|
||||||
assert(_binding is IntegrationTestWidgetsFlutterBinding);
|
assert(_binding is IntegrationTestWidgetsFlutterBinding);
|
||||||
|
@ -15,7 +15,7 @@ import 'package:macrobenchmarks/src/animated_image.dart';
|
|||||||
/// set number of image frames to render.
|
/// set number of image frames to render.
|
||||||
Future<void> main() async {
|
Future<void> main() async {
|
||||||
final Completer<void> waiter = Completer<void>();
|
final Completer<void> waiter = Completer<void>();
|
||||||
enableFlutterDriverExtension(handler: (String request) async {
|
enableFlutterDriverExtension(handler: (String? request) async {
|
||||||
if (request != 'waitForAnimation') {
|
if (request != 'waitForAnimation') {
|
||||||
throw UnsupportedError('Unrecognized request $request');
|
throw UnsupportedError('Unrecognized request $request');
|
||||||
}
|
}
|
||||||
|
@ -5,9 +5,9 @@
|
|||||||
import 'package:integration_test/integration_test_driver.dart' as driver;
|
import 'package:integration_test/integration_test_driver.dart' as driver;
|
||||||
|
|
||||||
Future<void> main() => driver.integrationDriver(
|
Future<void> main() => driver.integrationDriver(
|
||||||
responseDataCallback: (Map<String, dynamic> data) async {
|
responseDataCallback: (Map<String, dynamic>? data) async {
|
||||||
await driver.writeResponseData(
|
await driver.writeResponseData(
|
||||||
data['performance'] as Map<String, dynamic>,
|
data?['performance'] as Map<String, dynamic>,
|
||||||
testOutputFilename: 'e2e_perf_summary',
|
testOutputFilename: 'e2e_perf_summary',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -7,11 +7,11 @@ import 'dart:io';
|
|||||||
import 'package:integration_test/integration_test_driver.dart' as driver;
|
import 'package:integration_test/integration_test_driver.dart' as driver;
|
||||||
|
|
||||||
Future<void> main() => driver.integrationDriver(
|
Future<void> main() => driver.integrationDriver(
|
||||||
responseDataCallback: (Map<String, dynamic> data) async {
|
responseDataCallback: (Map<String, dynamic>? data) async {
|
||||||
final Map<String, dynamic> benchmarkLiveResult =
|
final Map<String, dynamic> benchmarkLiveResult =
|
||||||
data['benchmarkLive'] as Map<String,dynamic>;
|
data?['benchmarkLive'] as Map<String,dynamic>;
|
||||||
final Map<String, dynamic> fullyLiveResult =
|
final Map<String, dynamic> fullyLiveResult =
|
||||||
data['fullyLive'] as Map<String,dynamic>;
|
data?['fullyLive'] as Map<String,dynamic>;
|
||||||
|
|
||||||
if(benchmarkLiveResult['frame_count'] as int < 10
|
if(benchmarkLiveResult['frame_count'] as int < 10
|
||||||
|| fullyLiveResult['frame_count'] as int < 10) {
|
|| fullyLiveResult['frame_count'] as int < 10) {
|
||||||
|
@ -11,7 +11,7 @@ import 'package:macrobenchmarks/common.dart';
|
|||||||
import 'package:macrobenchmarks/main.dart';
|
import 'package:macrobenchmarks/main.dart';
|
||||||
|
|
||||||
Future<void> main() async {
|
Future<void> main() async {
|
||||||
enableFlutterDriverExtension(handler: (String message) async {
|
enableFlutterDriverExtension(handler: (String? message) async {
|
||||||
if (message == 'getTargetPlatform') {
|
if (message == 'getTargetPlatform') {
|
||||||
return defaultTargetPlatform.toString();
|
return defaultTargetPlatform.toString();
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ Future<void> main() async {
|
|||||||
|
|
||||||
final String targetPlatform = await driver.requestData('getTargetPlatform');
|
final String targetPlatform = await driver.requestData('getTargetPlatform');
|
||||||
|
|
||||||
Timeline timeline;
|
Timeline? timeline;
|
||||||
switch (targetPlatform) {
|
switch (targetPlatform) {
|
||||||
case 'TargetPlatform.iOS':
|
case 'TargetPlatform.iOS':
|
||||||
{
|
{
|
||||||
|
@ -16,7 +16,7 @@ const JsonEncoder _prettyEncoder = JsonEncoder.withIndent(' ');
|
|||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
test('stack_size', () async {
|
test('stack_size', () async {
|
||||||
int stackSizeInBytes;
|
late int stackSizeInBytes;
|
||||||
await runDriverTestForRoute(kStackSizeRouteName, (FlutterDriver driver) async {
|
await runDriverTestForRoute(kStackSizeRouteName, (FlutterDriver driver) async {
|
||||||
final String stackSize = await driver.getText(find.byValueKey(kStackSizeKey));
|
final String stackSize = await driver.getText(find.byValueKey(kStackSizeKey));
|
||||||
expect(stackSize.isNotEmpty, isTrue);
|
expect(stackSize.isNotEmpty, isTrue);
|
||||||
|
@ -34,13 +34,13 @@ Future<void> runDriverTestForRoute(String routeName, DriverTestCallBack body) as
|
|||||||
void macroPerfTest(
|
void macroPerfTest(
|
||||||
String testName,
|
String testName,
|
||||||
String routeName, {
|
String routeName, {
|
||||||
Duration pageDelay,
|
Duration? pageDelay,
|
||||||
Duration duration = const Duration(seconds: 3),
|
Duration duration = const Duration(seconds: 3),
|
||||||
Future<void> Function(FlutterDriver driver) driverOps,
|
Future<void> Function(FlutterDriver driver)? driverOps,
|
||||||
Future<void> Function(FlutterDriver driver) setupOps,
|
Future<void> Function(FlutterDriver driver)? setupOps,
|
||||||
}) {
|
}) {
|
||||||
test(testName, () async {
|
test(testName, () async {
|
||||||
Timeline timeline;
|
late Timeline timeline;
|
||||||
await runDriverTestForRoute(routeName, (FlutterDriver driver) async {
|
await runDriverTestForRoute(routeName, (FlutterDriver driver) async {
|
||||||
if (pageDelay != null) {
|
if (pageDelay != null) {
|
||||||
// Wait for the page to load
|
// Wait for the page to load
|
||||||
@ -48,7 +48,7 @@ void macroPerfTest(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (setupOps != null) {
|
if (setupOps != null) {
|
||||||
await setupOps(driver);
|
await setupOps(driver);
|
||||||
}
|
}
|
||||||
|
|
||||||
timeline = await driver.traceAction(() async {
|
timeline = await driver.traceAction(() async {
|
||||||
|
@ -10,8 +10,8 @@ import 'package:macrobenchmarks/main.dart';
|
|||||||
|
|
||||||
Future<void> endOfAnimation() async {
|
Future<void> endOfAnimation() async {
|
||||||
do {
|
do {
|
||||||
await SchedulerBinding.instance.endOfFrame;
|
await SchedulerBinding.instance!.endOfFrame;
|
||||||
} while (SchedulerBinding.instance.hasScheduledFrame);
|
} while (SchedulerBinding.instance!.hasScheduledFrame);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> main() async {
|
Future<void> main() async {
|
||||||
|
@ -10,8 +10,8 @@ import 'package:macrobenchmarks/main.dart';
|
|||||||
|
|
||||||
Future<void> endOfAnimation() async {
|
Future<void> endOfAnimation() async {
|
||||||
do {
|
do {
|
||||||
await SchedulerBinding.instance.endOfFrame;
|
await SchedulerBinding.instance!.endOfFrame;
|
||||||
} while (SchedulerBinding.instance.hasScheduledFrame);
|
} while (SchedulerBinding.instance!.hasScheduledFrame);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> main() async {
|
Future<void> main() async {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user