Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'package:flutter/material.dart';
- void main() {
- runApp(MyApp());
- }
- class MyApp extends StatefulWidget {
- @override
- _MyAppState createState() => _MyAppState();
- }
- class _MyAppState extends State<MyApp> {
- int _tabIndex = 0;
- @override
- Widget build(BuildContext context) {
- return MaterialApp(
- home: Scaffold(
- appBar: AppBar(
- title: Text("Welcome to Flutter!!"),
- ),
- bottomNavigationBar: BottomNavigationBar(
- items: [
- BottomNavigationBarItem(title: Text("Home"), icon: Icon(Icons.home)),
- BottomNavigationBarItem(title: Text("List"), icon: Icon(Icons.list))
- ],
- currentIndex: _tabIndex,
- onTap: (index) {
- setState(() {
- _tabIndex = index;
- });
- print(_tabIndex);
- },
- ),
- ),
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement