Skip to content

Setting minTextAdapt to true is not working? #603

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

Open
AbanobZakaria03 opened this issue Apr 29, 2025 · 0 comments
Open

Setting minTextAdapt to true is not working? #603

AbanobZakaria03 opened this issue Apr 29, 2025 · 0 comments

Comments

@AbanobZakaria03
Copy link

I'm using flutter_screenutil: ^5.9.3 and Flutter 3.29.3

After setting the minTextAdapt to true and used chrome for testing text adaption
the problem i'm facing is that when i set container with .r height and .r width (also if i specified .h and .w instead of .r), the text overflowed the container in big screens like laptop (1440x900)

After printing the scaling values, I found that the text always takes the highest scaling ratio, not the minimum between the height and width scaling

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return ScreenUtilInit(
      designSize: const Size(375, 812),
      minTextAdapt: true,
      builder: (_, child) {
        return MaterialApp(
          debugShowCheckedModeBanner: false,
          theme: ThemeData.light(),
          darkTheme: ThemeData.dark(),
          home: child,
        );
      },
      child: const HomePage3(),
    );
  }
}

Image

Image

and this is my HomePage3 code

class HomePage3 extends StatelessWidget {
  const HomePage3({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {

    print('width: ${1.sw}, scale width = ${1.sw / 375}');
    print('height: ${1.sh}, scale height = ${1.sh / 812}');
    print('text scale: ${1.sp}');

    return Scaffold(
      backgroundColor: Colors.white,
      body: Center(
          child: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          SizedBox(
            width: 52.r,
            height: 20.r,
            child: ElevatedButton(
              onPressed: () {},
              style: ElevatedButton.styleFrom(
                elevation: 0,
                padding: EdgeInsets.zero,
                backgroundColor: Colors.transparent,
                foregroundColor: const Color(0xFF121212),
                shape: RoundedRectangleBorder(
                  side: BorderSide(
                    color: const Color(0xFF2C262C),
                    width: 1.r,
                  ),
                  borderRadius: BorderRadius.circular(16.r),
                ),
              ),
              child: Text(
                'تفاصيل',
                style: TextStyle(
                  fontSize: 11.sp,
                  color: const Color(0xFF121212),
                  fontWeight: FontWeight.normal,
                ),
              ),
            ),
          ),
        ],
      )),
    );
  }
}

Am I missing something?

@AbanobZakaria03 AbanobZakaria03 changed the title setting minTextAdapt to true is not working? Setting minTextAdapt to true is not working? Apr 29, 2025
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

1 participant