Search code examples
flutterflutter-layoutflutter-dependencies

flutter_screenutil not working ,,,problem in builder


I am using flutter_screenutil: ^5.5.3+2 and build_runner: ^2.0.4 after running the build runner there is error in the builder of screenutlils

 here is the picture


Solution

  • use ScreenUtilInit like this
    
    @override
      Widget build(BuildContext context) {
        // In first method you only need to wrap [MaterialApp] with [ScreenUtilInit] and that's it
        return ScreenUtilInit(
          builder: (_, child) {
            return MaterialApp(
              debugShowCheckedModeBanner: false,
              title: 'Test',
              theme: ThemeData(
                primarySwatch: Colors.blue,
                textTheme: TextTheme(bodyText2: TextStyle(fontSize: 30.sp)),
              ),
              home: child,
            );
          },
          child: HomePage(),
        );
      }
    }