[英]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.