Issue
The late initialization error comes when I add .w, .h, .sp to double values like,
top: 16.h
or
right: 16.w
Here is the code 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
Solution
You need to initialize the ScreenUtil class just like it was provided in the example page here
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();
}
}
Answered By - Becca
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.