Skip to content

Instantly share code, notes, and snippets.

@Maadhav
Last active August 5, 2020 07:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Maadhav/087a446bff600c9f0d91e3da66c783a4 to your computer and use it in GitHub Desktop.
Save Maadhav/087a446bff600c9f0d91e3da66c783a4 to your computer and use it in GitHub Desktop.
Bubble Bottom Bar Flutter
import 'package:bubble_bottom_bar/bubble_bottom_bar.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
class Home extends StatefulWidget {
@override
_HomeState createState() => _HomeState();
}
class _HomeState extends State<Home> {
int currentIndex = 0;
void changePage(int index) {
setState(() {
currentIndex = index;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: <Widget>[
Container(
color: Colors.blue,
),
Container(
color: Colors.red,
),
Container(
color: Colors.yellow,
),
Container(
color: Colors.green,
),
][currentIndex],
bottomNavigationBar: BubbleBottomBar(
opacity: 0,
currentIndex: currentIndex,
onTap: changePage,
borderRadius: BorderRadius.vertical(top: Radius.circular(16)),
elevation: 8,
items: <BubbleBottomBarItem>[
BubbleBottomBarItem(
backgroundColor: Colors.black,
icon: SvgPicture.asset(
'assets/icons/home.svg',
width: 21,
color: Colors.black54,
height: 21,
),
activeIcon: SvgPicture.asset(
'assets/icons/home.svg',
width: 21,
color: Colors.black,
height: 21,
),
title: Text("Home")),
BubbleBottomBarItem(
backgroundColor: Colors.black,
icon: SvgPicture.asset(
'assets/icons/search.svg',
width: 21,
color: Colors.black54,
height: 21,
),
activeIcon: SvgPicture.asset(
'assets/icons/search.svg',
width: 21,
color: Colors.black,
height: 21,
),
title: Text("Search")),
BubbleBottomBarItem(
backgroundColor: Colors.black,
icon: SvgPicture.asset(
'assets/icons/bookmark.svg',
width: 21,
color: Colors.black54,
height: 21,
),
activeIcon: SvgPicture.asset(
'assets/icons/bookmark.svg',
width: 21,
color: Colors.black,
height: 21,
),
title: Text("Bookmarks")),
BubbleBottomBarItem(
backgroundColor: Colors.black,
icon: Container(
height: 24,
width: 24,
decoration: BoxDecoration(
shape: BoxShape.circle,
image: DecorationImage(image: AssetImage('assets/user.png')),
boxShadow: [
BoxShadow(
color: Color(0x5c000000),
offset: Offset(0, 1),
blurRadius: 5)
],
),
),
title: Text("Profile")),
],
),
);
}
}
import 'package:flutter/material.dart';
import 'home.dart';
void main() =>runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Home(),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment