joaopaulofcc

Untitled

Sep 9th, 2020
1,119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 1.29 KB | None | 0 0
  1. import "package:flutter/material.dart";
  2.  
  3. void main() => runApp(MyApp());
  4.  
  5. class MyApp extends StatefulWidget {
  6.  MyApp({Key key}) : super(key : key);
  7.  @override
  8.  _MyApp createState() => _MyApp();
  9. }
  10.  
  11. class _MyApp extends State {
  12.  
  13.  var _currentPage = 0;
  14.  
  15.  var _pages = [
  16.    Text("Página 1 - Avisos"),
  17.    Text("Página 2 - Aniversários"),
  18.    Text("Página 3 - Dados")
  19.  ];
  20.  
  21.   @override
  22.   Widget build(BuildContext context) {
  23.  
  24.     return MaterialApp(title : "Exemplo - BottomNavigationBar",
  25.       home : Scaffold(
  26.         body : Center(child : _pages.elementAt(_currentPage)),
  27.         bottomNavigationBar : BottomNavigationBar(
  28.           items : [
  29.             BottomNavigationBarItem(
  30.               icon : Icon(Icons.announcement),
  31.               title : Text("Avisos")
  32.             ),
  33.             BottomNavigationBarItem(
  34.               icon : Icon(Icons.cake),
  35.               title : Text("Aniversários")
  36.             ),
  37.             BottomNavigationBarItem(
  38.               icon : Icon(Icons.cloud),
  39.               title : Text("Dados")
  40.             ),
  41.           ],
  42.           currentIndex : _currentPage,
  43.           fixedColor : Colors.red,
  44.           onTap : (int inIndex) {
  45.             setState(() { _currentPage = inIndex; });
  46.           }
  47.         )
  48.       )
  49.     );
  50.   }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment