water_drop_nav_bar 2.1.0+7 water_drop_nav_bar: ^2.1.0+7 copied to clipboard
Bottom navigation bar, it has unique water drop effect. When water droplet falls it marks seleted item.
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:water_drop_nav_bar/water_drop_nav_bar.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
// debugShowCheckedModeBanner: false,
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
canvasColor: Colors.grey[200],
),
home: const MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({Key? key}) : super(key: key);
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
final Color navigationBarColor = Colors.white;
int selectedIndex = 0;
late PageController pageController;
@override
void initState() {
super.initState();
pageController = PageController(initialPage: selectedIndex);
}
@override
Widget build(BuildContext context) {
/// [AnnotatedRegion<SystemUiOverlayStyle>] only for android black navigation bar. 3 button navigation control (legacy)
return AnnotatedRegion<SystemUiOverlayStyle>(
value: SystemUiOverlayStyle(
systemNavigationBarColor: navigationBarColor,
systemNavigationBarIconBrightness: Brightness.dark,
),
child: Scaffold(
backgroundColor: Colors.amber,
body: PageView(
physics: const NeverScrollableScrollPhysics(),
controller: pageController,
children: <Widget>[
Container(
alignment: Alignment.center,
child: Icon(
Icons.bookmark_rounded,
size: 56,
color: Colors.amber[400],
),
),
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: ClipRRect(
borderRadius: BorderRadius.vertical(top: Radius.circular(20)),
child: WaterDropNavBar(
backgroundColor: navigationBarColor,
onItemSelected: (int index) {
setState(() {
selectedIndex = index;
});
pageController.animateToPage(selectedIndex,
duration: const Duration(milliseconds: 400),
curve: Curves.easeOutQuad);
},
selectedIndex: selectedIndex,
barItems: <BarItem>[
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,
),
],
),
),
),
);
}
}