cuberto_bottom_bar 1.1.1+2

  • Readme
  • Changelog
  • Example
  • Installing
  • 91

Cuberto Bottom Bar #

CubertoBottomBar widget in Flutter.

CubertoBottomBar - Default Style #

CubertoBottomBar - Default Style

CubertoBottomBar - Faded Style #

CubertoBottomBar - Faded Style

Getting Started #

dependencies:
  ...
  cuberto_bottom_bar: ^1.1.1+1

Limitations #

For now this is limited to more than 1 tab, and less than 5. So 2-4 tabs. textColor will only be applied in the case of STYLE_NORMAL, in case of STYLE_FADED_BACKGROUND the tabColor will be set as textColor,(if tabColor is not set inactiveColor will be set)

manually drawer or endDrawer has to be added and then respective drawer has to be added in CubertoBottomBar ( CubertoDrawer.NO_DRAWER for no drawer, CubertoDrawer.START_DRAWER for drawer and CubertoDrawer.END_DRAWER for endDrawer)

By default the drawer overlaps the CubertoBottomBar, for that margin: EdgeInsets.only(bottom: 60.0) has been added. (Please check with the example)

The values in onTabChangedListener: (position, title, color) (position, title and color are null at the beginning), but gets the value once the tab is clicked.

Basic Usage #

Adding the widget

bottomNavigationBar: CubertoBottomBar(
        inactiveIconColor: inactiveColor,
        tabStyle: CubertoTabStyle.STYLE_FADED_BACKGROUND, // By default its CubertoTabStyle.STYLE_NORMAL
        selectedTab: currentPage, // By default its 0, Current page which is fetched when a tab is clickd, should be set here so as the change the tabs, and the same can be done if willing to programmatically change the tab.
        drawer: CubertoDrawer.NO_DRAWER, // By default its NO_DRAWER (Availble START_DRAWER and END_DRAWER as per where you want to how the drawer icon in Cuberto Bottom bar)
        tabs: tabs
            .map((value) => TabData(
                iconData: value.icon,
                title: value.title,
                tabColor: value.color,
                tabGradient: value.gradient))
            .toList(),
        onTabChangedListener: (position, title, color) {
          setState(() {
            currentPage = position;
            currentTitle = title;
            currentColor = color;
          });
        },
      ),

class Tabs {
  final IconData icon;
  final String title;
  final Color color;
  final Gradient gradient;

  Tabs(this.icon, this.title, this.color, this.gradient);
}

getGradient(Color color) {
  return LinearGradient(
      colors: [color.withOpacity(0.5), color.withOpacity(0.1)],
      stops: [0.0, 0.7]);
}

List<Tabs> tabs = new List();
tabs.add(Tabs(Icons.home,"Home",Colors.deepPurple,getGradient(Colors.deepPurple),));
tabs.add(Tabs(Icons.search, "Search", Colors.pink, getGradient(Colors.pink)));
tabs.add(Tabs(Icons.alarm, "Alarm", Colors.amber, getGradient(Colors.amber)));
tabs.add(Tabs(Icons.settings, "Settings", Colors.teal, getGradient(Colors.teal)));

TabData #

iconData -> Icon to be used for the tab title -> String to be used for the tab tabColor: -> Colors to be used for background and label when STYLE_FADED_BACKGROUND is chosen tabGradient: -> Set a gradient to the selected tab which works only with STYLE_FADED_BACKGROUND . onClick -> Optional function to be used when the circle itself is clicked, on an active tab

Attributes #

Required #

  • tabs -> List of TabData objects
  • onTabChangedListener -> Function to handle a tap on a tab, receives int position, String title and Color tabColor (if not set will return inactiveIconColor in both STYLE_NORMAL and STYLE_FADED_BACKGROUND)

Optional #

  • selectedTab -> Defaults to 0 (initialSelection has been changed to selectedTab) Current page which is fetched when a tab is clickd, should be set here so as the change the tabs, and the same can be done if willing to programmatically change the tab.
  • inactiveIconColor -> Defaults to null, derives from Theme
  • textColor -> Defaults to Colors.white
  • barBackgroundColor -> Defaults to null, derives from Theme
  • barBorderRadius -> Default to null (Scaffold's background color must be different than barBackgroundColor)
  • tabStyle -> Defaults to CubertoTabStyle.STYLE_NORMAL
  • drawer -> Defaults to CubertoDrawer.NO_DRAWER (can be set as CubertoDrawer.START_DRAWER or CubertoDrawer.END_DRAWER as per the need for the placement of drawer icon)
  • key -> Defaults to null
  • padding -> Defaults to EdgeInsets.symmetric(horizontal: 12.0, vertical: 8.0). Modifies the inner padding of the bar.
  • barShadow -> By default, adds a shadow to the bar. Can be disabled with an empty list, or modified with the desired BoxShadow.

Theming #

The bar will attempt to use your current theme out of the box, however you may want to theme it. Here are the attributes:

CubertoBottom BarTheming - STYLE_FADED_BACKGROUND #

Cuberto Bottom Bar Theming - STYLE_FADED_BACKGROUND

Cuberto Bottom Bar Theming - STYLE_NORMAL #

Cuberto Bottom Bar Theming - STYLE_NORMAL

Showcase #

If using this package in a live app, let me know and I'll add you app here.

Inspiration #

This package was inspired by a design on dribbble by Sourabh Gupta and the faded background style from Aurelien Salomon: https://github.com/sourabhgupta811/CubertoBottomBar https://dribbble.com/shots/5925052-Google-Bottom-Bar-Navigation-Pattern https://www.instagram.com/p/BtyUbSkBlnF/

Contributing #

Contributions are welcome, please submit a PR :)

