Errors are reported as follows
reason
We use screenutil().Screenwidth to obtain the screen width in the layout. When initializing the unloaded view, we can’t get it for the first time, and the above crash will occur.
Solution
import 'package:flutter_screenutil/screenutil_init.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
@override
Widget build(BuildContext context) {
//Wrap the entire body layout with screen initialization
return ScreenUtilInit(
//set initial screen size
designSize: Size(375, 812),
builder: () => Scaffold(
backgroundColor: WBColors.color_f4f5f7,
body: Container(
height: 263.5,
width: ScreenUtil().screenWidth,
)
)
);
}
Use the screenutilinit screen initialization component to wrap the outermost layer of the entire page layout and set the initial screen size. The API for obtaining screen width and height can be used arbitrarily in the body
Read More:
- error: (-215:Assertion failed) size.width>0 && size.height>0 in function ‘cv::imshow‘
- Solve the problem of incorrect display of dialogfragment width
- Android Phone Record Screen Error: failed to get surface
- [Solved] ERROR RocketmqCommon-Failed to obtain the host name
- failed to obtain in-memory shard lock [How to Solve]
- [Solved] Initialization error encountered by JUnit unit test: Method initialization error not found
- How to Solve Clickhouse restart error: Cannot obtain value of path from config file…
- [Solved] JRebel Error: ERROR Failed to obtain seat. Unable to connect to license server
- ADS1.2 Error: cannot obtain license [How to Solve]
- [Solved] Android9.0 App Install Android4.4 Error: InflateException-You must supply a layout_height attribute.
- [Solved] React Native Red screen Error: Unable to load script from assets
- Vue Error in callback for immediate watcher “height”: “TypeError: Cannot read property ‘style’ of
- [ERROR] Terminal initialization failed; falling back to unsupported java.lang.IncompatibleClassChang
- [Solved] Springcloud Add gateway to Startup Error: Exception encountered during context initialization – cancelling refresh
- Hbase Shell startup error: [ERROR] Terminal initialization failed; falling back to unsupported
- [Solved] Error: The slice reducer for key “auth“ returned undefined during initialization. If the state pas
- [Solved] ora 01033 linux,ORA-01033: ORACLE initialization or shutdown in progres
- Error occurred during initialization of VM Could not reserve enough space for 1572864KB object heap
- [Solved] Schema initialization FAILED Metastore state would be inconsistent
- K8s cluster initialization error: Port 6443 is in use [Solved]