Created
January 10, 2020 13:05
-
-
Save guilhermecarvalhocarneiro/c927802a4969cb277760270dc98ccf44 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ... | |
class HomePage extends StatefulWidget { | |
@override | |
_HomePageState createState() => _HomePageState(); | |
} | |
class _HomePageState extends State<HomePage> { | |
... | |
@override | |
void initState() { | |
super.initState(); | |
// Instanciando as páginas da NavigationButton | |
FeedPage feedPage = FeedPage(); | |
ProfilePage profilePage = ProfilePage(); | |
ExplorerPage explorerPage = ExplorerPage(); | |
// Adicionando as páginas na lista | |
_pages = [feedPage, profilePage, explorerPage]; | |
// Setando a página inicial como sendo do Feed | |
_currentPage = feedPage; | |
} | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
body: _currentPage, | |
bottomNavigationBar: buildBottonNavigationBar(), | |
); | |
} | |
// Método para construir o BottomNavigationBar | |
Widget buildBottonNavigationBar() { | |
return BottomNavigationBar( | |
type: BottomNavigationBarType.fixed, | |
elevation: 0, | |
items: [ | |
... | |
], | |
onTap: navigationTapped, | |
currentIndex: _indexCurrentPage, | |
); | |
} | |
// Metodo para controlar a navegação quando o usuário clicar no Item do | |
// BottomNavigationBar | |
void navigationTapped(int page) { | |
setState(() { | |
_indexCurrentPage = page; | |
_currentPage = _pages[page]; | |
// PRECISO CHAMAR AQUI O MÉTODO moveTop do WidgetA | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment