Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
wumeixinjiazu opened this issue Dec 28, 2022 · 7 comments
Labels

Comments

@wumeixinjiazu
Copy link

wumeixinjiazu commented Dec 28, 2022

从原生跳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
Copy link

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

@github-actions github-actions bot added the stale label Jan 28, 2023
@lizhuoyuan
Copy link
Collaborator

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

@tang5011235
Copy link

@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
Copy link

只有 第一次启动会出问题

@github-actions github-actions bot removed the stale label Jan 31, 2023
@tang5011235
Copy link

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

@github-actions
Copy link

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

@github-actions github-actions bot added the stale label Mar 17, 2023
@github-actions
Copy link

github-actions bot commented Apr 1, 2023

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

@github-actions github-actions bot closed this as completed Apr 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants