-
Notifications
You must be signed in to change notification settings - Fork 504
Description
版本:4.0.4+1以及其他4.0.X其他版本
错误:======== Exception caught by widgets library =======================================================
The following assertion was thrown building LayoutBuilder:
Ensure to initialize ScreenUtil before accessing it.
Please execute the init method : ScreenUtil.init()
'package:flutter_screenutil/screen_util.dart':
Failed assertion: line 34 pos 7: '_instance != null'
The relevant error-causing widget was:
OrientationBuilder file:///D:/tool/flutter-env/flutter_1.22.6/.pub-cache/hosted/pub.flutter-io.cn/flutter_screenutil-4.0.4+1/lib/screenutil_init.dart:25:14
When the exception was thrown, this was the stack:
#2 new ScreenUtil (package:flutter_screenutil/screen_util.dart:34:7)
#3 Base.dp (package:qniqni/common/base.dart:14:36)
#4 _StartPageState.build. (package:qniqni/page/init/start.dart:81:26)
#5 ScreenUtilInit.build.. (package:flutter_screenutil/screenutil_init.dart:35:25)
#6 OrientationBuilder._buildWithConstraints (package:flutter/src/widgets/orientation_builder.dart:52:19)
代码:
@OverRide
Widget build(BuildContext context) {
return ScreenUtilInit(
designSize: Base.size,
builder: () {
return Scaffold(
body: SizedBox(
width: MediaQuery.of(context).size.width, //获取屏幕宽度
child: Stack(
alignment: Alignment.center,
children: [
SizedBox(
width: dp(375),
child: Image.asset("assets/start.jpg"),
),
Positioned(
right: dp(40),
top: dp(40),
child: CountDown(),
),
],
),
),
);
},
);
}