0

I am developing an app on Flutter, I have a Column which contains two Text Widgets in my Home Page. the problem is that on a mobile phone, the text size is normal, but on a tablet, the text is way too small to see. Could you please suggest a way to enlarge the text dynamically based on the screen size?

The Widget:

Column(
    children: [
      Text(
        widget.label,
        style: TextStyle(
            fontFamily: 'Roboto',
            color: Colors.white,
            fontWeight: FontWeight.bold),
      ),
      Text(
        widget.description,
        style: TextStyle(
            fontFamily: 'Roboto',
            color: Colors.white,
            fontWeight: FontWeight.w100),
      )
    ],
  ),

Thanks

2 Answers 2

1

This package here :

auto_size_text , https://pub.dev/packages/auto_size_text

Would help.

Sign up to request clarification or add additional context in comments.

Comments

0

you can have two approaches:

  1. use auto_size_text package
  2. use MediaQuery.of(context).size.width and MediaQuery.of(context).size.height to access width and height of screen, then use them to resize a SizedBox and pass your text as a FittedBox(child:YourTextWidget) to this widget. for example:
SizedBox(
width: 0.5 * screenWidth, // change 0.5 to whatever your want
child:FittedBox(
child: Text("Your Text")
))

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.