Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit 2e8bebd

Browse files
authored
Remove single window assumption from macrobenchmark (#119368)
1 parent 3f95bef commit 2e8bebd

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

dev/benchmarks/macrobenchmarks/lib/src/clipper_cache.dart

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,6 @@ class _ClipperCachePageState extends State<ClipperCachePage>
2323
@override
2424
void initState() {
2525
super.initState();
26-
const double itemHeight = 140;
27-
_topMargin = (window.physicalSize.height / window.devicePixelRatio - itemHeight * 3) / 2;
28-
if (_topMargin < 0) {
29-
_topMargin = 0;
30-
}
3126
_controller.addListener(() {
3227
if (_controller.offset < 10) {
3328
_controller.animateTo(_animateOffset, duration: const Duration(milliseconds: 1000), curve: Curves.ease);
@@ -40,6 +35,18 @@ class _ClipperCachePageState extends State<ClipperCachePage>
4035
});
4136
}
4237

38+
@override
39+
void didChangeDependencies() {
40+
super.didChangeDependencies();
41+
42+
const double itemHeight = 140;
43+
final FlutterView view = View.of(context);
44+
_topMargin = (view.physicalSize.height / view.devicePixelRatio - itemHeight * 3) / 2;
45+
if (_topMargin < 0) {
46+
_topMargin = 0;
47+
}
48+
}
49+
4350
@override
4451
Widget build(BuildContext context) {
4552
return Scaffold(

0 commit comments

Comments
 (0)