liquid_glass_bottom_navbar 0.0.1
liquid_glass_bottom_navbar: ^0.0.1 copied to clipboard
A stunning glassmorphic bottom navigation bar for Flutter with liquid animations, physics-based transitions, and GPU-accelerated rendering.
import 'package:flutter/material.dart';
import 'package:liquid_glass_bottom_navbar/liquid_glass_bottom_navbar.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
bool _isDarkMode = false;
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Liquid Glass Nav Demo',
debugShowCheckedModeBanner: false,
theme: ThemeData(
brightness: _isDarkMode ? Brightness.dark : Brightness.light,
primarySwatch: Colors.blue,
useMaterial3: true,
),
home: MyHomePage(
onThemeToggle: () {
setState(() {
_isDarkMode = !_isDarkMode;
});
},
),
);
}
}
class MyHomePage extends StatefulWidget {
final VoidCallback onThemeToggle;
const MyHomePage({super.key, required this.onThemeToggle});
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _currentIndex = 0;
@override
Widget build(BuildContext context) {
final bool isDark = Theme.of(context).brightness == Brightness.dark;
return LiquidGlassTheme(
data: isDark ? LiquidGlassThemeData.dark() : LiquidGlassThemeData.light(),
child: Scaffold(
extendBody: true,
appBar: AppBar(
title: const Text('Liquid Glass Nav'),
backgroundColor: Colors.transparent,
elevation: 0,
actions: [
IconButton(
icon: Icon(isDark ? Icons.light_mode : Icons.dark_mode),
onPressed: widget.onThemeToggle,
),
],
),
body: Container(
width: double.infinity,
height: double.infinity,
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
stops: isDark ? const [0.0, 0.4, 1.0] : const [0.0, 0.5, 1.0],
colors: isDark
? [
const Color(0xFF1a1a2e),
const Color(0xFF16213e),
const Color(0xFF0f3460),
]
: [
const Color(0xFF667eea),
const Color(0xFF764ba2),
const Color(0xFFf093fb),
],
),
),
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'Page Index: $_currentIndex',
style: const TextStyle(
color: Colors.white,
fontSize: 32,
fontWeight: FontWeight.bold,
shadows: [
Shadow(
blurRadius: 10.0,
color: Colors.black45,
offset: Offset(2.0, 2.0),
),
],
),
),
const SizedBox(height: 40),
GlassContainer(
blurRadius: 25,
opacity: 0.2,
borderRadius: BorderRadius.circular(28),
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 48, vertical: 28),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Container(
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.white.withValues(alpha: 0.15),
),
child: const Icon(
Icons.auto_awesome,
color: Colors.white,
size: 40,
),
),
const SizedBox(height: 20),
const Text(
'Liquid Glass',
style: TextStyle(
color: Colors.white,
fontSize: 24,
fontWeight: FontWeight.w600,
letterSpacing: 1.5,
),
),
const SizedBox(height: 8),
Text(
'Experience the depth of glass',
style: TextStyle(
color: Colors.white.withValues(alpha: 0.8),
fontSize: 14,
letterSpacing: 0.5,
),
),
],
),
),
),
],
),
),
),
bottomNavigationBar: LiquidGlassNavBar(
icons: const [
Icon(Icons.home_rounded),
Icon(Icons.search_rounded),
Icon(Icons.notifications_rounded),
Icon(Icons.person_rounded),
],
labels: const [
Text('Home'),
Text('Search'),
Text('Alerts'),
Text('Profile'),
],
onItemSelected: (index) {
setState(() {
_currentIndex = index;
});
},
),
),
);
}
}