GoogleNavBar is a Flutter widget designed by Aurelien Salomon and developed by sooxt98

Overview

google_nav_bar

    

A modern google style nav bar for flutter.

google_nav_bar

GoogleNavBar is a Flutter widget designed by Aurelien Salomon and developed by sooxt98.

Getting Started

Add this to your package's pubspec.yaml file:

...
dependencies:
  google_nav_bar: ^5.0.5
  

Now in your Dart code, you can use:

import 'package:google_nav_bar/google_nav_bar.dart';

Usage

Style your tab globally with GNav's attribute, if you wish to style tab separately, use GButton's attribute

GNav(
  rippleColor: Colors.grey[800], // tab button ripple color when pressed
  hoverColor: Colors.grey[700], // tab button hover color
  haptic: true, // haptic feedback
  tabBorderRadius: 15, 
  tabActiveBorder: Border.all(color: Colors.black, width: 1), // tab button border
  tabBorder: Border.all(color: Colors.grey, width: 1), // tab button border
  tabShadow: [BoxShadow(color: Colors.grey.withOpacity(0.5), blurRadius: 8)], // tab button shadow
  curve: Curves.easeOutExpo, // tab animation curves
  duration: Duration(milliseconds: 900), // tab animation duration
  gap: 8, // the tab button gap between icon and text 
  color: Colors.grey[800], // unselected icon color
  activeColor: Colors.purple, // selected icon and text color
  iconSize: 24, // tab button icon size
  tabBackgroundColor: Colors.purple.withOpacity(0.1), // selected tab background color
  padding: EdgeInsets.symmetric(horizontal: 20, vertical: 5), // navigation bar padding
  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',
    )
  ]
)

View the example folder

There are 4 different use case included in the /example directory, go try it out!

