OpenFlutter / flutter_screenutil

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

Pushed pages recreates from a scratch instead of just resize #473

Closed nadrolinux closed 1 year ago

nadrolinux commented 1 year ago

Hi, When you push some page/widget on the navigation stack with: Navigator.of(context).push and manually resize a main window on the desktop you can see that a page/widget on the top of the stack is continiously recreated from a scratch (constructor is called instead of just build method like with LayoutBuilder). Both stateful and stateless widgets are affected. This is a serious bug, especially on the desktop, makes this really good lib totally useless on the desktop platforms, because all fields like a handles to a logic components are broken after a window resize. I attached quick example. main.txt

BTW. At first glance it looks like this issue is related to a combination of flutter_screenutil + MaterialPageRoute, but I'm not 100% sure (I'm really new with Flutter). If yes, is it possible to solve this issue from a library level? Best regards,

nadrolinux commented 1 year ago

It looks like this is not a big issue as I though. Just MaterialPageRoute builder is called at window resize. We can apply simple workaround for that - passing values by arguments instead of creating them inside a widget. However, maybe it will be good to avoid MPR builder recalls somehow?

lizhuoyuan commented 1 year ago

I will test the effect on the desktop platform

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.