Skip to content

Instantly share code, notes, and snippets.

@guilhermecarvalhocarneiro
Created January 10, 2020 13:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guilhermecarvalhocarneiro/c927802a4969cb277760270dc98ccf44 to your computer and use it in GitHub Desktop.
Save guilhermecarvalhocarneiro/c927802a4969cb277760270dc98ccf44 to your computer and use it in GitHub Desktop.
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