Closed StipT closed 1 year ago
Everything works and scales fine with debug build, but once I build the release version, font scaling doesn't work right. Has anyone come across this?
@override Widget build(BuildContext context) { return ScreenUtilInit( designSize: const Size(787, 375), builder: (BuildContext context, Widget? child) { return MaterialApp.router( localizationsDelegates: context.localizationDelegates, supportedLocales: context.supportedLocales, locale: context.locale, routerDelegate: _appRouter.delegate(), routeInformationParser: _appRouter.defaultRouteParser(), title: APP_NAME, debugShowCheckedModeBanner: false, theme: ThemeData( fontFamily: FontStyles.FONT_FAMILY, primaryColor: AppColors.vanDykeBrown, splashColor: AppColors.bistreBrown, colorScheme: ColorScheme.fromSwatch().copyWith(secondary: AppColors.gold), textSelectionTheme: const TextSelectionThemeData( cursorColor: AppColors.gold, ), ), ); }); }
class FontStyles { static const String FONT_FAMILY = "Belwe"; // Regular Belwe static TextStyle regular15 = TextStyle( fontFamily: FONT_FAMILY, fontWeight: FontWeight.w400, fontSize: 15.sp, color: AppColors.white, ); static TextStyle regular15Black = TextStyle( fontFamily: FONT_FAMILY, fontWeight: FontWeight.bold, fontSize: 15.sp, color: Colors.black, ); static TextStyle regular17 = TextStyle( fontFamily: FONT_FAMILY, fontWeight: FontWeight.w400, fontSize: 17.sp, color: AppColors.white, ); ... }
Do not use static This will be loaded before screenutil, at this time xx.sp is invalid
Everything works and scales fine with debug build, but once I build the release version, font scaling doesn't work right. Has anyone come across this?
Device: Pixel 3a android-arm64 • Android 13 (API 33) (emulator)
app-debug.apk
app-release.apk
ScreenUtilInit
Text styles used accross the app