flutter_screenutil icon indicating copy to clipboard operation
flutter_screenutil copied to clipboard

ScreenUtil doesnt adapt when running DevicePreview

Open xalikoutis opened this issue 2 years ago • 4 comments

Hi i am using version 5.5.3+2 with DevicePreview to run some tests, but doesnt work. Everything is a mess with large text and widget sizes. It used to work very well in previous versions. What am i doing wrong?

return DevicePreview(
        enabled: generalConfig.isTest,
        builder: (BuildContext context) {
          return ScreenUtilInit(
              minTextAdapt: true,
              designSize: Size(AppConstants.screenWidth, AppConstants.screenHeight),
              builder: (BuildContext context, Widget? child) {
                return ThemeSwitcherWidget(
                  initialTheme: themeConfig.defaultTheme,
                  child: OverlaySupport.global(
                    child: KeyboardDismisser(
                      child: CubitsProvider(
                        child: MaterialApp.router(
                          localizationsDelegates: GlobalMaterialLocalizations.delegates,
                          supportedLocales: <Locale>[
                            Locale(generalConfig.languageCode),
                          ],
                          useInheritedMediaQuery: true,
                          locale: DevicePreview.locale(context),
                          builder: DevicePreview.appBuilder,
                          theme: themeConfig.defaultTheme,
                          debugShowCheckedModeBanner: false,
                          routeInformationParser: appRouter.defaultRouteParser(),
                          routerDelegate: appRouter.delegate(initialRoutes: [LandingPageRoute()]),
                        ),
                      ),
                    ),
                  ),
                );
              });
        });

image

xalikoutis avatar Jun 02 '22 16:06 xalikoutis

Ver 5.0.4 using ScreenUtil.setContext(context) inside builder works

xalikoutis avatar Jun 06 '22 11:06 xalikoutis

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

github-actions[bot] avatar Jul 07 '22 02:07 github-actions[bot]

Ver 5.0.4 using ScreenUtil.setContext(context) inside builder works

Hello, try adding useInheritedMediaQuery: true in ScreenUtilInit params.

Mounir-Bouaiche avatar Jul 08 '22 12:07 Mounir-Bouaiche

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

github-actions[bot] avatar Aug 08 '22 02:08 github-actions[bot]

This issue was closed because it has been inactive for 14 days since being marked as stale.

github-actions[bot] avatar Aug 22 '22 02:08 github-actions[bot]