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

混合开发模式,在flutter_boost 引入flutter_screeutil 用的是文档里写的第二种初始化, #446

Closed wumeixinjiazu closed 1 year ago

wumeixinjiazu commented 1 year ago

从原生跳Flutter页面第一次会黑屏几秒然后就正常看到页面 第二次之后都正常。。有什么解决方法嘛,初始化代码如下: void main() async{ ///这里的CustomFlutterBinding调用务必不可缺少,用于控制Boost状态的resume和pause MyFlutterBinding(); await ScreenUtil.ensureScreenSize(); runApp(const MyApp()); }

Widget appBuilder(Widget home) {

return MaterialApp(
  home: home,
  debugShowCheckedModeBanner: false,

  ///必须加上builder参数,否则showDialog等会出问题
  builder: (context, child) {
    ScreenUtil.init(context);
    return home;
  },
);

}

@override Widget build(BuildContext context) { return FlutterBoostApp( routeFactory, appBuilder: appBuilder, ); }

github-actions[bot] commented 1 year ago

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

lizhuoyuan commented 1 year ago

我没用过boost , 我觉得可以尝试用自己从原生传过来尺寸试试效果

tang5011235 commented 1 year ago

@override Widget build(BuildContext context) { ScreenUtil.init(context, designSize: const Size(375, 812)); return ListView( children:[ Text('sdfsdf',style:TextStyle(fontSize:16..w)) ])

报错
Looking up a deactivated widget's ancestor is unsafe. At this point the state of the widget's element tree is no longer stable. To safely refer to a widget's ancestor in its dispose() method, save a reference to the ancestor by calling dependOnInheritedWidgetOfExactType() in the widget's didChangeDependencies() method.

/// 当前设备宽度 dp /// The horizontal extent of this size. double get screenWidth => _context != null ? MediaQuery.of(_context!).size.width : _screenWidth;

context 出了问题 但是 不是listView 使用 SingleScroll + Colum 不会出错 一直没搞懂原因

tang5011235 commented 1 year ago

只有 第一次启动会出问题

tang5011235 commented 1 year ago

搞个一个插件 可以适用于 android平台 和 iOS平台 https://pub.flutter-io.cn/packages/screen_adapter

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.

kavin-zhihua commented 1 week ago

楼主解决了吗