[1.1.1+2] #

  • Some issue fixes.

[1.1.1+1] #

  • Added tabGradient property to add background gradient to the selcted tab.

[1.1.1] #

  • Added feature to programmatically change the tab.
  • initialSelection has been changed to selectedTab which has the set with the current index / position of the tab fetched from onTabChangedListener.

[1.1.0] #

  • Breaking change: Migration to AndroidX
  • Breaking change: Minor UI tweaks
  • Added padding property
  • Added barShadow property
  • Added borderRadius property to TabData
  • Added SafeArea to render correctly on iPhones with gestures
  • Fixed some analyzer issues
  • Improved some code formatting
  • Updated Kotlin and AS plugin example versions

[1.0.0] #

  • Increased button padding
  • Option added to add border radius

[0.0.2] #

  • Fixed mistakes in README.md
  • Fixed some bugs

[0.0.1] #

  • The first beta release of Cuberto Bottom Bar

example/lib/main.dart

import 'package:cuberto_bottom_bar/cuberto_bottom_bar.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  // This widget is the root of your application.

  @override
  Widget build(BuildContext context) {
    SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
        statusBarColor: Colors.black.withOpacity(1),
        statusBarIconBrightness: Brightness.light));
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData.light(),
      darkTheme: ThemeData.light(),
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);
  final String title;
  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage>
    with SingleTickerProviderStateMixin {
  int currentPage;
  Color currentColor = Colors.deepPurple;
  Color inactiveColor = Colors.black;
  TabController tabBarController;
  List<Tabs> tabs = new List();

  @override
  void initState() {
    super.initState();
    currentPage = 0;
    tabs.add(Tabs(
      Icons.home,
      "Home",
      Colors.deepPurple,
      getGradient(Colors.deepPurple),
    ));
    tabs.add(
        Tabs(Icons.search, "Search", Colors.pink, getGradient(Colors.pink)));
    tabs.add(
        Tabs(Icons.alarm, "Alarm", Colors.amber, getGradient(Colors.amber)));
    tabs.add(Tabs(
        Icons.settings, "Settings", Colors.teal, getGradient(Colors.teal)));
    tabBarController =
        new TabController(initialIndex: currentPage, length: 4, vsync: this);
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: TabBarView(
          controller: tabBarController,
          physics: NeverScrollableScrollPhysics(),
          children: {2, 3, 1, 0}
              .map(
                (index) => Container(
                  decoration: BoxDecoration(color: tabs[currentPage].color),
                  child: InkWell(
                      child: Center(
                          child: Column(
                        mainAxisAlignment: MainAxisAlignment.center,
                        children: <Widget>[
                          Text(
                            tabs[currentPage].title,
                            textAlign: TextAlign.center,
                            style: TextStyle(
                                color: Colors.white,
                                fontSize: 20.0,
                                fontWeight: FontWeight.w700),
                          ),
                          SizedBox(height: 4),
                          Text(
                            "Click here to Change the tab To " +
                                tabs[index].title,
                            textAlign: TextAlign.center,
                            style:
                                TextStyle(color: Colors.white, fontSize: 14.0),
                          ),
                        ],
                      )),
                      onTap: () {
                        setState(() {
                          currentPage = index;
                          tabBarController.animateTo(currentPage);
                        });
                      }),
                ),
              )
              .toList()),
      drawer: new Container(
          width: 250.0,
          margin: EdgeInsets.only(bottom: 60.0),
          color: Colors.blue,
          child: ListView(
            children: <Widget>[Text("Hello"), Text("World")],
          )),
      endDrawer: new Container(
          width: 250.0,
          margin: EdgeInsets.only(bottom: 60.0),
          color: Colors.blue,
          child: ListView(
            children: <Widget>[Text("Hello"), Text("World")],
          )),
      bottomNavigationBar: CubertoBottomBar(
        inactiveIconColor: inactiveColor,
        tabStyle: CubertoTabStyle.STYLE_FADED_BACKGROUND,
        selectedTab: currentPage,
        tabs: tabs
            .map((value) => TabData(
                iconData: value.icon,
                title: value.title,
                tabColor: value.color,
                tabGradient: value.gradient))
            .toList(),
        onTabChangedListener: (position, title, color) {
          setState(() {
            tabBarController.animateTo(position);
            currentPage = position;
          });
        },
      ),
    );
  }

  @override
  void dispose() {
    tabBarController.dispose();
    super.dispose();
  }
}

class Tabs {
  final IconData icon;
  final String title;
  final Color color;
  final Gradient gradient;

  Tabs(this.icon, this.title, this.color, this.gradient);
}

getGradient(Color color) {
  return LinearGradient(
      colors: [color.withOpacity(0.5), color.withOpacity(0.1)],
      stops: [0.0, 0.7]);
}

Use this package as a library

1. Depend on it

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


dependencies:
  cuberto_bottom_bar: ^1.1.1+2

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:cuberto_bottom_bar/cuberto_bottom_bar.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
83
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
91
Learn more about scoring.

We analyzed this package on Jul 7, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.14
  • Flutter: 1.17.5

Analysis suggestions

Package not compatible with SDK dart

Because:

  • cuberto_bottom_bar that is a package requiring null.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.5.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.12 1.14.13
meta 1.1.8 1.2.1
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8
Dev dependencies
flutter_test