OpenFlutter / flutter_screenutil

Flutter screen adaptation, font adaptation, get screen information
https://pub.dartlang.org/packages/flutter_screenutil
Apache License 2.0
3.85k stars 486 forks source link

Keyboard is not open on textfield (I am using this package with GoRouter) #506

Closed anilflutter closed 11 months ago

anilflutter commented 11 months ago

this package sued with GoRouter then I am getting issue while type on textfield. Keyboard doesn't open .

this issue is occurred if TextEditingController without static or global key without static as below given:

// this code give the error final GlobalKey _formKey = GlobalKey(); final TextEditingController mobileController = TextEditingController();

// solved error after add static, but this is not the good solution static final GlobalKey _formKey = GlobalKey(); static final TextEditingController mobileController = TextEditingController();

Mounir-Bouaiche commented 11 months ago

@anilflutter make sure you are not building routes inside ScreenUtilInit scope

anilflutter commented 11 months ago

But ScreenUtil is the parent widget above the MaterialApp. And GoRouter used with Materialapp as MaterialApp.GoRouter().

ScreenUtilInit( designSize: const Size(430, 932), builder: (BuildContext context, Widget? child) { return MaterialApp.router( debugShowCheckedModeBanner: false, theme: AppTheme.appThemeData(context), builder: EasyLoading.init(), routeInformationProvider: Routes.onRouter.routeInformationProvider, routeInformationParser: Routes.onRouter.routeInformationParser, routerDelegate: Routes.onRouter.routerDelegate, ); }, )

anilflutter commented 11 months ago

The issue is resolved after moving theme out of screen until scope ScreenUtilInit( designSize: const Size(430, 932), builder: (BuildContext context, Widget? child) { return child!; }, child: const MaterialRoute(), ),

abdullah432 commented 11 months ago

child

After applying your solution, I'm now getting this error

Another exception was thrown: LateInitializationError: Field '_minTextAdapt@3085084504' has not been
initialized.
anilgsharma900 commented 11 months ago

Using this solution, I am not getting any error and not even warning

ScreenUtilInit( designSize: const Size(430, 932), builder: (BuildContext context, Widget? child) { return child!; }, child: const MaterialRoute(), ),

anilgsharma900 commented 11 months ago

@abdullah432

Can you share the code where are you getting error?