diff --git a/dev/benchmarks/macrobenchmarks/lib/src/clipper_cache.dart b/dev/benchmarks/macrobenchmarks/lib/src/clipper_cache.dart index 85098ef34cb..0db2c02021c 100644 --- a/dev/benchmarks/macrobenchmarks/lib/src/clipper_cache.dart +++ b/dev/benchmarks/macrobenchmarks/lib/src/clipper_cache.dart @@ -23,11 +23,6 @@ class _ClipperCachePageState extends State @override void initState() { super.initState(); - const double itemHeight = 140; - _topMargin = (window.physicalSize.height / window.devicePixelRatio - itemHeight * 3) / 2; - if (_topMargin < 0) { - _topMargin = 0; - } _controller.addListener(() { if (_controller.offset < 10) { _controller.animateTo(_animateOffset, duration: const Duration(milliseconds: 1000), curve: Curves.ease); @@ -40,6 +35,18 @@ class _ClipperCachePageState extends State }); } + @override + void didChangeDependencies() { + super.didChangeDependencies(); + + const double itemHeight = 140; + final FlutterView view = View.of(context); + _topMargin = (view.physicalSize.height / view.devicePixelRatio - itemHeight * 3) / 2; + if (_topMargin < 0) { + _topMargin = 0; + } + } + @override Widget build(BuildContext context) { return Scaffold(