Home > Enterprise >  For flutter best way for custom space between two text
For flutter best way for custom space between two text

Time:11-14

I am confuse about which is the best and right way for horizontal spacing between two text. I know \t, white space or some decoration can use for spacing. But I want to know exactly which is suitable way, because I want to rule standard rule and for large project. Please let me know.

I show example code that I use in my project and I used it usual but I think it is boring and not standard.

Padding(
              padding: const EdgeInsets.only(left: 50.0),
              child: Text(
                'Current Version\t\t\t:\t\t\t\t\t\t$appVersion',
                style: TextStyle(
                  fontSize: 18,
                  fontWeight: FontWeight.w500,
                ),
              ),
            ),

Image for space between Current version text and version number

As shown is figure, should I use \t or type manually space from keyboard that I want or two widget.

CodePudding user response:

You can get the UI using RichText

RichText(
    text: TextSpan(
  children: [
    TextSpan(text: "Current Version"),
    WidgetSpan(
        child: SizedBox(
      width: 20, // your of space
    )),
    TextSpan(text: ":"),
    WidgetSpan(
        child: SizedBox(
      width: 20, // your of space
    )),
    TextSpan(text: appVersion),
  ],
)),
  • Related