Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LateInitializationError: Field '_minTextAdapt@941084504' has not been initialized. #545

Closed
mohamed-seiam opened this issue Jan 19, 2024 · 11 comments

Comments

@mohamed-seiam
Copy link

i have this error suddenly when i run new application

@Dhruvrajsinh7Span
Copy link

I am having same issue did you find any solution

Copy link

github-actions bot commented Mar 7, 2024

This issue is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale label Mar 7, 2024
@abdifitahabdulkadir
Copy link

I have same issue now this time while I am using this package for mobile dev responsive ui and I wondered why so far no one solved. waiting to be solve but dont know how long wiill that take

@github-actions github-actions bot removed the stale label Mar 8, 2024
@omar-khaium
Copy link

Same issue

@DAMHONGDUC
Copy link

DAMHONGDUC commented Mar 13, 2024

you guys have to wrap your MaterialApp with ScreenUtilInit, follow the docs:

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    //Set the fit size (Find your UI design, look at the dimensions of the device screen and fill it in,unit in dp)
    return ScreenUtilInit(
      designSize: const Size(360, 690),
      minTextAdapt: true,
      splitScreenMode: true,
      // Use builder only if you need to use library outside ScreenUtilInit context
      builder: (_ , child) {
        return MaterialApp(
          debugShowCheckedModeBanner: false,
          title: 'First Method',
          // You can use the library anywhere in the app even in theme
          theme: ThemeData(
            primarySwatch: Colors.blue,
            textTheme: Typography.englishLike2018.apply(fontSizeFactor: 1.sp),
          ),
          home: child,
        );
      },
      child: const HomePage(title: 'First Method'),
    );
  }
}

@Aditya7738
Copy link

Aditya7738 commented Apr 3, 2024

I got solution. Here is my code,
@override Widget build(BuildContext context) { return ScreenUtilInit( designSize: Size(MediaQuery.of(context).size.width, MediaQuery.of(context).size.height), minTextAdapt: true, splitScreenMode: true, child: MaterialApp( title: Constants.app_name, builder: (context, child) { ScreenUtil.init(context); return Theme( child: Home(), data: ThemeData( textTheme: TextTheme( headline1: TextStyle( fontWeight: FontWeight.bold, fontSize: 11.sp, )), )); }, debugShowCheckedModeBanner: false, ), ); }

Copy link

github-actions bot commented May 4, 2024

This issue is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale label May 4, 2024
@muhamedsaber
Copy link

i got the same error

@muhamedsaber
Copy link

The MaterialApp should be returned From the ScreenUtilInit builder not as a child --
ScreenUtilInit(
designSize: const Size(360, 690),
minTextAdapt: true,
splitScreenMode: true,
builder: (_, child) {
return MaterialApp(
debugShowCheckedModeBanner: false,
theme: isDarkMode ? darkThemeManager : lightThemeManager,
onGenerateRoute: onGenerateRoute,
);
});

@github-actions github-actions bot removed the stale label May 8, 2024
@michaelfeb
Copy link

have same issue

@Mounir-Bouaiche
Copy link
Collaborator

Mounir-Bouaiche commented May 30, 2024

You must use ScreenUtilInit widget on top of your widget. If they are on the same level, use builder.

Example when use child:

WidgetA(
  child: ScreenUtilInit(
    child: WidgetB(),
  ),
)

class WidgetB extends State..Widget {
  @override
  build(context) {
    return Text('', fontSize: 18.sp),
  }
}

Example when use builder:

WidgetA(
  child: ScreenUtilInit(
    builder: (_, __) {
      return Text('', fontSize: 18.sp);
    },
  ),
)

Example when use both:

WidgetA(
  child: ScreenUtilInit(
    builder: (_, child) {
      return Container(
        width: .2.sw,
        child: child,
      );
    },
    // Use child so WidgetB not get built every time .2.sw change
    child: WidgetB(),
  ),
)

@Mounir-Bouaiche Mounir-Bouaiche closed this as not planned Won't fix, can't repro, duplicate, stale May 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants