Large text in tab is not showing completely Flutter

367

Solution 1

I solved it, instead of using text attribute I used

child: Text(
  "Countdown Timer",
  textAlign: TextAlign.center,
),

Adding textAlign to it solved my problem

Solution 2

Add labelPadding or make the tabs scrollable using isScrollable

TabBar(
  isScrollable: true,
  labelPadding: EdgeInsets.symmetric(horizontal: 10.0),
  tabs: [
Tab(
  text: "Clock",
  icon: Icon(Icons.access_time),
),
Tab(
  text: "Alarm",
  icon: Icon(Icons.access_alarm),
),
Tab(
  text: "Stopwatch",
  icon: Icon(Icons.av_timer),
),
Tab(
  text: "Countdown Timer",
  icon: Icon(Icons.timer_rounded),
)
],),

Solution 3

put Tab Text into Expanded widget

child:Expaned(
child : Text(
  "Countdown Timer",
  textAlign: TextAlign.center,
)),
Share:
367
Junaid Khalid
Author by

Junaid Khalid

I am a CS graduate and passionate about learning

Updated on December 30, 2022

Comments

  • Junaid Khalid
    Junaid Khalid over 1 year

    I am working on a Flutter project that requires tabs, but one of the tab name is large, the name is not showing completely, as demonstrated in picture, How can I resolve this issue, I want the TabBar text to be multiline, I am new to Flutter so any help will be appreciated.

    Current tab situation

    Here is the code

    TabBar(
      tabs: [
        Tab(
          text: "Clock",
          icon: Icon(Icons.access_time),
        ),
        Tab(
          text: "Alarm",
          icon: Icon(Icons.access_alarm),
        ),
        Tab(
          text: "Stopwatch",
          icon: Icon(Icons.av_timer),
        ),
        Tab(
          text: "Countdown Timer",
          icon: Icon(Icons.timer_rounded),
        )
      ],
    ),
    
    • Mahi
      Mahi over 2 years
      show the code a little bit. you can use \n for next line.
    • Mahi
      Mahi over 2 years
      Text( maxlines:2
    • Rohith Nambiar
      Rohith Nambiar over 2 years
      As only one letter is hidden, you can decrease the font size
    • Junaid Khalid
      Junaid Khalid over 2 years
      @Mahi I am not using Text widget, secondly after \n the text allignment does not remain centered
    • Mahi
      Mahi over 2 years
      okay. whatever it is.. you have solved it. good.
    • Junaid Khalid
      Junaid Khalid over 2 years
      Thank You very much, Your comment did gave me the Idea
  • Shahriar Siraj Snigdho
    Shahriar Siraj Snigdho almost 2 years
    This should be voted as the correct answer. Thanks mate!