|
| 1 | +import 'package:flutter/material.dart'; |
| 2 | +import 'package:salomon_bottom_bar/salomon_bottom_bar.dart'; |
| 3 | + |
| 4 | +class SalomonBottomNavBar extends StatefulWidget { |
| 5 | + const SalomonBottomNavBar({ Key? key }) : super(key: key); |
| 6 | + |
| 7 | + @override |
| 8 | + _SalomonBottomNavBarState createState() => _SalomonBottomNavBarState(); |
| 9 | +} |
| 10 | + |
| 11 | +class _SalomonBottomNavBarState extends State<SalomonBottomNavBar> { |
| 12 | + int _currentIndex = 0; |
| 13 | + |
| 14 | + @override |
| 15 | + void initState() { |
| 16 | + super.initState(); |
| 17 | + } |
| 18 | + |
| 19 | + @override |
| 20 | + Widget build(BuildContext context) { |
| 21 | + return Scaffold( |
| 22 | + appBar: AppBar( |
| 23 | + backgroundColor: Colors.blueAccent, |
| 24 | + elevation: 0, |
| 25 | + title: Text("Salomon Bottom Bar",), |
| 26 | + ), |
| 27 | + body: Center(child: Text("@theflutterlover", style: TextStyle(fontSize: 20),),), |
| 28 | + bottomNavigationBar: SalomonBottomBar( |
| 29 | + currentIndex: _currentIndex, |
| 30 | + margin: EdgeInsets.symmetric(vertical: 30, horizontal: 20), |
| 31 | + onTap: (index) { |
| 32 | + setState(() { |
| 33 | + _currentIndex = index; |
| 34 | + }); |
| 35 | + }, |
| 36 | + items: [ |
| 37 | + SalomonBottomBarItem( |
| 38 | + icon: Icon(Icons.home), |
| 39 | + title: Text("Home"), |
| 40 | + selectedColor: Colors.purple |
| 41 | + ), |
| 42 | + SalomonBottomBarItem( |
| 43 | + icon: Icon(Icons.favorite_border), |
| 44 | + title: Text("Likes"), |
| 45 | + selectedColor: Colors.pink |
| 46 | + ), |
| 47 | + SalomonBottomBarItem( |
| 48 | + icon: Icon(Icons.search), |
| 49 | + title: Text("Search"), |
| 50 | + selectedColor: Colors.orange |
| 51 | + ), |
| 52 | + SalomonBottomBarItem( |
| 53 | + icon: Icon(Icons.person), |
| 54 | + title: Text("Profile"), |
| 55 | + selectedColor: Colors.teal |
| 56 | + ) |
| 57 | + ], |
| 58 | + ), |
| 59 | + ); |
| 60 | + } |
| 61 | +} |
0 commit comments