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

Text is not showing in release mode #593

Open
ShafiMunshi opened this issue Dec 3, 2024 · 5 comments
Open

Text is not showing in release mode #593

ShafiMunshi opened this issue Dec 3, 2024 · 5 comments

Comments

@ShafiMunshi
Copy link

ShafiMunshi commented Dec 3, 2024

For getting adaptive text by depending on screen size, I used (.sp) in TextStyle in TextTheme. Using (.sp) inside text theme data , app works fine. But the issue occured when I tried to run it in release or profile mode. No text were showing in screen. Then i had to refine the textheme and remove all the (.sp).

From

  static TextTheme lightTextTheme = TextTheme(
    displayLarge: TextStyle(
      fontSize: 30.sp, 
      fontWeight: FontWeight.w600,
      color: AppColors.black, 
    ),
    displayMedium: TextStyle(
      fontWeight: FontWeight.w500, 
      fontSize: 25.sp, 
      color: AppColors.secondaryColor, 
    ),

To

  static TextTheme lightTextTheme = TextTheme(
    displayLarge: TextStyle(
      fontSize: 30, 
      fontWeight: FontWeight.w600, 
      color: AppColors.black, 
    ),
    displayMedium: TextStyle(
      fontWeight: FontWeight.w500,
      fontSize: 25, 
      color: AppColors.secondaryColor, 
    ), 
@paulcardno
Copy link

I have the same issue
only happens in release mode and not for all Phones. I have run on 4 phones (2 android and 2 iphones) only one had the issue and only in release mode and not completely consistently there either.
Sometimes when I started the app on the phone with the issue, it looked fine but then when I put it as into the background and brought it to foreground I had the issue.

Looks like the .sp value is returning zero for the text size.

this is my yaml entry flutter_screenutil: ^5.9.3
not sure the iOS version of the phone (its my partners phone) but can find out if need be.

@ShafiMunshi
Copy link
Author

I have the same issue only happens in release mode and not for all Phones. I have run on 4 phones (2 android and 2 iphones) only one had the issue and only in release mode and not completely consistently there either. Sometimes when I started the app on the phone with the issue, it looked fine but then when I put it as into the background and brought it to foreground I had the issue.

Looks like the .sp value is returning zero for the text size.

this is my yaml entry flutter_screenutil: ^5.9.3 not sure the iOS version of the phone (its my partners phone) but can find out if need be.

how did you fix that?

@paulcardno
Copy link

sorry didn't fix it, need to borrow the phone back and have another go. I centralized all my font sizes so only have one place to change from using .sp, I will focus back on it next week when I can get my hands on the phone.

here is my centralization code,
class FontSizes {
static double largeTitle36 = 36.sp;
static double largeTitle32 = 32.sp;
static double largeTitle30 = 30.sp;
static double title24 = 24.sp;
static double heading20 = 20.sp;
static double body20 = 20.sp;
static double caption12 = 12.sp;
// static double largeTitle36 = 36;
// static double largeTitle32 = 32;
// static double largeTitle30 = 30;
// static double title24 = 24;
// static double heading20 = 20;
// static double body20 = 20;
// static double caption12 = 12;
}

@paulcardno
Copy link

ok I might have found a solution, I have tested this on two phones that had issues and its working. But be interested if it works for you @ShafiMunshi.

Basically I put in a delay at the start using future builder, not sure why it works but 100mSecs seems to make all the difference, haven't done a binary search to find out how much time it really needs but 100mSec is acceptable solution.

class MyApp extends StatelessWidget {
const MyApp({super.key});

Future initializeScreenUtil(BuildContext context) async {
// Wait for a short duration to ensure initialization is complete
await Future.delayed(const Duration(milliseconds: 100));
}

// This widget is the root of your application.
@OverRide
Widget build(BuildContext context) {
return FutureBuilder(
future: initializeScreenUtil(context),
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
// Show a loading indicator while waiting for initialization
return const CircularProgressIndicator();
} else {
return ScreenUtilInit(
designSize: const Size(414, 892), // Set the design size of your app, used for scaling
builder: (context, child) {
return MaterialApp(

@ShafiMunshi
Copy link
Author

ShafiMunshi commented Dec 6, 2024

ok I might have found a solution, I have tested this on two phones that had issues and its working. But be interested if it works for you @ShafiMunshi.

Basically I put in a delay at the start using future builder, not sure why it works but 100mSecs seems to make all the difference, haven't done a binary search to find out how much time it really needs but 100mSec is acceptable solution.

class MyApp extends StatelessWidget { const MyApp({super.key});

Future initializeScreenUtil(BuildContext context) async { // Wait for a short duration to ensure initialization is complete await Future.delayed(const Duration(milliseconds: 100)); }

// This widget is the root of your application. @OverRide Widget build(BuildContext context) { return FutureBuilder( future: initializeScreenUtil(context), builder: (context, snapshot) { if (snapshot.connectionState == ConnectionState.waiting) { // Show a loading indicator while waiting for initialization return const CircularProgressIndicator(); } else { return ScreenUtilInit( designSize: const Size(414, 892), // Set the design size of your app, used for scaling builder: (context, child) { return MaterialApp(

Thanks for your help. Your code works truly flawless.

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

2 participants