salomon_bottom_bar 2.0.0 salomon_bottom_bar: ^2.0.0 copied to clipboard
Yet another bottom navigation bar, but with a few key promises.
import 'package:flutter/material.dart';
import 'package:salomon_bottom_bar/salomon_bottom_bar.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
var _selectedTab = _SelectedTab.home;
void _handleIndexChanged(int i) {
setState(() {
_selectedTab = _SelectedTab.values[i];
});
}
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'salomon_bottom_bar',
theme: ThemeData(
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: Scaffold(
appBar: AppBar(
title: Text("salomon_bottom_bar"),
),
body: Center(
child: SalomonBottomBar(
currentIndex: _SelectedTab.values.indexOf(_selectedTab),
onTap: _handleIndexChanged,
items: [
/// Home
SalomonBottomBarItem(
icon: Icon(Icons.home),
title: Text("Home"),
selectedColor: Colors.purple,
),
/// Likes
SalomonBottomBarItem(
icon: Icon(Icons.favorite_border),
title: Text("Likes"),
selectedColor: Colors.pink,
),
/// Search
SalomonBottomBarItem(
icon: Icon(Icons.search),
title: Text("Search"),
selectedColor: Colors.orange,
),
/// Profile
SalomonBottomBarItem(
icon: Icon(Icons.person),
title: Text("Profile"),
selectedColor: Colors.teal,
),
],
),
),
),
);
}
}
enum _SelectedTab { home, likes, search, profile }