简体   繁体   English

尝试使用 flutter_screenutil package 和 Introduction_screen package 时,我在 flutter 中遇到延迟初始化错误

[英]I'm getting late initialization error in flutter when trying to use flutter_screenutil package with introduction_screen package

The late initialization error comes when I add.w, .h, .sp to double values like,当我将.w、.h、.sp 添加到双倍值时,会出现后期初始化错误,例如,

top: 16.h

or或者

right: 16.w

Here is the code https://drive.google.com/file/d/1yN2AqKF2LOMFYkX9PzsTVz_o5hktSY0D/view?usp=sharing这是代码https://drive.google.com/file/d/1yN2AqKF2LOMFYkX9PzsTVz_o5hktSY0D/view?usp=sharing

These are the packages which I have installed这些是我安装的软件包

dev_dependencies:
  flutter_test:
    sdk: flutter
  google_fonts: 2.1.0
  flutter_screenutil: ^5.0.0+2
  page_transition: ^2.0.4
  introduction_screen: ^2.1.0

You need to initialize the ScreenUtil class just like it was provided in the example page here您需要初始化 ScreenUtil class 就像在此处的示例页面中提供的一样

class _HomePageState extends State<HomePage> {


 @override
  Widget build(BuildContext context) {

     //You need to add this line to your code
    //Set the fit size (fill in the screen size of the device in the design) If the design is based on the size of the 360*690(dp)
    ScreenUtil.init(
        BoxConstraints(
            maxWidth: MediaQuery.of(context).size.width,
            maxHeight: MediaQuery.of(context).size.height),
        designSize: Size(360, 690),
        minTextAdapt: true,
        orientation: Orientation.portrait);
    return Scaffold();
  }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 Flutter 中使用 Introduction_screen package 获取 CurrentPage/CurrentState - Get CurrentPage/CurrentState with introduction_screen package in Flutter Flutter WiFi套件出现类型错误 - Getting type error with flutter wifi package flutter。 当我尝试运行此推荐“flutter build appbundle”时,出现此错误 - flutter . When I'm trying run this commend "flutter build appbundle" I get this error 实施Firebase(Flutter)通知时,出现错误 - When implementing Firebase (Flutter) notifications, I'm getting an error 与 Flutter 提供程序包相关的错误 - Error related to Flutter provider package Flutter:插入新权限后尝试启动应用程序时出错 package - Flutter: Error when trying to launch app after inserting new permissions package 如何修复“错误:Flutter 目录不是 GitHub 项目的克隆。” 尝试安装 flutter 时出错? - How do I fix the "Error: The Flutter directory is not a clone of the GitHub project." error when I'm trying to install flutter? 我正在尝试将 firebase 添加到我的 flutter 项目中,但我不断收到此错误找不到方法实现() - I'm trying to add firebase to my flutter project but i keep on getting this Error Could not find method implementation() 尝试在 Flutter 中使用 Animator 时出现编译错误 - Compile error when trying to use Animator in Flutter Flutter - 添加 import &#39;package:path/path.dart&#39; 时出错 - Flutter - I get error when i add import 'package:path/path.dart'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM