OpenFlutter / flutter_screenutil

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

Fix initializing with Size(0, 0). closes #350, closes #348, closes #347 #352

Closed Mounir-Bouaiche closed 2 years ago

Mounir-Bouaiche commented 2 years ago

@lizhuoyuan , Only in Production Mode, Flutter starts quicker and the native platform reports the actual resolution in a certain delai. This update only wait for the real resolution. Hope this closes #350 , closes #348 , closes #347 , closes #341

BrunoJurkovic commented 2 years ago

If this is a superior method of initialization, why only use it in release mode?

Mounir-Bouaiche commented 2 years ago

@BrunoJurkovic It is not necessary to use it only in release mode (I didn't provide or assert that option in the library itself), but, it is unnecessary to ensure that window is already initialized since it tooks only a few milliseconds to ensure and in debug mode app can take at least 200 milliseconds to run so the size must be and for sure initialized with the correct size, and sometimes takes double time to rebuild materialapp, so you couldn't face this problem in debug mode or in a low end device like an emulator. I don't want to interrupt the app with function that does nothing useful in debug mode.

Mounir-Bouaiche commented 2 years ago

@BrunoJurkovic @lizhuoyuan Checkout the new optimized solution

lizhuoyuan commented 2 years ago

Thanks, I will find time to debug and merge them

Mounir-Bouaiche commented 2 years ago

Hello friend, are you planning to publish updates in pub.dev next days ?

lizhuoyuan commented 2 years ago

Thank you very much for your contribution, and I have noticed that you often answer questions, thank you very much. I can't respond to other people in a timely manner, you are important.
ty!

Mounir-Bouaiche commented 2 years ago

@lizhuoyuan Don't mention that please, we are dev family after all. But I must say that last two commits are terrible and very bad, they can reproduce this last bug (initializing with zeros). There will be a fix by the end of next week of the last error (getting informations from buildcontext after a defunct which produces null cast error).