OpenFlutter / flutter_screenutil

Flutter screen adaptation, font adaptation, get screen information
https://pub.dartlang.org/packages/flutter_screenutil
Apache License 2.0
3.85k stars 486 forks source link

Web 初始化的时候 await ScreenUtil.ensureScreenSize(); 会一直递归 #488

Closed YOrange834 closed 1 year ago

YOrange834 commented 1 year ago

void main() async { // Add this line await ScreenUtil.ensureScreenSize(); runApp(MyApp()); }

如果是Web的话他会一直递归 static Future ensureScreenSize([ FlutterView? window, Duration duration = const Duration(milliseconds: 10), ]) async { final binding = WidgetsFlutterBinding.ensureInitialized(); window ??= binding.window;

if (window.physicalGeometry.isEmpty) {
  return Future.delayed(duration, () async {
    binding.deferFirstFrame();
    await ensureScreenSize(window, duration);
    return binding.allowFirstFrame();
  });
}

}

lizhuoyuan commented 1 year ago

await ScreenUtil.ensureScreenSize(); 这个现在可以删掉了 你删掉试试有没有影响

YOrange834 commented 1 year ago

还是有影响,首次安装app的时候可以获取到尺寸,但是二次打开的时候获取不到尺寸

YOrange834 commented 1 year ago

Web是正常的,安卓端会出现这个问题, iOS还没有测试

lizhuoyuan commented 1 year ago

不应当啊 , 我示例运行了好多次 没发现这个问题

github-actions[bot] commented 1 year ago

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] commented 1 year ago

This issue was closed because it has been inactive for 14 days since being marked as stale.