dot_navigation_bar 1.0.2 dot_navigation_bar: ^1.0.2 copied to clipboard
Simple smooth animations, providing a nice and cleanUI/UX Bottom Nav Bar.
import 'package:dot_navigation_bar/dot_navigation_bar.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget{
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: Home(),
);
}
}
class Home extends StatefulWidget {
@override
_HomeState createState() => _HomeState();
}
class _HomeState extends State<Home> with TickerProviderStateMixin {
var _selectedTab = _SelectedTab.home;
void _handleIndexChanged(int i) {
setState(() {
_selectedTab = _SelectedTab.values[i];
});
}
@override
Widget build(BuildContext context) {
var anim = AnimationController(
vsync: this,
value: 1,
duration: const Duration(milliseconds: 500),
);
return Scaffold(
extendBody: true,
body: Container(
child: Image.asset("lib/img/1.png"),
),
bottomNavigationBar: Padding(
padding: EdgeInsets.only(bottom: 10),
child: DotNavigationBar(
margin: EdgeInsets.only(left: 10, right: 10),
currentIndex: _SelectedTab.values.indexOf(_selectedTab),
dotIndicatorColor: Colors.white,
unselectedItemColor: Colors.grey[300],
splashBorderRadius: 50,
// enableFloatingNavBar: false,
onTap: _handleIndexChanged,
items: [
/// Home
DotNavigationBarItem(
icon: Icon(Icons.home),
selectedColor: Color(0xff73544C),
),
/// Likes
DotNavigationBarItem(
icon: Icon(Icons.favorite),
selectedColor: Color(0xff73544C),
),
/// Search
DotNavigationBarItem(
icon: Icon(Icons.search),
selectedColor: Color(0xff73544C),
),
/// Profile
DotNavigationBarItem(
icon: Icon(Icons.person),
selectedColor: Color(0xff73544C),
),
],
),
),
);
}
}
enum _SelectedTab { home, favorite, search, person }