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 StatelessWidget {
- @override
- Widget build(BuildContext context) {
- return MaterialApp(
- debugShowCheckedModeBanner: false,
- home: MyHomePage(),
- );
- }
- }
- class MyHomePage extends StatefulWidget {
- @override
- State<MyHomePage> createState() => _MyHomePageState();
- }
- class _MyHomePageState extends State<MyHomePage> {
- int _selectedIndex = 0;
- void _onItemTapped(int index) {
- setState(() {
- _selectedIndex = index;
- });
- }
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- body: Center(
- child: Text(
- 'Selected tab: ${_selectedIndex + 1}',
- style: TextStyle(fontSize: 20),
- ),
- ),
- floatingActionButton: FloatingActionButton(
- onPressed: () {
- // FAB action
- },
- shape: CircleBorder(),
- backgroundColor: Colors.teal,
- child: Icon(
- Icons.restaurant_menu,
- color: Colors.white,
- ),
- ),
- floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
- bottomNavigationBar: ClipRRect(
- borderRadius: BorderRadius.vertical(top: Radius.circular(32)),
- child: BottomAppBar(
- shape: CircularNotchedRectangle(),
- notchMargin: 10.0,
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceAround,
- children: [
- IconButton(
- icon: Icon(
- Icons.home,
- color: _selectedIndex == 0 ? Colors.teal : Colors.grey,
- ),
- onPressed: () => _onItemTapped(0),
- ),
- IconButton(
- icon: Icon(
- Icons.search,
- color: _selectedIndex == 1 ? Colors.teal : Colors.grey,
- ),
- onPressed: () => _onItemTapped(1),
- ),
- IconButton(
- icon: Icon(
- Icons.notifications,
- color: _selectedIndex == 2 ? Colors.teal : Colors.grey,
- ),
- onPressed: () => _onItemTapped(2),
- ),
- IconButton(
- icon: Icon(
- Icons.person,
- color: _selectedIndex == 3 ? Colors.teal : Colors.grey,
- ),
- onPressed: () => _onItemTapped(3),
- ),
- ],
- ),
- ),
- ),
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement