Advertisement
Guest User

Untitled

a guest
Feb 17th, 2020
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 0.83 KB | None | 0 0
  1. import 'package:flutter/material.dart';
  2.  
  3. void main() {
  4.     runApp(MyApp());
  5. }
  6.  
  7. class MyApp extends StatefulWidget {
  8.   @override
  9.   _MyAppState createState() => _MyAppState();
  10. }
  11.  
  12. class _MyAppState extends State<MyApp> {
  13.     int _tabIndex = 0;
  14.  
  15.     @override
  16.     Widget build(BuildContext context) {
  17.         return MaterialApp(
  18.             home: Scaffold(
  19.                 appBar: AppBar(
  20.                     title: Text("Welcome to Flutter!!"),
  21.                 ),
  22.                 bottomNavigationBar: BottomNavigationBar(
  23.                     items: [
  24.                         BottomNavigationBarItem(title: Text("Home"), icon: Icon(Icons.home)),
  25.                         BottomNavigationBarItem(title: Text("List"), icon: Icon(Icons.list))
  26.                     ],
  27.  
  28.                     currentIndex: _tabIndex,
  29.           onTap: (index) {
  30.             setState(() {
  31.               _tabIndex = index;
  32.             });
  33.             print(_tabIndex);
  34.           },
  35.                 ),
  36.             ),
  37.         );
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement