ashish rajbanshi
ashish rajbanshi

Reputation: 55

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

Upvotes: 0

Views: 1297

Answers (2)

Mahesh Gv
Mahesh Gv

Reputation: 1103

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(),
    );
  }
}

Upvotes: 1

Md. Yeasin Sheikh
Md. Yeasin Sheikh

Reputation: 63809

The issue is here ScreenUtilInit builder require context and child

  builder: (context , child) { //this
Widget build(BuildContext context) {
  return ScreenUtilInit(
    builder: (context, child) {
      return MultiBlocProvider(
        providers: [],
        child: Text("AA"),
      );
    },
  );
}

Upvotes: 0

Related Questions