🔥🔥🔥 Flutter common utils library. SpUtil, ScreenUtil,WidgetUtil. 也许是目前最好用的SharedPreferences工具类。WidgetUtil 获取图片尺寸宽高, View尺寸&在屏幕上的坐标。
你好,我使用ScreenUtil来作为产品的自适应方案。我希望在折叠屏设备折叠状态发生变化的时候,能自动更新页面UI元素尺寸。 当前情况: 使用如下方法,需要手动setState()或调用MediaQuery.of(context)才能实现。 ```dart /// 仅支持纵屏。 /// returns the size after adaptation according to the screen width.(unit dp or pt) /// 返回根据屏幕宽适配后尺寸(单位 dp or pt) /// size 单位 dp or pt double getWidth(double size) { return _screenWidth == 0.0 ? size : (size * _screenWidth / _designW); } /// 仅支持纵屏。 /// returns the size after adaptation according to the screen height.(unit dp or pt) /// 返回根据屏幕高适配后尺寸(单位 dp or pt) /// size unit dp or pt double getHeight(double size) { return _screenHeight == 0.0 ? size : (size * _screenHeight / _designH); } ``` 其中,ScreenUtil中的某些方法中,包含执行MediaQuery.of(context)逻辑,可以实现自动刷新 ```dart /// screen width /// 当前屏幕 宽 static double getScreenW(BuildContext context) { MediaQueryData mediaQuery = MediaQuery.of(context); return mediaQuery.size.width; } /// screen height /// 当前屏幕 高 static double getScreenH(BuildContext context) { MediaQueryData mediaQuery = MediaQuery.of(context); return mediaQuery.size.height; } ``` 请问第一种情况是否有办法解决,还是只能手动setState来实现自动更新?
This issue appears to be discussing a feature request or bug report related to the repository. Based on the content, it seems to be still under discussion. The issue was opened by Huanxin1997 and has received 0 comments.