Skip to content

Text is not showing in release mode #593

Open

Description

@ShafiMunshi

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, 
    ), 

Activity

  1. paulcardno commented on Dec 5, 2024

    @paulcardno

    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.

  2. ShafiMunshi commented on Dec 5, 2024

    @ShafiMunshi
    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?

  3. paulcardno commented on Dec 5, 2024

    @paulcardno

    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;
    }

  4. paulcardno commented on Dec 6, 2024

    @paulcardno

    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(

  5. ShafiMunshi commented on Dec 6, 2024

    @ShafiMunshi
    Author

    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.

  6. Jewel105 commented on Dec 31, 2024

    @Jewel105

    Ensure that the screen size is initialized before running the app.

    // This is particularly useful for adapting UI layouts to different screen sizes.
    await ScreenUtil.ensureScreenSize();
    
    runApp(const MyApp());
    
    
  7. damooola commented on Aug 6, 2025

    @damooola

    Ensure that the screen size is initialized before running the app.

    // This is particularly useful for adapting UI layouts to different screen sizes.
    await ScreenUtil.ensureScreenSize();
    
    runApp(const MyApp());
    

    This works. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions