Tinovimba Mawoyo
Tinovimba Mawoyo

Reputation: 410

Flutter | Text on top of bottom navigation bar screens

I have bottom navigation menu items where I successfully change through pages. I want to add a text widget to the top of the screens. as shown in below code

body: _kTabPages[_currentTabIndex],
bottomNavigationBar: bottomNavBar,

and then i changed it to this,

body: 
      Column(
        children: [
          Text('Hello Text'),
          _kTabPages[_currentTabIndex],
        ],
      ),
     
      bottomNavigationBar: bottomNavBar,

but now the pages are disappearing and i am only left with the text at the top, the navigation items at the bottom, and a blank white screen in the middle where the pages are supposed to go. With the error :

bottom overflowed by infinity pixels

Upvotes: 0

Views: 429

Answers (1)

Tinovimba Mawoyo
Tinovimba Mawoyo

Reputation: 410

From this i managed to find out the solution which is to wrap the screens by Expanded so my answer is now

body:
      Column(
        children: [
          Text('Hello Text'),
          Expanded(child: _kTabPages[_currentTabIndex]),
        ],
      ),

      bottomNavigationBar: bottomNavBar,

Upvotes: 1

Related Questions