Как сделать так, чтобы текст в панели вкладок отображался в одной строке? - PullRequest
0 голосов
/ 01 августа 2020
• 1000 например enter image description here

So, i tried wrapping the texts in FittedBox widget but then the font size got reduced as seen in the above image. What i am trying to achieve is введите описание изображения здесь

  Widget build(BuildContext context) {
    return DefaultTabController(
      length: 7,
          child: Scaffold(
        appBar: AppBar(
          bottom: TabBar(
            tabs: [

              Tab(child: FittedBox(child: Text('HOME', style: TextStyle(color: Colors.black),)) ),
              Tab(child: Text('RESULTS', style: TextStyle(color: Colors.black),) ),
              Tab(child: Text('INTERNALS', style: TextStyle(color: Colors.black),) ),
              Tab(child: Text('NOTES', style: TextStyle(color: Colors.black),) ),
              Tab(child: Text('EVENTS', style: TextStyle(color: Colors.black),) ),
              Tab(child: Text('QUESTION PAPERS', style: TextStyle(color: Colors.black),) ),
              Tab(child: Text('JOBS', style: TextStyle(color: Colors.black),) )]),```

1 Ответ

2 голосов
/ 01 августа 2020

Как упоминалось в комментарии, вы можете добиться поведения TabBar, установив свойство isScrollable для TabBar на true.

Разместив его как ответ здесь, чтобы другие могут видеть:

Я добавил пример, используя ваше дерево виджетов:

 Widget build(BuildContext context) {
    return DefaultTabController(
      length: 7,
          child: Scaffold(
        appBar: AppBar(
          bottom: TabBar(
            isScrollable: true, // new line
            tabs: [

              Tab(child: FittedBox(child: Text('HOME', style: TextStyle(color: Colors.black),)) ),
              Tab(child: Text('RESULTS', style: TextStyle(color: Colors.black),) ),
              Tab(child: Text('INTERNALS', style: TextStyle(color: Colors.black),) ),
              Tab(child: Text('NOTES', style: TextStyle(color: Colors.black),) ),
              Tab(child: Text('EVENTS', style: TextStyle(color: Colors.black),) ),
              Tab(child: Text('QUESTION PAPERS', style: TextStyle(color: Colors.black),) ),
              Tab(child: Text('JOBS', style: TextStyle(color: Colors.black),) )]),
...