La Pyae
La Pyae

Reputation: 509

Want to set same size in different font system style for flutter

I want to set same size for different font system in flutter. How to set with this? With the Unicode system all the font is fine in app but with other system font (Example, wrong font format from backend.) the font size is too big that set in code and app UI alignment is so ugly. How to do that problem?

Container(
            width: ScreenSizeConfig.screenWidth / 1.115,
            child: Text(
              nameFromAPI,
              textAlign: TextAlign.center,
              style: kTitleTextStyle(
                size: 24,
              ).copyWith(
                wordSpacing: 3,
              ),
            ),

This photo is with the correct unicode font.enter image description here

........

In this photo, with wrong format fonts, UI misalign badly.enter image description here

Upvotes: 0

Views: 543

Answers (2)

La Pyae
La Pyae

Reputation: 509

Container(
            width: ScreenSizeConfig.screenWidth / 1.115,
            height: 35,
            child: Center(
              child: FittedBox(
                child: Text(
                  agentName,
                  textAlign: TextAlign.center,
                  maxLines: 1,
                  style: kTitleTextStyle(
                    size: 24,
                  ).copyWith(
                    wordSpacing: 3,
                  ),
                ),
              ),
            ),
          ),

Giving Height to the Container solve this problem.

Upvotes: 1

amit.flutter
amit.flutter

Reputation: 1111

You can wrap text widget to Fitted box to fit in fix size

FittedBox(
   child: Text(
      "Some Text Here. More. More. More. More. More. More. More. More. ",
       maxLines: 1)
)

Upvotes: 0

Related Questions