Comments
  • It won't desapear when opening new page

    It won't desapear when opening new page

    Hi,

    so I am finding an issue in which when preasing navigation from the home page the bottom navigation bar won't desapare and I can't figure out why.

    My code:

    import` 'package:flutter/material.dart';
    import 'package:google_nav_bar/google_nav_bar.dart';
    import 'package:hopeapp/screens/give_page.dart';
    import 'package:hopeapp/screens/home_screen.dart';
    import 'package:hopeapp/screens/morepage.dart';
    import 'package:flutter/services.dart';
    
    void main() => runApp(
          new MaterialApp(
            darkTheme: ThemeData.light(),
            home: MyApp(),
          ),
        );
    
    class MyApp extends StatefulWidget {
      @override
      State<StatefulWidget> createState() {
        return MyAppState();
      }
    }
    
    class MyAppState extends State<MyApp> {
      int _selectedPage = 0;
      final _pageOptions = [
        HomeScreenTabBar(),
        GivePage(),
        MorePage(),
      ];
    
      @override
      Widget build(BuildContext context) {
        SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
          statusBarColor: Colors.grey[900],
          statusBarIconBrightness: Brightness.light, // not working
          statusBarBrightness: Brightness.dark,
          // works
        ));
        return MaterialApp(
          title: 'Hope and Anchor App',
          theme: ThemeData(
            primarySwatch: Colors.yellow,
            primaryColor: Colors.yellow,
            brightness: Brightness.dark,
            accentColor: Colors.yellow,
          ),
          home: Scaffold(
            body: Center(
              child: _pageOptions.elementAt(_selectedPage),
            ),
            bottomNavigationBar: Container(
              decoration: BoxDecoration(color: Colors.grey[900], boxShadow: [
                BoxShadow(blurRadius: 20, color: Colors.black.withOpacity(0.0))
              ]),
              child: SafeArea(
                child: Padding(
                  padding:
                      const EdgeInsets.symmetric(horizontal: 20.0, vertical: 10),
                  child: GNav(
                      gap: 1,
                      activeColor: Colors.yellow,
                      iconSize: 24,
                      padding: EdgeInsets.symmetric(horizontal: 10, vertical: 8),
                      duration: Duration(milliseconds: 800),
                      tabBackgroundColor: Colors.black,
                      tabs: [
                        GButton(
                          icon: Icons.video_library,
                          iconColor: Colors.grey[500],
                          text: 'Home',
                        ),
                        GButton(
                          icon: Icons.favorite_border,
                          iconColor: Colors.grey[500],
                          text: 'Give',
                        ),
                        GButton(
                          icon: Icons.menu_rounded,
                          iconColor: Colors.grey[500],
                          text: 'More',
                        ),
                      ],
                      selectedIndex: _selectedPage,
                      onTabChange: (int index) {
                        setState(() {
                          _selectedPage = index;
                        });
                      }),
                ),
              ),
            ),
            backgroundColor: Colors.grey[900],
          ),
        );
      }
    }
    
    opened by lucasagazzani 14
  • how to use it in other language

    how to use it in other language

    hello everyone,

    I use the google_nav_bar package, it is good and very nice.

    but when I convert the direction of the app to (right to left) the text is making an error.

    like the photo below:

    https://i.ibb.co/D183V9b/20200713-170022.jpg

    how can I solve that ??

    and I am sorry because my English is not very good

    opened by faress123 13
  • setState() called after dispose()

    setState() called after dispose()

    E/flutter ( 7192): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: setState() called after dispose(): _GNavState#fb094(lifecycle state: defunct, not mounted) E/flutter ( 7192): This error happens if you call setState() on a State object for a widget that no longer appears in the widget tree (e.g., whose parent widget no longer includes the widget in its build). This error can occur when code calls setState() from a timer or an animation callback. E/flutter ( 7192): The preferred solution is to cancel the timer or stop listening to the animation in the dispose() callback. Another solution is to check the "mounted" property of this object before calling setState() to ensure the object is still in the tree. E/flutter ( 7192): This error might indicate a memory leak if setState() is being called because another object is retaining a reference to this State object after it has been removed from the tree. To avoid memory leaks, consider breaking the reference to this object during dispose().

    opened by pradeep14598 11
  • Big grey box when switching pages in release mode

    Big grey box when switching pages in release mode

    I have a big grey box which appear less than one second when switching between page, in release mode or in profile mode.

    In profile I was able to get this message error :

    Another exception was thrown: Instance of 'ft' or uid=10419(com.***) 1.ui identical 23 lines

    opened by louia 10
  • Feature request: Tooltip or Semantic Label

    Feature request: Tooltip or Semantic Label

    Hey @sooxt98!

    Writing to you again! Thank you for the great package, but could you add some semantics? Because at the moment GButton doesn't allow us to add any tooltip or semantic tag, so Accessibility Checker or any other semantic analysis SW will not recognize the meaning of this button... Semantics are articularly helpful for people with visual impairments but are also great for testing. A Tooltip would be perfect, but the semanticLabel property should be okay too.

    Thanks!

    opened by tsinis 6
  • Can you provide the code of one of your examples?

    Can you provide the code of one of your examples?

    At the beginning, when you change tabs it appears you're using a TabController? I'm trying to make the TabController animate the GoogleNavBar while the user swipes the screen, just like in your example. Thanks!

    image of tabs chaning

    opened by lucasmaffazioli 6
  • How to center the icon without text?

    How to center the icon without text?

    As you can see in the image, the text has been removed, but the icon is not centered. image

    I have set the gap to zero.

    GNav(
    	iconSize: 24,
    	padding: EdgeInsets.symmetric(horizontal: 20, vertical: 12),
    	duration: Duration(milliseconds: 400),
    	gap: 0,
    	tabs: [
    	  GButton(
    		icon: Icons.home,
    		backgroundColor: Colors.white,
    		iconColor: Colors.black,
    		iconActiveColor: Colors.purple,
    		borderRadius: BorderRadius.all(Radius.circular(30)),
    	  ),
    	],
    	selectedIndex: selectedScreenIndex,
    	onTabChange: (index) {
    	  setState(() {
    		selectedScreenIndex = index;
    	  });
    	},
    ),
    
    opened by PINHOf 5
  • GButton onPressed doesn't do anything

    GButton onPressed doesn't do anything

    Hi, first of all I really like this widget, however I doesn't use it as a bottom navigation bar, but as an appbar, I have a problem for GButton the onPressed function doesn't do anything

    opened by eva-cn 5
  • Allow icon to take Widget, not IconData

    Allow icon to take Widget, not IconData

    We can refactor GButton.icon to be a Widget and apply the icon settings as an IconTheme. This matches the semantics of other material widgets, and in our case, allows us to put a dynamic icon widget in GNav.

    Is this a PR you would accept?

    enhancement 
    opened by lukepighetti 5
  • Skip animation on middle element when you go from first one to last one

    Skip animation on middle element when you go from first one to last one

    Hi, I really like your lib and the amount of customization. I have a PageView as a body and use your package as a bottom navigation bar. I have 3 pages, when I go from 1 -> 3 then the 2nd one also gets highlighted on the navigation bar, which doesn't look very nice.

    Would it be possible to fix it or add a new param? Let me know if you need a gif, but I guess the description is clear. If you are busy maybe I will be able to fix it and add PR, let me know your thoughts.

    opened by afijal 5
  • Updating selectedIndex does not update the index

    Updating selectedIndex does not update the index

    Previously on 4.0.2, if I called setState() on a value passed to GNav, it would also animate the tab to the new index. This no longer works with 5.0.1.

    A quick example where I use a PageController listener to update _index:

    int _index;
    
    @override
    void initState() {
        _index = widget.pageController?.initialPage ?? 0;
        widget.pageController?.addListener(_pageControllerListener);
        super.initState();
    }
    
    @override
    void dispose() {
        widget.pageController?.removeListener(_pageControllerListener);
        super.dispose();
    }
    
    void _pageControllerListener() {
        setState(() => _index = widget.pageController.page.round());
    }
    
    @override
    Widget build(BuildContext context) => GNav(
        selectedIndex: _index,
        ... // Additional GNav parameters
    );
    

    The initially selected index is correct, but just does not update unless you tap on the GButton in the navigation bar.

    opened by JagandeepBrar 4
  • How to stop clicking and changing status

    How to stop clicking and changing status

    I am trying to prevent the user from entering screen number 2, and I succeeded in that by controlling the screenIndex variable , but in all cases the nav button is activated and its state changes! . How can I prevent the nav but from changing its state. Note : i already tried to set active to false .

    opened by Hesham-Dev-LY 0
  • Debug console shows this message

    Debug console shows this message "ensureControlAlpha: for ITYPE_NAVIGATION_BAR" when GNav does not show?

    So in my app, I have the GNav bar to navigate between some pages. I use Firebase Auth to sign in users. Right after a user signs in, the app navigates to the main page where the GNav is.

    class MainPage extends StatefulWidget
    {
      const MainPage({Key? key}) : super(key: key);
    
      @override
      State<MainPage> createState() => _MainPageState();
    }
    
    class _MainPageState extends State<MainPage>
    {
      final _utils = Utils();
      int _gNavBarIndex = 0;
      final _listPages = [const HomePage(), const Rides(), const ProfilePage()];
    
      @override
      Widget build(BuildContext context)
      {
        return Scaffold(
          backgroundColor: Colors.blueGrey[100],
          body: _listPages[_gNavBarIndex],
          bottomNavigationBar: Container(
            decoration: BoxDecoration(
              color: _utils.darkBlueGrey,
              borderRadius: BorderRadius.circular(16)
            ),
            child:  Padding(
              padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 10),
              child: GNav(
                backgroundColor: _utils.darkBlueGrey!,
                color: Colors.tealAccent,
                activeColor: _utils.titleTextColor,
                tabBackgroundColor: Colors.white.withOpacity(0.5),
                gap: 10,
                padding: const EdgeInsets.all(8.0),
                selectedIndex: _gNavBarIndex,
                onTabChange: (index) {
                  setState(() => _gNavBarIndex = index);
                },
                tabs: const [
                  GButton(
                    icon: Icons.home,
                    text: 'Home',
                  ),
                  GButton(
                    icon: Icons.car_crash_outlined,
                    text: 'Rides',
                  ),
                  GButton(
                    icon: Icons.person,
                    text: 'Profile',
                  )
                ],
              ),
            ),
          ),
        );
      }
    }
    

    so from here, the user can now see the HomePage, one of the tabs of the GNav bar. But each time a user logs out and laogs back in, the GNav bar does not appear when they log back in. The debug console shows this message, "ensureControlAlpha: for ITYPE_NAVIGATION_BAR" and I have searched for it and there aren't any information about this message. As a user, I have to close the app and relaunch it, then the GNav bar appears again. Does anyone know how I can fix this issue?

    opened by Mleendox 1
  • Added extension, animateTo, clickIndex

    Added extension, animateTo, clickIndex

    Similar to https://pub.dev/packages/convex_bottom_bar

    I have made 4 useful updates:

    1. animteTo which will only change the active index without any firing tab events.
    2. clickTo which will fire click event to wanted index similar to a manual click.
    3. Made the state public so we can make keys to control the nav bar.
    4. Added extensions so now you can do the following:
    context.gNav?.animateTo(tabsRouter.activeIndex);
    context.gNav?.clickIndex(tabsRouter.activeIndex);
    

    or through using keys:

    appBarKey.currentState?.animateTo(tabsRouter.activeIndex),
    appBarKey.currentState?.clickIndex(tabsRouter.activeIndex),
    
    opened by YDA93 0
  • Make the state class _GNavState public

    Make the state class _GNavState public

    This is a PR of an issue in open a few minutes ago (#77 )

    This allows me to do the following in my code:

      @override
      Widget build(BuildContext context) {
        final appBarKey = GlobalKey<GNavState>(); // This was not possible with the state being private
    
        const _kPages = <String, IconData>{
          'Home': Icons.home,
          'Explore': Icons.search,
          'Alerts': Icons.notifications,
          'Leagues': CommunityMaterialIcons.trophy
        };
    
        return Consumer(
          builder: (context, ref, child) {
            var currentPageIndex = ref.watch(bottomNavigationProvider); //My Navigation Drawer can update this value when a user clicks on a menu item on it
    
            if (currentPageIndex < _kPages.length) {
              appBarKey.currentState?.animateTo(currentPageIndex); // Now I can animate the bottom navigation drawer to the index which the navigation drawer is also pointing to
            }
    
            return GNav(
              key: appBarKey,
              tabs: buildGNavButtons(_kPages),
              activeColor: Colors.redAccent,
              gap: 8.0,
              onTabChange: (int i) =>SonicNavigator.navigateToPage(ref, i),
            );
          },
        );
      }
    
    opened by robertmrobo 2
Owner
null
NumberPicker is a custom widget designed for choosing an integer or decimal number by scrolling spinners.

NumberPicker NumberPicker is a custom widget designed for choosing an integer or decimal number by scrolling spinners. Example: (See example for more)

Marcin Szałek 273 Nov 4, 2022
A flutter carousel widget, support infinite scroll, and custom child widget.

carousel_slider A carousel slider widget. Features Infinite scroll Custom child widgets Auto play Supported platforms Flutter Android Flutter iOS Flut

Bart T 1 Nov 25, 2021
Progress Dialog widget for flutter projects with ability to customize loading widget, background color and background blur.

DISCONTINUED Checkout ArsDialog ars_progress_dialog Customizable progress dialog for Flutter applications with smooth animation for background dim col

Arsam 8 Apr 15, 2022
A simple Flutter widget to add in the widget tree when you want to show nothing, with minimal impact on performance.

nil A simple widget to add in the widget tree when you want to show nothing, with minimal impact on performance. Why? Sometimes, according to a condit

Romain Rastel 127 Dec 22, 2022
A Flutter Widget to make interactive timeline widget.

Bubble Timeline Package A Flutter Widget to make interactive timeline widget. This widget can be used to make Event Timelines, or Timelines for certai

Vansh Goel 12 Sep 22, 2022
📸 Easy to use yet very customizable zoomable image widget for Flutter, Photo View provides a gesture sensitive zoomable widget.

?? Easy to use yet very customizable zoomable image widget for Flutter, Photo View provides a gesture sensitive zoomable widget. Photo View is largely used to show interacive images and other stuff such as SVG.

Blue Fire 1.7k Jan 7, 2023
A widget lib that the widget in this lib can react to flutter ScrollController's offset

Language: English | 中文简体 linked_scroll_widgets A lib full of widgets that can react to the scrollController's offset change,to custom your UI effect.

WenJingRui 8 Oct 16, 2022
Full customable rolling switch widget for flutter apps based on Pedro Massango's 'crazy-switch' widget

lite_rolling_switch Full customable rolling switch widget for flutter apps based on Pedro Massango's 'crazy-switch' widget https://github.com/pedromas

Eduardo Muñoz 48 Dec 1, 2022
A Flutter widget that will give a Glitch Animation Effect to it's child widget.

GlitchEffect A Flutter widget that will give a Glitch Animation Effect to it's child widget. Installation Add the latest version of package to your pu

Sameer Singh 6 Nov 25, 2022
Widget, that can make any static located widget hidable

Installing See the official installing guidline from hidable/install Usage & Overview To start using Hidable widget, we have to create a ScrollControl

Anon 18 Dec 16, 2022
A widget that allow user resize the widget with drag

Flutter-Resizable-Widget A widget that allow user resize the widget with drag Note: this widget uses Getx Example bandicam.2021-11-11.12-34-41-056.mp4

MohammadAminZamani.afshar 22 Dec 13, 2022
Various Flutter widgets that are developed by Google but not by the core Flutter team

Flutter widgets This repository contains the source code for various Flutter widgets that are developed by Google but not by the core Flutter team. Is

Google 1.1k Jan 7, 2023
The SpannableGrid is a Flutter widget that allows its cells to span columns and rows and supports moving cells inside the grid.

Spannable Grid The SpannableGrid is a Flutter widget that allows its cells to span columns and rows and supports moving cells inside the grid. Feature

Evgeny Cherkasov 17 Nov 7, 2022
A widget that can be dragged and scrolled in a single gesture and snapped to a list of extents.

Sliding Sheet A widget that can be dragged and scrolled in a single gesture and snapped to a list of extents. Click here to view the full example. Ins

null 396 Mar 10, 2022
React hooks for Flutter. Hooks are a new kind of object that manages a Widget life-cycles. They are used to increase code sharing between widgets and as a complete replacement for StatefulWidget.

English | Português Flutter Hooks A Flutter implementation of React hooks: https://medium.com/@dan_abramov/making-sense-of-react-hooks-fdbde8803889 Ho

Remi Rousselet 2.6k Dec 29, 2022
Flutter debug helper widget with common and custom actions

Flutter debug helper widget with common and custom actions

Stanislav Ilin 43 Dec 7, 2022
A draggable Flutter widget that makes implementing a Sliding up and fully-stretchable much easier.

Draggable Home A draggable Flutter widget that makes implementing a Sliding up and fully-stretchable much easier! Based on the Scaffold and Sliver. Us

Devs On Flutter 106 Dec 12, 2022
Flutter widget for fetching, caching and refetching asynchronous data.

Flutter library for fetching, caching and invalidating asynchronous data Quick Features Fetch asynchronous data Data invalidation Optimistic response

null 32 Dec 24, 2022
An extensive snap tool/widget for Flutter that allows very flexible snap management and snapping between your widgets.

An extensive snap tool/widget for Flutter that allows very flexible snap management and snapping between your widgets.

AliYigitBireroglu 101 Dec 16, 2022