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

Time:08-05

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

CodePudding user response:

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.

CodePudding user response:

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)
)
  • Related