### Flutter App Setup with Animated Bottom Navigation Bar Source: https://github.com/lanarsinc/animated-bottom-navigation-bar-flutter/blob/master/example/README.md Sets up the main Flutter application, defining the theme, navigation, and the home page which utilizes the AnimatedBottomNavigationBar. It includes basic theming and scaffold setup. ```dart import 'package:flutter/material.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, scaffoldBackgroundColor: Colors.white, visualDensity: VisualDensity.adaptivePlatformDensity, ), home: MyHomePage(title: 'Animated Navigation Bottom Bar'), ); } } class MyHomePage extends StatefulWidget { MyHomePage({Key key, this.title}) : super(key: key); final String title; @override _MyHomePageState createState() => _MyHomePageState(); } class _MyHomePageState extends State with SingleTickerProviderStateMixin { var _bottomNavIndex = 0; //default index of first screen AnimationController _animationController; Animation animation; CurvedAnimation curve; final iconList = [ Icons.brightness_5, Icons.brightness_4, Icons.brightness_6, Icons.brightness_7, ]; @override void initState() { super.initState(); final systemTheme = SystemUiOverlayStyle.light.copyWith( systemNavigationBarColor: HexColor('#373A36'), systemNavigationBarIconBrightness: Brightness.light, ); SystemChrome.setSystemUIOverlayStyle(systemTheme); _animationController = AnimationController( duration: Duration(seconds: 1), vsync: this, ); curve = CurvedAnimation( parent: _animationController, curve: Interval( 0.5, 1.0, curve: Curves.fastOutSlowIn, ), ); animation = Tween( begin: 0, end: 1, ).animate(curve); Future.delayed( Duration(seconds: 1), () => _animationController.forward(), ); } @override Widget build(BuildContext context) { return Scaffold( extendBody: true, appBar: AppBar( title: Text( widget.title, style: TextStyle(color: Colors.white), ), backgroundColor: HexColor('#373A36'), ), body: NavigationScreen( iconList[_bottomNavIndex], ), floatingActionButton: ScaleTransition( scale: animation, child: FloatingActionButton( elevation: 8, backgroundColor: HexColor('#FFA400'), child: Icon( Icons.brightness_3, color: HexColor('#373A36'), ), onPressed: () { _animationController.reset(); _animationController.forward(); }, ), ), floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked, bottomNavigationBar: AnimatedBottomNavigationBar( icons: iconList, backgroundColor: HexColor('#373A36'), activeIndex: _bottomNavIndex, activeColor: HexColor('#FFA400'), splashColor: HexColor('#FFA400'), inactiveColor: Colors.white, notchAndCornersAnimation: animation, splashSpeedInMilliseconds: 300, notchSmoothness: NotchSmoothness.defaultEdge, gapLocation: GapLocation.center, leftCornerRadius: 32, rightCornerRadius: 32, onTap: (index) => setState(() => _bottomNavIndex = index), ), ); } } class NavigationScreen extends StatefulWidget { final IconData iconData; NavigationScreen(this.iconData) : super(); @override _NavigationScreenState createState() => _NavigationScreenState(); } class _NavigationScreenState extends State with TickerProviderStateMixin { AnimationController _controller; Animation animation; @override void didUpdateWidget(NavigationScreen oldWidget) { super.didUpdateWidget(oldWidget); if (oldWidget.iconData != widget.iconData) { _startAnimation(); } } @override void initState() { _controller = AnimationController( vsync: this, duration: Duration(milliseconds: 1000), ); animation = CurvedAnimation( parent: _controller, curve: Curves.easeIn, ); _controller.forward(); super.initState(); } _startAnimation() { _controller = AnimationController( vsync: this, duration: Duration(milliseconds: 1000), ); animation = CurvedAnimation( parent: _controller, curve: Curves.easeIn, ); _controller.forward(); } @override void dispose() { _controller.dispose(); super.dispose(); } @override Widget build(BuildContext context) { return Container( width: double.infinity, height: double.infinity, color: Colors.white, child: Center( child: Icon( widget.iconData, size: 80, color: HexColor("#FFA400"), ), ), ); } } class HexColor extends Color { HexColor(final String hexColor) : super(_getColorFromHex(hexColor)); static int _getColorFromHex(String hexColor) { hexColor = hexColor.toUpperCase().replaceAll("#", ""); if (hexColor.length == 6) { hexColor = "FF" + hexColor; } return int.parse(hexColor, radix: 16); } } ``` -------------------------------- ### HexColor Class for Flutter Colors Source: https://github.com/lanarsinc/animated-bottom-navigation-bar-flutter/blob/master/example/README.md A custom Flutter Color class that allows creating colors directly from hexadecimal color strings. It parses the hex string, handling both 6-digit and 8-digit formats (with alpha), and converts it into an integer representation suitable for Flutter's Color constructor. ```dart class HexColor extends Color { HexColor(final String hexColor) : super(_getColorFromHex(hexColor)); static int _getColorFromHex(String hexColor) { hexColor = hexColor.toUpperCase().replaceAll('#', ''); if (hexColor.length == 6) { hexColor = 'FF' + hexColor; } return int.parse(hexColor, radix: 16); } } ``` -------------------------------- ### Circular Reveal Animation in Flutter Source: https://github.com/lanarsinc/animated-bottom-navigation-bar-flutter/blob/master/example/README.md Implements a circular reveal animation for UI elements, often used for transitions in bottom navigation bars. It requires an Animation object, a center offset for the reveal, and the maximum radius to cover. The child widget is revealed from the center offset outwards. ```dart child: CircularRevealAnimation( animation: animation, centerOffset: Offset(80, 80), maxRadius: MediaQuery.of(context).size.longestSide * 1.1, child: Icon( widget.iconData, color: HexColor('#FFA400'), size: 160, ), ), ), ); } ``` -------------------------------- ### Basic Animated Bottom Navigation Bar Source: https://github.com/lanarsinc/animated-bottom-navigation-bar-flutter/blob/master/README.md Demonstrates the basic usage of `AnimatedBottomNavigationBar` within a `Scaffold`. This includes setting up icons, active index, gap location, notch smoothness, corner radii, and an `onTap` callback for handling tab selections. It also shows how to integrate with a `FloatingActionButton` and its location. ```dart Scaffold( body: Container(), //destination screen floatingActionButton: FloatingActionButton( //params ), floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked, bottomNavigationBar: AnimatedBottomNavigationBar( icons: iconList, activeIndex: _bottomNavIndex, gapLocation: GapLocation.center, notchSmoothness: NotchSmoothness.verySmoothEdge, leftCornerRadius: 32, rightCornerRadius: 32, onTap: (index) => setState(() => _bottomNavNavIndex = index), //other params ), ); ``` -------------------------------- ### Basic Animated Bottom Navigation Bar Source: https://github.com/lanarsinc/animated-bottom-navigation-bar-flutter/blob/master/README.md Demonstrates the basic implementation of the AnimatedBottomNavigationBar within a Scaffold. It shows how to pass a list of icons and handle tap events to update the active index. ```dart Scaffold( bottomNavigationBar: AnimatedBottomNavigationBar( icons: iconList, activeIndex: _bottomNavIndex, onTap: (index) => setState(() => _bottomNavNavIndex = index), //other params ), ); ``` -------------------------------- ### Animated Bottom Navigation Bar with Builder Source: https://github.com/lanarsinc/animated-bottom-navigation-bar-flutter/blob/master/README.md Illustrates the usage of `AnimatedBottomNavigationBar.builder` for more control over tab rendering. This approach requires the developer to provide the `itemCount` and a `tabBuilder` function, which receives the index and active state to render each tab. It also includes common parameters like `activeIndex`, `gapLocation`, `notchSmoothness`, corner radii, and an `onTap` callback. ```dart Scaffold( body: Container(), //destination screen floatingActionButton: FloatingActionButton( //params ), floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked, bottomNavigationBar: AnimatedBottomNavigationBar.builder( itemCount: iconList.length, tabBuilder: (int index, bool isActive) { return Icon( iconList[index], size: 24, color: isActive ? colors.activeNavigationBarColor : colors.notActiveNavigationBarColor, ); }, activeIndex: _bottomNavIndex, gapLocation: GapLocation.center, notchSmoothness: NotchSmoothness.verySmoothEdge, leftCornerRadius: 32, rightCornerRadius: 32, onTap: (index) => setState(() => _bottomNavIndex = index), //other params ), ); ``` -------------------------------- ### Animated Bottom Navigation Bar with Center Gap (Smooth Edge) Source: https://github.com/lanarsinc/animated-bottom-navigation-bar-flutter/blob/master/README.md Illustrates achieving a smooth edge for the notch when a FAB is centered using `notchSmoothness: NotchSmoothness.smoothEdge`. ```dart Scaffold( floatingActionButton: FloatingActionButton( //params ), floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked, bottomNavigationBar: AnimatedBottomNavigationBar( icons: iconList, activeIndex: _bottomNavIndex, gapLocation: GapLocation.center, notchSmoothness: NotchSmoothness.smoothEdge, onTap: (index) => setState(() => _bottomNavIndex = index), //other params ), ); ``` -------------------------------- ### Animated Bottom Navigation Bar with Center Gap (Very Smooth Edge) Source: https://github.com/lanarsinc/animated-bottom-navigation-bar-flutter/blob/master/README.md Demonstrates the smoothest notch effect for a centered FAB by using `notchSmoothness: NotchSmoothness.verySmoothEdge`. ```dart Scaffold( floatingActionButton: FloatingActionButton( //params ), floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked, bottomNavigationBar: AnimatedBottomNavigationBar( icons: iconList, activeIndex: _bottomNavIndex, gapLocation: GapLocation.center, notchSmoothness: NotchSmoothness.verySmoothEdge, onTap: (index) => setState(() => _bottomNavIndex = index), //other params ), ); ``` -------------------------------- ### Animated Bottom Navigation Bar with Center Gap (Soft Smoothness) Source: https://github.com/lanarsinc/animated-bottom-navigation-bar-flutter/blob/master/README.md Shows how to create a softer notch effect for a centered FAB gap in the AnimatedBottomNavigationBar by setting `notchSmoothness: NotchSmoothness.softEdge`. ```dart Scaffold( floatingActionButton: FloatingActionButton( //params ), floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked, bottomNavigationBar: AnimatedBottomNavigationBar( icons: iconList, activeIndex: _bottomNavIndex, gapLocation: GapLocation.center, notchSmoothness: NotchSmoothness.softEdge, onTap: (index) => setState(() => _bottomNavIndex = index), //other params ), ); ``` -------------------------------- ### Animated Bottom Navigation Bar with Center Gap (Default Smoothness) Source: https://github.com/lanarsinc/animated-bottom-navigation-bar-flutter/blob/master/README.md Demonstrates setting the gap in the center of the AnimatedBottomNavigationBar for a FAB, using the default notch smoothness. This is achieved with `gapLocation: GapLocation.center` and `floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked`. ```dart Scaffold( floatingActionButton: FloatingActionButton( //params ), floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked, bottomNavigationBar: AnimatedBottomNavigationBar( icons: iconList, activeIndex: _bottomNavIndex, gapLocation: GapLocation.center, notchSmoothness: NotchSmoothness.defaultEdge, onTap: (index) => setState(() => _bottomNavIndex = index), //other params ), ); ``` -------------------------------- ### Animated Bottom Navigation Bar with End Gap for FAB Source: https://github.com/lanarsinc/animated-bottom-navigation-bar-flutter/blob/master/README.md Illustrates configuring the AnimatedBottomNavigationBar to accommodate a FloatingActionButton (FAB) with the gap positioned at the end. It uses `gapLocation: GapLocation.end` and `floatingActionButtonLocation: FloatingActionButtonLocation.endDocked`. ```dart Scaffold( floatingActionButton: FloatingActionButton( //params ), floatingActionButtonLocation: FloatingActionButtonLocation.endDocked, bottomNavigationBar: AnimatedBottomNavigationBar( icons: iconList, activeIndex: _bottomNavIndex, gapLocation: GapLocation.end, notchSmoothness: NotchSmoothness.defaultEdge, onTap: (index) => setState(() => _bottomNavIndex = index), //other params ), ); ``` -------------------------------- ### Animated Bottom Navigation Bar with Rounded Corners Source: https://github.com/lanarsinc/animated-bottom-navigation-bar-flutter/blob/master/README.md Shows how to customize the AnimatedBottomNavigationBar with rounded corners by setting `leftCornerRadius` and `rightCornerRadius`. This provides a more distinct visual style. ```dart Scaffold( bottomNavigationBar: AnimatedBottomNavigationBar( icons: iconList, activeIndex: _bottomNavIndex, leftCornerRadius: 32, rightCornerRadius: 32, onTap: (index) => setState(() => _bottomNavIndex = index), //other params ), ); ``` -------------------------------- ### Programmatic Navigation Bar Tab Changes Source: https://github.com/lanarsinc/animated-bottom-navigation-bar-flutter/blob/master/README.md Explains how to programmatically change the active tab of the AnimatedBottomNavigationBar. This involves updating the `activeIndex` property within a `setState` call in response to an event, such as a tap handler. ```dart class _MyAppState extends State { int activeIndex; /// Handler for when you want to programmatically change /// the active index. Calling `setState()` here causes /// Flutter to re-render the tree, which `AnimatedBottomNavigationBar` /// responds to by running its normal animation. void _onTap(int index) { setState((){ activeIndex = index; }); } Widget build(BuildContext context) { return AnimatedBottomNavigationBar( activeIndex: activeIndex, onTap: _onTap, //other params ); } } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.