Reputation: 187
I have a page called FirstScreen.dart
SafeArea(
child: Scaffold(
key: _scaffoldKey,
body: PageView(
controller: _pageController,
children: [
HomeScreen(controller: _pageController),
PrenotationScreen(),
AccountScreen(),
NotificationScreen()
],
physics: NeverScrollableScrollPhysics(),
),
bottomNavigationBar: BottomNavigationBar(
onTap: _onItemTapped,
currentIndex: _selectedIndex,
elevation: 0,
selectedItemColor: kBlackColor,
backgroundColor: kGoldColor,
type: BottomNavigationBarType.fixed,
iconSize: 26,
items: [...]
Inside the HomeScreen, I have a button with this function:
onPressed: () {
controller.jumpToPage(1);
},
When I click, the function is performed correctly, but does not color the tab.
Change the page but does not color the new current tab
Upvotes: 0
Views: 63
Reputation: 3235
You have to add a onPageChanged
callback to your PageView
.
Like this:
PageView(
...
onPageChanged: (int index)=>setState(()=>_selectedIndex = index),
...
),
Upvotes: 1