### Basic Usage Example Source: https://github.com/sooxt98/google_nav_bar/blob/master/_autodocs/REFERENCE.md A complete Flutter example demonstrating how to integrate and use the Google Nav Bar with state management for tab changes. ```dart import 'package:google_nav_bar/google_nav_bar.dart'; import 'package:flutter/material.dart'; class MyApp extends StatefulWidget { @override _MyAppState createState() => _MyAppState(); } class _MyAppState extends State { int _selectedIndex = 0; @override Widget build(BuildContext context) { return Scaffold( body: Center( child: Text('Tab $_selectedIndex'), ), bottomNavigationBar: GNav( selectedIndex: _selectedIndex, onTabChange: (index) { setState(() => _selectedIndex = index); }, tabs: [ GButton(icon: Icons.home, text: 'Home'), GButton(icon: Icons.favorite, text: 'Likes'), GButton(icon: Icons.search, text: 'Search'), GButton(icon: Icons.person, text: 'Profile'), ], ), ); } } ``` -------------------------------- ### Basic GNav Widget Usage Source: https://github.com/sooxt98/google_nav_bar/blob/master/_autodocs/MANIFEST.txt Demonstrates the fundamental setup of the GNav widget with a few basic items. This is a starting point for integrating the navigation bar. ```dart GNav( gap: 8, iconSize: 24, padding: EdgeInsets.symmetric(horizontal: 12, vertical: 5), activeColor: Colors.white, tabBackgroundColor: Colors.grey.shade800, color: Colors.grey, tabs: [ GButton(icon: Icons.home), GButton(icon: Icons.search), GButton(icon: Icons.settings), GButton(icon: Icons.person), ] ) ``` -------------------------------- ### GButton Constructor Example Source: https://github.com/sooxt98/google_nav_bar/blob/master/_autodocs/PROPERTY_INHERITANCE.md Illustrates the initial GButton constructor call where iconActiveColor is omitted, setting the stage for inheritance. ```dart GButton( icon: Icons.favorite, text: 'Likes', // iconActiveColor not specified (omitted) ) ``` -------------------------------- ### Symbol Resolution Example Source: https://github.com/sooxt98/google_nav_bar/blob/master/_autodocs/MODULE_STRUCTURE.md Demonstrates how to trace imports to their definitions within the google_nav_bar package, showing how GNav, GnavStyle, and GButton resolve. ```dart // Import statement import 'package:google_nav_bar/google_nav_bar.dart'; // Resolves to: lib/google_nav_bar.dart // Which exports: 'src/gnav.dart', 'src/gbutton.dart' // Accessing GNav GNav(...) // ← Resolves to: lib/src/gnav.dart, class GNav extends StatefulWidget // Accessing GnavStyle GnavStyle.google // ← Resolves to: lib/src/gnav.dart, enum GnavStyle // GNav contains GButton tabs: [ GButton(...) // ← Resolves to: lib/src/gbutton.dart, class GButton extends StatefulWidget ] ``` -------------------------------- ### GNav Configuration Example Source: https://github.com/sooxt98/google_nav_bar/blob/master/_autodocs/configuration.md Demonstrates how to configure GNav with custom colors, icon sizes, and per-button overrides for active color and icon size. ```dart GNav( activeColor: Colors.purple, iconSize: 24, tabs: [ GButton( icon: Icons.home, text: 'Home', ), GButton( icon: Icons.favorite, text: 'Likes', activeColor: Colors.red, iconSize: 28, ), ], ) ``` -------------------------------- ### Import Usage Example Source: https://github.com/sooxt98/google_nav_bar/blob/master/_autodocs/MODULE_STRUCTURE.md Demonstrates how to import and use the main components of the google_nav_bar package in your Flutter application. ```dart import 'package:google_nav_bar/google_nav_bar.dart'; // Now available: // - GNav (class) // - GButton (class) // - GnavStyle (enum) ``` -------------------------------- ### GNav Type Flow Example Source: https://github.com/sooxt98/google_nav_bar/blob/master/_autodocs/types.md Provides a comprehensive example of the types expected by the GNav widget, including lists of GButton widgets, selected index, optional callbacks, colors, durations, curves, padding, and style. ```dart // GNav receives these types final GNav nav = GNav( tabs: List, selectedIndex: int, onTabChange: ValueChanged?, activeColor: Color?, duration: Duration, curve: Curve, padding: EdgeInsetsGeometry, style: GnavStyle?, ); ``` -------------------------------- ### ColorTween Setup for Animation Source: https://github.com/sooxt98/google_nav_bar/blob/master/_autodocs/ANIMATION_SYSTEM.md Initializes a ColorTween with begin and end colors, and sets up its animation using a CurvedAnimation. ```dart var _colorTween = ColorTween( begin: widget.iconColor, // Unselected color end: widget.iconActiveColor // Selected color ); var _colorTweenAnimation = _colorTween.animate(CurvedAnimation( parent: expandController, curve: _expanded ? Curves.easeInExpo : Curves.easeOutCirc )); ``` -------------------------------- ### GNav Widget with Responsive Design Source: https://github.com/sooxt98/google_nav_bar/blob/master/_autodocs/MANIFEST.txt Shows an example of how the GNav widget can be used in a responsive design, adapting its layout or behavior based on screen size or orientation. This example might adjust padding or icon size. ```dart GNav( gap: 8, iconSize: MediaQuery.of(context).size.width * 0.07, padding: EdgeInsets.symmetric(horizontal: 12, vertical: 5), activeColor: Colors.white, tabBackgroundColor: Colors.grey.shade800, color: Colors.grey, tabs: [ GButton(icon: Icons.home, text: 'Home'), GButton(icon: Icons.search, text: 'Search'), GButton(icon: Icons.settings, text: 'Settings'), GButton(icon: Icons.person, text: 'Profile'), ] ) ``` -------------------------------- ### GNav and GButton Type Flow Example Source: https://github.com/sooxt98/google_nav_bar/blob/master/_autodocs/types.md Illustrates the types accepted by GNav and GButton widgets, showcasing required and optional parameters, callback types, and style enums. ```APIDOC ## Example: Complete Type Flow ```dart // GNav receives these types final GNav nav = GNav( tabs: List, selectedIndex: int, onTabChange: ValueChanged?, activeColor: Color?, duration: Duration, curve: Curve, padding: EdgeInsetsGeometry, style: GnavStyle?, ); // GButton accepts subset of types final GButton btn = GButton( icon: IconData, text: String, onPressed: Function?, iconColor: Color?, style: GnavStyle?, ); ``` ``` -------------------------------- ### TextStyle Composition Example Source: https://github.com/sooxt98/google_nav_bar/blob/master/_autodocs/PROPERTY_INHERITANCE.md Illustrates how TextStyle is composed in GButton. If `textStyle` is provided, it's used directly; otherwise, default properties like fontWeight are combined with inherited `textColor`. ```dart // If GButton provides textStyle Text( widget.text, style: widget.textStyle, // Use it directly ) // If GButton doesn't provide textStyle Text( widget.text, style: TextStyle( fontWeight: FontWeight.w600, // Default weight color: widget.textColor, // Use inherited textColor ), ) ``` -------------------------------- ### GNav Configuration Inheritance Example Source: https://github.com/sooxt98/google_nav_bar/blob/master/_autodocs/configuration.md Demonstrates how global GNav properties like colors, sizes, and animations are inherited by individual GButton widgets. Overrides can be applied sparingly for unique styling needs. ```dart GNav( // Global defaults activeColor: Colors.purple, color: Colors.grey, iconSize: 24, gap: 8, padding: EdgeInsets.all(20), duration: Duration(milliseconds: 400), style: GnavStyle.google, tabs: [ GButton( icon: Icons.home, text: 'Home', // Inherits: activeColor, color, iconSize, gap, padding, duration, style ), GButton( icon: Icons.favorite, text: 'Likes', iconActiveColor: Colors.red, // Override activeColor only backgroundColor: Colors.red.withOpacity(0.1), // Override tab bg // Inherits: color, iconSize, gap, padding, duration, style ), GButton( icon: Icons.person, text: 'Profile', leading: CircleAvatar(...), // Custom widget // Inherits: activeColor, color, iconSize, gap, padding, duration, style ), ], ) ``` -------------------------------- ### Border Radius Resolution Example Source: https://github.com/sooxt98/google_nav_bar/blob/master/_autodocs/PROPERTY_INHERITANCE.md Demonstrates how a double value for `tabBorderRadius` in GNav is converted to a BorderRadius object in GButton and then applied to a BoxDecoration. ```dart // GNav configuration GNav( tabBorderRadius: 15, // Double value tabs: [...] ) // GNav.build() conversion GButton( borderRadius: t.borderRadius ?? BorderRadius.all(Radius.circular(widget.tabBorderRadius)), // ^^^^^^^^^^^^^^^^^^^^^^^ // Converted: 15 → BorderRadius(15) ) // GButton passes to Button Button( borderRadius: BorderRadius.circular(15), // BorderRadius object ) // Button uses in decoration BoxDecoration( borderRadius: widget.borderRadius, // Can apply directly ) ``` -------------------------------- ### GButton Style Usage Example Source: https://github.com/sooxt98/google_nav_bar/blob/master/_autodocs/types.md Shows how to apply a specific GnavStyle to an individual GButton widget. This allows for consistent styling across navigation elements or for unique button appearances. ```dart GButton( style: GnavStyle.oldSchool, icon: Icons.home, text: 'Home', ) ``` -------------------------------- ### GButton Type Flow Example Source: https://github.com/sooxt98/google_nav_bar/blob/master/_autodocs/types.md Illustrates the types accepted by the GButton widget, including required icon and text, optional callbacks, colors, and style. This shows the subset of types GButton uses compared to GNav. ```dart // GButton accepts subset of types final GButton btn = GButton( icon: IconData, text: String, onPressed: Function?, iconColor: Color?, style: GnavStyle?, ); ``` -------------------------------- ### GNav Widget Usage Example Source: https://github.com/sooxt98/google_nav_bar/blob/master/_autodocs/api-reference/gnav.md Demonstrates how to integrate the GNav widget into a Flutter application, including state management for the selected tab and customization of appearance and behavior. ```dart GNav( selectedIndex: _selectedIndex, onTabChange: (index) { setState(() { _selectedIndex = index; }); }, gap: 8, activeColor: Colors.purple, color: Colors.grey[800], iconSize: 24, padding: EdgeInsets.symmetric(horizontal: 20, vertical: 12), duration: Duration(milliseconds: 400), tabBackgroundColor: Colors.grey[100], tabs: [ GButton(icon: Icons.home, text: 'Home'), GButton(icon: Icons.favorite, text: 'Likes'), GButton(icon: Icons.search, text: 'Search'), GButton(icon: Icons.person, text: 'Profile'), ], ) ``` -------------------------------- ### Minimal Google Nav Bar Implementation Source: https://github.com/sooxt98/google_nav_bar/blob/master/_autodocs/EXAMPLES.md This snippet shows the most basic setup for the Google Nav Bar with default styling and animations. It tracks the selected tab using `setState` and displays a simple text indicator. ```dart import 'package:flutter/material.dart'; import 'package:google_nav_bar/google_nav_bar.dart'; class MinimalNav extends StatefulWidget { @override _MinimalNavState createState() => _MinimalNavState(); } class _MinimalNavState extends State { int _selectedIndex = 0; @override Widget build(BuildContext context) { return Scaffold( body: Center(child: Text('Page $_selectedIndex')), bottomNavigationBar: GNav( selectedIndex: _selectedIndex, onTabChange: (index) { setState(() => _selectedIndex = index); }, tabs: [ GButton(icon: Icons.home, text: 'Home'), GButton(icon: Icons.search, text: 'Search'), GButton(icon: Icons.person, text: 'Profile'), ], ), ); } } ``` -------------------------------- ### Complete Real-World App Integration Source: https://github.com/sooxt98/google_nav_bar/blob/master/_autodocs/MANIFEST.txt Presents a comprehensive example of integrating the GNav widget into a full-fledged application. This snippet showcases a realistic usage scenario, including state management and navigation. ```dart import 'package:flutter/material.dart'; import 'package:google_nav_bar/google_nav_bar', class MainScreen extends StatefulWidget { @override _MainScreenState createState() => _MainScreenState(); } class _MainScreenState extends State { int _selectedIndex = 0; static const List _widgetOptions = [ Text('Home Page'), Text('Search Page'), Text('Profile Page'), Text('Settings Page'), ]; @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text('Google Nav Bar Example'), ), body: Center( child: _widgetOptions.elementAt(_selectedIndex), ), bottomNavigationBar: Container( decoration: BoxDecoration( color: Colors.black.withOpacity(0.8), boxShadow: [ BoxShadow( blurRadius: 20, color: Colors.black.withOpacity(0.1), ) ], ), child: SafeArea( child: Padding( padding: const EdgeInsets.symmetric(horizontal: 15.0, vertical: 8.0), child: GNav( rippleColor: Colors.grey[300]!, hoverColor: Colors.grey[100]!, gap: 4.0, activeColor: Colors.white, iconSize: 24.0, padding: EdgeInsets.symmetric(horizontal: 20.0, vertical: 12.0), duration: 400, tabBackgroundColor: Colors.grey[800]!, color: Colors.white, tabs: const [ GButton( icon: Icons.home, text: 'Home', ), GButton( icon: Icons.search, text: 'Search', ), GButton( icon: Icons.person, text: 'Profile', ), GButton( icon: Icons.settings, text: 'Settings', ), ], selectedIndex: _selectedIndex, onTabChange: (index) { setState(() { _selectedIndex = index; }); }, ), ), ), ), ); } } void main() { runApp(MaterialApp( home: MainScreen(), theme: ThemeData.dark(), )); } ``` -------------------------------- ### Button Component Usage Example Source: https://github.com/sooxt98/google_nav_bar/blob/master/_autodocs/api-reference/button.md Demonstrates how to use the Button component with various properties like icon, text, active state, and styling. This is typically used internally by GButton. ```dart Button( icon: Icons.home, text: Text('Home'), active: true, onPressed: () { /* handle tap */ }, iconColor: Colors.grey[800], iconActiveColor: Colors.purple, padding: EdgeInsets.symmetric(horizontal: 20, vertical: 12), duration: Duration(milliseconds: 400), curve: Curves.easeOutExpo, backgroundColor: Colors.purple.withOpacity(0.1), borderRadius: BorderRadius.circular(15), ) ``` -------------------------------- ### GNav Widget with Custom Leading Widget Source: https://github.com/sooxt98/google_nav_bar/blob/master/_autodocs/MANIFEST.txt Shows how to use a custom widget for the 'leading' parameter of a GButton, allowing for more complex or unique tab designs. This example uses a CircleAvatar. ```dart GNav( gap: 8, iconSize: 24, padding: EdgeInsets.symmetric(horizontal: 12, vertical: 5), activeColor: Colors.white, tabBackgroundColor: Colors.grey.shade800, color: Colors.grey, tabs: [ GButton(icon: Icons.home, text: 'Home'), GButton(icon: Icons.search, text: 'Search'), GButton( icon: Icons.settings, text: 'Settings', leading: CircleAvatar(backgroundImage: NetworkImage('https://example.com/avatar.jpg')), ), GButton(icon: Icons.person, text: 'Profile'), ] ) ``` -------------------------------- ### Google Nav Bar with Page Switching Source: https://github.com/sooxt98/google_nav_bar/blob/master/_autodocs/EXAMPLES.md This example demonstrates how to use the Google Nav Bar to switch between different pages or widgets within your application. It manages the displayed content based on the selected tab index. ```dart class TabbedApp extends StatefulWidget { @override _TabbedAppState createState() => _TabbedAppState(); } class _TabbedAppState extends State { int _selectedIndex = 0; final List _pages = [ HomePage(), SearchPage(), ProfilePage(), ]; @override Widget build(BuildContext context) { return Scaffold( body: _pages[_selectedIndex], bottomNavigationBar: GNav( selectedIndex: _selectedIndex, onTabChange: (index) { setState(() => _selectedIndex = index); }, tabs: [ GButton(icon: Icons.home, text: 'Home'), GButton(icon: Icons.search, text: 'Search'), GButton(icon: Icons.person, text: 'Profile'), ], ), ); } } ``` -------------------------------- ### Non-Nullable Property Handling Source: https://github.com/sooxt98/google_nav_bar/blob/master/_autodocs/PROPERTY_INHERITANCE.md Shows examples of non-nullable properties like gap, icon, and text, which are guaranteed to have a value. ```dart gap: t.gap ?? widget.gap, // gap is double (non-nullable) // Result is always a double, never null icon: widget.icon, // IconData, required text: widget.text, // String, required ``` -------------------------------- ### GButton onPressed Callback Example Source: https://github.com/sooxt98/google_nav_bar/blob/master/_autodocs/types.md Demonstrates the usage of the VoidCallback for the onPressed property of GButton. This callback is executed when the button is tapped, allowing for custom actions. ```dart GButton( icon: Icons.home, text: 'Home', onPressed: () { print('Button tapped'); }, ) ``` -------------------------------- ### Complete Google Nav Bar Implementation Source: https://github.com/sooxt98/google_nav_bar/blob/master/_autodocs/EXAMPLES.md This snippet shows a full Flutter application setup with a Google Nav Bar at the bottom. It manages navigation between different pages based on user selection. ```dart import 'package:flutter/material.dart'; import 'package:google_nav_bar/google_nav_bar.dart'; import 'package:line_icons/line_icons.dart'; void main() => runApp(const MyApp()); class MyApp extends StatelessWidget { const MyApp(); @override Widget build(BuildContext context) { return MaterialApp( title: 'Google Nav Bar Demo', theme: ThemeData( primarySwatch: Colors.purple, ), home: const MainScreen(), ); } } class MainScreen extends StatefulWidget { const MainScreen(); @override _MainScreenState createState() => _MainScreenState(); } class _MainScreenState extends State { int _selectedIndex = 0; final List _pages = const [ HomePage(), SearchPage(), LikesPage(), ProfilePage(), ]; @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text('Google Nav Bar'), elevation: 0, ), body: _pages[_selectedIndex], bottomNavigationBar: Container( decoration: BoxDecoration( color: Colors.white, boxShadow: [ BoxShadow( blurRadius: 20, color: Colors.black.withOpacity(.1), ) ], ), child: SafeArea( child: Padding( padding: const EdgeInsets.symmetric(horizontal: 15.0, vertical: 8), child: GNav( rippleColor: Colors.grey[300]!, hoverColor: Colors.grey[100]!, gap: 8, activeColor: Colors.purple, iconSize: 24, padding: EdgeInsets.symmetric(horizontal: 20, vertical: 12), duration: const Duration(milliseconds: 400), tabBackgroundColor: Colors.purple.withOpacity(0.1), color: Colors.black, tabs: const [ GButton( icon: LineIcons.home, text: 'Home', ), GButton( icon: LineIcons.search, text: 'Search', ), GButton( icon: LineIcons.heart, text: 'Likes', ), GButton( icon: LineIcons.user, text: 'Profile', ), ], selectedIndex: _selectedIndex, onTabChange: (index) { setState(() { _selectedIndex = index; }); }, ), ), ), ), ); } } class HomePage extends StatelessWidget { const HomePage(); @override Widget build(BuildContext context) { return const Center(child: Text('Home Page')); } } class SearchPage extends StatelessWidget { const SearchPage(); @override Widget build(BuildContext context) { return const Center(child: Text('Search Page')); } } class LikesPage extends StatelessWidget { const LikesPage(); @override Widget build(BuildContext context) { return const Center(child: Text('Likes Page')); } } class ProfilePage extends StatelessWidget { const ProfilePage(); @override Widget build(BuildContext context) { return const Center(child: Text('Profile Page')); } } ``` -------------------------------- ### Integrate GNav with Navigator Routes in Flutter Source: https://github.com/sooxt98/google_nav_bar/blob/master/_autodocs/EXAMPLES.md This example shows how to use GNav to navigate between different routes using Navigator.pushReplacementNamed. Ensure your routes are properly defined in your MaterialApp. ```dart class RouteNav extends StatefulWidget { @override _RouteNavState createState() => _RouteNavState(); } class _RouteNavState extends State { int _selectedIndex = 0; void _navigate(String route) { Navigator.pushReplacementNamed(context, route); } @override Widget build(BuildContext context) { return Scaffold( body: Container(), // Current page content bottomNavigationBar: GNav( selectedIndex: _selectedIndex, onTabChange: (index) { setState(() => _selectedIndex = index); switch (index) { case 0: _navigate('/home'); break; case 1: _navigate('/search'); break; case 2: _navigate('/profile'); break; } }, tabs: [ GButton(icon: Icons.home, text: 'Home'), GButton(icon: Icons.search, text: 'Search'), GButton(icon: Icons.person, text: 'Profile'), ], ), ); } } ``` -------------------------------- ### Configure GNav and GButton for Navigation Bar Source: https://github.com/sooxt98/google_nav_bar/blob/master/README.md Customize the appearance and behavior of the navigation bar using GNav attributes for global styling and GButton attributes for individual tab styling. This example demonstrates setting colors, borders, shadows, animations, and tab items. ```dart GNav( rippleColor: Colors.grey[800], hoverColor: Colors.grey[700], haptic: true, tabBorderRadius: 15, tabActiveBorder: Border.all(color: Colors.black, width: 1), tabBorder: Border.all(color: Colors.grey, width: 1), tabShadow: [BoxShadow(color: Colors.grey.withOpacity(0.5), blurRadius: 8)], curve: Curves.easeOutExpo, duration: Duration(milliseconds: 900), gap: 8, color: Colors.grey[800], activeColor: Colors.purple, iconSize: 24, tabBackgroundColor: Colors.purple.withOpacity(0.1), padding: EdgeInsets.symmetric(horizontal: 20, vertical: 5), tabs: [ GButton( icon: LineIcons.home, text: 'Home', ), GButton( icon: LineIcons.heart_o, text: 'Likes', ), GButton( icon: LineIcons.search, text: 'Search', ), GButton( icon: LineIcons.user, text: 'Profile', ) ] ) ``` -------------------------------- ### GNav Widget for Accessibility Source: https://github.com/sooxt98/google_nav_bar/blob/master/_autodocs/MANIFEST.txt Demonstrates how to configure the GNav widget to meet accessibility standards, such as providing appropriate labels or ensuring sufficient color contrast. This example might focus on semantic labels for screen readers. ```dart GNav( gap: 8, iconSize: 24, padding: EdgeInsets.symmetric(horizontal: 12, vertical: 5), activeColor: Colors.white, tabBackgroundColor: Colors.grey.shade800, color: Colors.grey, tabs: [ GButton(icon: Icons.home, text: 'Home', tooltip: 'Go to Home'), GButton(icon: Icons.search, text: 'Search', tooltip: 'Search content'), GButton(icon: Icons.settings, text: 'Settings', tooltip: 'Adjust settings'), GButton(icon: Icons.person, text: 'Profile', tooltip: 'View your profile'), ] ) ``` -------------------------------- ### GNav Style Usage Example Source: https://github.com/sooxt98/google_nav_bar/blob/master/_autodocs/types.md Demonstrates how to set the navigation bar style using the GnavStyle enum when creating a GNav widget. This controls the visual rendering and animation of the navigation bar. ```dart GNav( style: GnavStyle.google, // or GnavStyle.oldSchool tabs: [/* ... */], ) ``` -------------------------------- ### Dependency Tree for google_nav_bar Source: https://github.com/sooxt98/google_nav_bar/blob/master/_autodocs/MODULE_STRUCTURE.md Illustrates the dependency relationships between the main package entry point and its internal files. ```text google_nav_bar (package entry) ├── gnav.dart │ ├── flutter/material.dart │ └── gbutton.dart ├── gbutton.dart │ ├── flutter/material.dart │ ├── flutter/services.dart (HapticFeedback) │ ├── google_nav_bar.dart (circular - GnavStyle) │ └── button.dart └── button.dart ├── dart/math (pow) └── flutter/material.dart ``` -------------------------------- ### GNav with Complete Per-Button Configuration Source: https://github.com/sooxt98/google_nav_bar/blob/master/_autodocs/PROPERTY_INHERITANCE.md Shows a GButton configured with all its properties explicitly set, negating the need for inheritance from GNav. ```dart GNav( tabs: [ GButton( icon: Icons.home, text: 'Home', iconColor: Colors.grey, iconActiveColor: Colors.purple, textColor: Colors.purple, backgroundColor: Colors.purple.withOpacity(0.1), gap: 8, padding: EdgeInsets.all(20), iconSize: 24, // No inheritance needed - all set explicitly ), ], ) ``` -------------------------------- ### Import google_nav_bar in Dart code Source: https://github.com/sooxt98/google_nav_bar/blob/master/README.md Import the necessary package in your Dart files to start using the GoogleNavBar widget. ```dart import 'package:google_nav_bar/google_nav_bar.dart'; ``` -------------------------------- ### Dark Mode GNav Source: https://github.com/sooxt98/google_nav_bar/blob/master/_autodocs/EXAMPLES.md Configures the GNav for a dark theme. This example uses dark background colors and contrasting text/icon colors. ```dart GNav( selectedIndex: _selectedIndex, onTabChange: (index) => setState(() => _selectedIndex = index), backgroundColor: Colors.grey[900], activeColor: Colors.white, color: Colors.grey[400], tabBackgroundColor: Colors.grey[800], padding: EdgeInsets.symmetric(horizontal: 20, vertical: 12), tabs: [ GButton(icon: Icons.home, text: 'Home'), GButton(icon: Icons.search, text: 'Search'), GButton(icon: Icons.person, text: 'Profile'), ], ) ``` -------------------------------- ### Slowing Animations Source: https://github.com/sooxt98/google_nav_bar/blob/master/_autodocs/ANIMATION_SYSTEM.md Increase the 'duration' property to make animations slower. This example sets the duration to 1 second using 'easeInOutCubic' curve. ```dart GNav( duration: Duration(milliseconds: 1000), // 1 second curve: Curves.easeInOutCubic, tabs: [/* ... */], ) ``` -------------------------------- ### GButton Constructor Source: https://github.com/sooxt98/google_nav_bar/blob/master/_autodocs/api-reference/gbutton.md This snippet details the constructor for the GButton widget, outlining all available parameters for customization. ```APIDOC ## GButton Constructor ### Description Constructs a GButton widget with various customization options for its appearance and behavior. ### Parameters - **key** (Key?) - Optional - A unique identifier for the widget. - **active** (bool?) - Optional - Whether this button is currently selected. - **debug** (bool?) - Optional - Enables debug mode, rendering the button in red. - **haptic** (bool?) - Optional - Enables haptic feedback on tap. - **gap** (double?) - Optional - The space between the icon and the text. - **iconColor** (Color?) - Optional - The color of the unselected icon. - **rippleColor** (Color?) - Optional - The splash color displayed when the button is pressed. - **hoverColor** (Color?) - Optional - The highlight color displayed when the button is hovered over. - **iconActiveColor** (Color?) - Optional - The color of the selected icon. - **textColor** (Color?) - Optional - The color of the text label. - **padding** (EdgeInsetsGeometry?) - Optional - The inner padding of the button. - **margin** (EdgeInsetsGeometry?) - Optional - The outer margin around the button. - **textStyle** (TextStyle?) - Optional - Custom TextStyle for the label. - **iconSize** (double?) - Optional - The size of the icon. - **onPressed** (Function?) - Optional - Callback invoked when the button is tapped. - **text** (String) - Optional - Default: '' - The label text displayed below or beside the icon. - **icon** (IconData) - Required - The Material Design icon to display in the button. - **backgroundColor** (Color?) - Optional - The background color when the button is selected. - **duration** (Duration?) - Optional - The duration of the animation. - **curve** (Curve?) - Optional - The animation curve. - **backgroundGradient** (Gradient?) - Optional - A gradient fill for the button background. - **leading** (Widget?) - Optional - A custom widget to replace the default icon. - **borderRadius** (BorderRadius?) - Optional - The corner radius of the button. - **border** (Border?) - Optional - The border for the unselected state. - **activeBorder** (Border?) - Optional - The border for the selected state. - **shadow** (List?) - Optional - Box shadows to apply to the button. - **semanticLabel** (String?) - Optional - An accessibility label for screen readers. - **style** (GnavStyle?) - Optional - Default: GnavStyle.google - The visual style of the button (google or oldSchool). ``` -------------------------------- ### GNav Default Color Example Source: https://github.com/sooxt98/google_nav_bar/blob/master/_autodocs/REFERENCE.md Sets a global default active color for all buttons in the GNav. This color will be used unless overridden by individual GButton properties. ```dart GNav(activeColor: Colors.purple, ...) ``` -------------------------------- ### Basic GButton Usage Source: https://github.com/sooxt98/google_nav_bar/blob/master/_autodocs/api-reference/gbutton.md A simple GButton with an icon and text. This is the most basic way to implement the widget. ```dart GButton( icon: Icons.home, text: 'Home', ) ``` -------------------------------- ### File Statistics for google_nav_bar Source: https://github.com/sooxt98/google_nav_bar/blob/master/_autodocs/MODULE_STRUCTURE.md Provides a summary of lines, symbols, and exports for each file in the package. ```text | File | Lines | Symbols | Exports | |------|-------|---------|---------| | lib/google_nav_bar.dart | 5 | 0 | 2 (GNav, GButton) | | lib/src/gnav.dart | 152 | 2 | GNav, GnavStyle | | lib/src/gbutton.dart | 116 | 1 | GButton | | lib/src/button.dart | 216 | 1 | None (internal) | ``` -------------------------------- ### GNav onTabChange Callback Example Source: https://github.com/sooxt98/google_nav_bar/blob/master/_autodocs/types.md Illustrates how to use the ValueChanged callback for the onTabChange property of GNav. This function is invoked when a new tab is selected, providing the index of the selected tab. ```dart GNav( onTabChange: (index) { print('Tab selected: $index'); setState(() { _selectedIndex = index; }); }, tabs: [/* ... */], ) ``` -------------------------------- ### Project Directory Structure Source: https://github.com/sooxt98/google_nav_bar/blob/master/_autodocs/README.md Overview of the documentation structure for the Google Navigation Bar project. This outlines the purpose of each markdown file and the API reference directory. ```markdown /output/ ├── START_HERE.md ← Begin here ├── INDEX.md ← Detailed navigation ├── README.md ← This file │ ├── REFERENCE.md ← Comprehensive overview ├── EXAMPLES.md ← 30+ code examples ├── configuration.md ← All properties & presets ├── types.md ← Type definitions │ ├── ANIMATION_SYSTEM.md ← Animation specification ├── MODULE_STRUCTURE.md ← File organization ├── PROPERTY_INHERITANCE.md ← Property cascade │ └── api-reference/ ├── gnav.md ← GNav widget ├── gbutton.md ← GButton widget └── button.md ← Button widget (internal) ``` -------------------------------- ### Widget Class Hierarchy Source: https://github.com/sooxt98/google_nav_bar/blob/master/_autodocs/MODULE_STRUCTURE.md Shows the inheritance hierarchy of the main widgets provided by the package. ```text StatefulWidget ├── GNav (_GNavState) ├── GButton (_GButtonState) └── Button (_ButtonState) ``` -------------------------------- ### GButton Constructor Source: https://github.com/sooxt98/google_nav_bar/blob/master/_autodocs/api-reference/gbutton.md Defines the parameters available for creating a GButton widget. Many properties can inherit defaults from the parent GNav widget if not explicitly set. ```dart const GButton({ Key? key, bool? active, bool? debug, bool? haptic, double? gap, Color? iconColor, Color? rippleColor, Color? hoverColor, Color? iconActiveColor, Color? textColor, EdgeInsetsGeometry? padding, EdgeInsetsGeometry? margin, TextStyle? textStyle, double? iconSize, Function? onPressed, String text = '', required IconData icon, Color? backgroundColor, Duration? duration, Curve? curve, Gradient? backgroundGradient, Widget? leading, BorderRadius? borderRadius, Border? border, Border? activeBorder, List? shadow, String? semanticLabel, GnavStyle? style = GnavStyle.google, double? textSize, }) ``` -------------------------------- ### Directly Importable API Surface Source: https://github.com/sooxt98/google_nav_bar/blob/master/_autodocs/MODULE_STRUCTURE.md Shows how to import and use the main GNav and GButton classes, along with the GnavStyle enum. ```dart import 'package:google_nav_bar/google_nav_bar.dart'; // GNav class final nav = GNav( selectedIndex: 0, tabs: [...], ); // GButton class final btn = GButton( icon: Icons.home, text: 'Home', ); // GnavStyle enum final style = GnavStyle.google; // or .oldSchool ``` -------------------------------- ### GButton Dependencies Source: https://github.com/sooxt98/google_nav_bar/blob/master/_autodocs/MODULE_STRUCTURE.md Imports required for the GButton widget, including Flutter material, haptic feedback, and the Google Nav Bar core. ```dart import 'package:flutter/material.dart'; import 'package:flutter/services.dart' show HapticFeedback; import 'package:google_nav_bar/google_nav_bar.dart'; import 'button.dart'; ``` -------------------------------- ### GNav Constructor Source: https://github.com/sooxt98/google_nav_bar/blob/master/_autodocs/api-reference/gnav.md The GNav widget constructor allows for extensive customization of the navigation bar's appearance and behavior. It takes a list of GButton widgets and various styling properties. ```APIDOC ## GNav Constructor ### Description Initializes a new instance of the GNav widget. ### Parameters - **tabs** (List) - Required - List of tab buttons to display in the navigation bar. - **selectedIndex** (int) - Optional - The index of the currently selected tab (0-based). Defaults to 0. - **onTabChange** (ValueChanged?) - Optional - Callback function invoked when tab selection changes, receives selected index. - **gap** (double) - Optional - Spacing between icon and text within tab buttons. Defaults to 0. - **padding** (EdgeInsetsGeometry) - Optional - Padding inside each tab button. Defaults to EdgeInsets.all(25). - **activeColor** (Color?) - Optional - Color of the selected icon and text; overridden by GButton properties. - **color** (Color?) - Optional - Color of unselected icons; overridden by GButton properties. - **rippleColor** (Color) - Optional - Ripple/splash color when tabs are pressed. Defaults to Colors.transparent. - **hoverColor** (Color) - Optional - Highlight color on hover/press. Defaults to Colors.transparent. - **backgroundColor** (Color) - Optional - Background color of the entire navigation bar. Defaults to Colors.transparent. - **tabBackgroundColor** (Color) - Optional - Background color of individual selected tabs; overridden by GButton properties. Defaults to Colors.transparent. - **tabBorderRadius** (double) - Optional - Border radius for tab button corners. Defaults to 100.0. - **iconSize** (double?) - Optional - Size of the icon; overridden by GButton properties. - **textStyle** (TextStyle?) - Optional - Text styling for tab labels; overridden by GButton properties. - **curve** (Curve) - Optional - Animation curve for tab transitions. Defaults to Curves.easeInCubic. - **tabMargin** (EdgeInsetsGeometry) - Optional - Margin around each tab button. Defaults to EdgeInsets.zero. - **debug** (bool) - Optional - Enable debug mode (renders tabs in red). Defaults to false. - **duration** (Duration) - Optional - Animation duration for tab transitions. Defaults to Duration(milliseconds: 500). - **tabBorder** (Border?) - Optional - Border decoration for unselected tabs. - **tabActiveBorder** (Border?) - Optional - Border decoration for the selected tab. - **tabShadow** (List?) - Optional - Shadow effects for tab buttons. - **haptic** (bool) - Optional - Enable haptic feedback (vibration) on tab selection. Defaults to true. - **tabBackgroundGradient** (Gradient?) - Optional - Gradient fill for selected tab background; overridden by GButton properties. - **mainAxisAlignment** (MainAxisAlignment) - Optional - How tabs are aligned horizontally (spaceBetween distributes tabs evenly). Defaults to MainAxisAlignment.spaceBetween. - **style** (GnavStyle?) - Optional - Visual style: google (text expands on selection) or oldSchool (column layout). Defaults to GnavStyle.google. - **textSize** (double?) - Optional - Font size override for tab text labels. ``` -------------------------------- ### GButton with Custom Leading Widget Source: https://github.com/sooxt98/google_nav_bar/blob/master/_autodocs/api-reference/gbutton.md Shows how to replace the default icon with a custom widget, such as a Badge with notification count. This is useful for adding interactive elements or indicators to the button. ```dart GButton( icon: Icons.notifications, text: 'Notifications', leading: Badge( badgeContent: Text('5'), child: Icon(Icons.notifications), ), ) ``` -------------------------------- ### Add google_nav_bar to pubspec.yaml Source: https://github.com/sooxt98/google_nav_bar/blob/master/README.md To use the google_nav_bar package, add it to your project's pubspec.yaml file under dependencies. ```yaml dependencies: google_nav_bar: ^5.0.7 ``` -------------------------------- ### GNav Widget with Google Style Animation Source: https://github.com/sooxt98/google_nav_bar/blob/master/_autodocs/MANIFEST.txt Illustrates the 'google' style for GNav, which features a text expansion animation when a tab is selected. This provides a dynamic and visually engaging user experience. ```dart GNav( curve: Curves.easeIn, duration: 300, gap: 8, iconSize: 24, padding: EdgeInsets.symmetric(horizontal: 12, vertical: 5), activeColor: Colors.white, tabBackgroundColor: Colors.grey.shade800, color: Colors.grey, tabs: [ GButton(icon: Icons.home, text: 'Home'), GButton(icon: Icons.search, text: 'Search'), GButton(icon: Icons.settings, text: 'Settings'), GButton(icon: Icons.person, text: 'Profile'), ] ) ``` -------------------------------- ### Print GButton Property Values Source: https://github.com/sooxt98/google_nav_bar/blob/master/_autodocs/PROPERTY_INHERITANCE.md Inspect the visual appearance of a GButton to verify if property overrides have been applied correctly. This is useful when unsure about the outcome of custom settings. ```dart GButton( icon: Icons.home, text: 'Home', padding: EdgeInsets.all(20), // If unsure whether override worked: // Check the button's visual appearance ) ``` -------------------------------- ### Initialize AnimationController Source: https://github.com/sooxt98/google_nav_bar/blob/master/_autodocs/ANIMATION_SYSTEM.md Initialize the AnimationController in initState. It requires a vsync provider and a duration, and a listener is added to trigger rebuilds on every frame. ```dart expandController = AnimationController( vsync: this, // TickerProviderStateMixin mixin required duration: widget.duration // From GNav/GButton configuration )..addListener(() => setState(() {})); // Rebuild on every frame ``` -------------------------------- ### Google Nav Bar with Badges Source: https://github.com/sooxt98/google_nav_bar/blob/master/_autodocs/EXAMPLES.md Integrate the 'badges' package to display notification counts or indicators on navigation items. Ensure the 'badges' package is imported. ```dart import 'package:badges/badges.dart'; GNav( selectedIndex: _selectedIndex, onTabChange: (index) => setState(() => _selectedIndex = index), tabs: [ GButton( icon: Icons.home, text: 'Home', ), GButton( icon: Icons.notifications, text: 'Notifications', leading: Badge( badgeContent: Text('3'), badgeColor: Colors.red, child: Icon(Icons.notifications), ), ), GButton( icon: Icons.person, text: 'Profile', ), ], ) ``` -------------------------------- ### GButton with Custom Avatar Source: https://github.com/sooxt98/google_nav_bar/blob/master/_autodocs/api-reference/gbutton.md Illustrates using a custom avatar as the leading widget for a GButton. This is ideal for profile-related navigation items. ```dart GButton( icon: Icons.person, text: 'Profile', leading: CircleAvatar( radius: 12, backgroundImage: NetworkImage('https://example.com/avatar.jpg'), ), ) ``` -------------------------------- ### Callback Types Used Source: https://github.com/sooxt98/google_nav_bar/blob/master/_autodocs/MODULE_STRUCTURE.md Lists the types of callbacks used within the package, including standard Flutter and Dart types. ```text - ValueChanged — Standard Flutter type from material.dart - VoidCallback — Standard Flutter type from foundation.dart - Function — Dart core type (untyped callbacks in GButton.onPressed) ``` -------------------------------- ### Google Material Style (Classic) Configuration Source: https://github.com/sooxt98/google_nav_bar/blob/master/_autodocs/configuration.md Configure the navigation bar with a classic Google Material Design look, featuring distinct active and ripple colors, and a pill-shaped tab background. ```dart GNav( activeColor: Colors.deepPurple, color: Colors.grey[600], rippleColor: Colors.deepPurple.withOpacity(0.1), hoverColor: Colors.deepPurple.withOpacity(0.05), tabBackgroundColor: Colors.deepPurple.withOpacity(0.1), tabBorderRadius: 15, gap: 8, padding: EdgeInsets.symmetric(horizontal: 20, vertical: 12), tabs: [/* ... */], ) ``` -------------------------------- ### Customized GButton Source: https://github.com/sooxt98/google_nav_bar/blob/master/_autodocs/api-reference/gbutton.md Demonstrates customizing the appearance of a GButton with specific colors, text styles, and padding. Use this to match the button's look to your application's theme. ```dart GButton( icon: Icons.favorite, text: 'Likes', iconColor: Colors.grey, iconActiveColor: Colors.red, textColor: Colors.red, backgroundColor: Colors.red.withOpacity(0.1), padding: EdgeInsets.symmetric(horizontal: 20, vertical: 12), ) ``` -------------------------------- ### GNav Widget with Haptic Feedback Source: https://github.com/sooxt98/google_nav_bar/blob/master/_autodocs/MANIFEST.txt Demonstrates enabling haptic feedback for tab selections in the GNav widget. This provides tactile confirmation to the user upon interaction. ```dart GNav( gap: 8, iconSize: 24, padding: EdgeInsets.symmetric(horizontal: 12, vertical: 5), activeColor: Colors.white, tabBackgroundColor: Colors.grey.shade800, color: Colors.grey, haptic: true, tabs: [ GButton(icon: Icons.home, text: 'Home'), GButton(icon: Icons.search, text: 'Search'), GButton(icon: Icons.settings, text: 'Settings'), GButton(icon: Icons.person, text: 'Profile'), ] ) ``` -------------------------------- ### Google Style Button Rendering Source: https://github.com/sooxt98/google_nav_bar/blob/master/_autodocs/api-reference/button.md Illustrates the layout for the default Google navigation bar style. Shows the unselected and selected states with icon and text. ```plaintext Unselected: [Icon] Selected: [Icon] [Text] ``` -------------------------------- ### Source Code Structure Source: https://github.com/sooxt98/google_nav_bar/blob/master/_autodocs/INDEX.md This code block shows the directory structure of the Google Nav Bar package, indicating the location of key files like the entry point and internal modules. ```plaintext lib/ ├── google_nav_bar.dart # Entry point (exports GNav, GButton) └── src/ ├── gnav.dart # GNav widget + GnavStyle enum ├── gbutton.dart # GButton widget └── button.dart # Button internal widget (animation) ``` -------------------------------- ### Navigation Bar with Semantic Labels Source: https://github.com/sooxt98/google_nav_bar/blob/master/_autodocs/EXAMPLES.md Enhances accessibility by providing semantic labels for each GButton, which are read by screen readers. Ensure appropriate labels are used for clarity. ```dart GNav( selectedIndex: _selectedIndex, onTabChange: (index) => setState(() => _selectedIndex = index), tabs: [ GButton( icon: Icons.home, text: 'Home', semanticLabel: 'Home page', ), GButton( icon: Icons.search, text: 'Search', semanticLabel: 'Search functionality', ), GButton( icon: Icons.person, text: 'Profile', semanticLabel: 'User profile', ), ], ) ``` -------------------------------- ### GNav Build Method with Property Resolution Source: https://github.com/sooxt98/google_nav_bar/blob/master/_autodocs/PROPERTY_INHERITANCE.md The GNav build method iterates through tabs, resolving multiple properties using null coalescing for each GButton. ```dart GNav.build() { return Container( child: Row( children: widget.tabs .map((t) => GButton( // All ?? resolutions happen here gap: t.gap ?? widget.gap, // Single evaluation // ... 20+ more properties ... )) .toList(), ), ); } ``` -------------------------------- ### Rule 4: Non-Overridable Properties Source: https://github.com/sooxt98/google_nav_bar/blob/master/_autodocs/PROPERTY_INHERITANCE.md Demonstrates that certain properties like mainAxisAlignment are fixed at the GNav level and cannot be overridden by individual GButton components. ```dart GNav( mainAxisAlignment: MainAxisAlignment.spaceBetween, // Cannot be overridden per-button tabs: [ GButton( // No way to override mainAxisAlignment here ) ], ) ``` -------------------------------- ### GNav.build() Property Resolution Source: https://github.com/sooxt98/google_nav_bar/blob/master/_autodocs/PROPERTY_INHERITANCE.md Shows how GNav.build() resolves the iconActiveColor property using the null coalescing operator. ```dart GNav.build() { return GButton( // ... other properties ... iconActiveColor: t.iconActiveColor ?? widget.activeColor, // ^^^^^^^^^^^^^^^^^ // null (not specified) ) } ``` -------------------------------- ### GNav Widget with Custom Gap and Padding Source: https://github.com/sooxt98/google_nav_bar/blob/master/_autodocs/MANIFEST.txt Shows how to adjust the gap between icons and text, and the padding around each tab in the GNav widget. This allows for fine-tuning the visual spacing. ```dart GNav( gap: 12, iconSize: 28, padding: EdgeInsets.symmetric(horizontal: 20, vertical: 8), activeColor: Colors.white, tabBackgroundColor: Colors.grey.shade800, color: Colors.grey, tabs: [ GButton(icon: Icons.home, text: 'Home'), GButton(icon: Icons.search, text: 'Search'), GButton(icon: Icons.settings, text: 'Settings'), GButton(icon: Icons.person, text: 'Profile'), ] ) ``` -------------------------------- ### Package Exports Source: https://github.com/sooxt98/google_nav_bar/blob/master/_autodocs/MODULE_STRUCTURE.md Defines the public API of the google_nav_bar package by exporting key widgets and enums. ```dart export 'src/gnav.dart'; // GNav, GnavStyle export 'src/gbutton.dart'; // GButton ```