water_drop_nav_bar 0.0.2 water_drop_nav_bar: ^0.0.2 copied to clipboard
Bottom navigation bar. It has unique water drop effect. Indicates with filled icon.
import 'package:flutter/material.dart';
import 'package:water_drop_nav_bar/water_drop_nav_bar.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
canvasColor: Colors.grey[200],
accentColor: Colors.teal[400]),
home: MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int selectedIndex = 0;
late PageController pageController;
@override
void initState() {
super.initState();
pageController = PageController(initialPage: selectedIndex);
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: PageView(
physics: NeverScrollableScrollPhysics(),
controller: pageController,
children: [
Container(
width: MediaQuery.of(context).size.width / 2,
height: double.infinity,
alignment: Alignment.bottomCenter,
padding: const EdgeInsets.only(bottom: 200),
child: Icon(
Icons.bookmark_rounded,
size: 56,
color: Colors.amber[300],
),
),
Container(
alignment: Alignment.center,
child: Icon(
Icons.favorite_rounded,
size: 56,
color: Colors.red[400],
),
),
Container(
alignment: Alignment.center,
child: Icon(
Icons.email_rounded,
size: 56,
color: Colors.green[400],
),
),
Container(
alignment: Alignment.center,
child: Icon(
Icons.folder_rounded,
size: 56,
color: Colors.blue[400],
),
),
],
),
bottomNavigationBar: WaterDropNavBar(
backgroundColor: Colors.white,
onButtonPressed: (index) {
setState(() {
selectedIndex = index;
});
pageController.animateToPage(selectedIndex,
duration: const Duration(milliseconds: 400),
curve: Curves.easeOutQuad);
},
selectedIndex: selectedIndex,
barItems: [
BarItem(
filledIcon: Icons.bookmark_rounded,
outlinedIcon: Icons.bookmark_border_rounded,
),
BarItem(
filledIcon: Icons.favorite_rounded,
outlinedIcon: Icons.favorite_border_rounded),
BarItem(
filledIcon: Icons.email_rounded,
outlinedIcon: Icons.email_outlined,
),
BarItem(
filledIcon: Icons.folder_rounded,
outlinedIcon: Icons.folder_outlined,
),
],
),
);
}
}
// icon size:24 for fontAwesomeIcons
// icons size: 30 for MaterialIcons