bottommultinavigationbar 1.1.2

  • Readme
  • Changelog
  • Installing
  • 57

bottommultinavigationbar #

A widget where each fragment has their own navigation history inside the bottom navigation bar

Getting Started #

1. import bottommultinavigationbar #

import 'package:bottommultinavigationbar/bottommultinavigationbar.dart';

2. Create a list of PageNavigators: #

var pages = [
  PageNavigator(
    bottomNavigationIcon: Icon(Icons.ac_unit),
    bottomNavigationText: "Page 1",
    initialRoute: "/page2",
    onGenerateRoute: (settings) {
      if(settings.name == PageNavigator.home)
        return MaterialPageRoute(builder: (_) => Test(test:"Page 1 - 1",index: 0,));
      if(settings.name == "/page2")
        return MaterialPageRoute(builder: (_) => Test(test:"Page 1 - 2",index: 0));
    }
  ),
  PageNavigator(
    bottomNavigationIcon: Icon(Icons.ac_unit),
    bottomNavigationText: "Page 2",
    onGenerateRoute: (settings) {
      if(settings.name == PageNavigator.home)
        return MaterialPageRoute(builder: (_) => Test(test:"Page 2 - 1",index: 1,));
      if(settings.name == "/page2-2")
        return MaterialPageRoute(builder: (_) => Test(test:"Page 2 - 2",index: 1,));
    }
  ),
];

Be sure that you use "/" in your namings like "/page1". PageNavigator.home represents the home page of the fragment. From there the navigator will navigate to your pages inside of the fragment without leaving the bottom navigation view. With the "initialRoute" attribute you can specify a different start point for each of your fragment.

3. Use the BottomMultiNavigationBar Widget #

  @override
  Widget build(BuildContext context) {
    return BottomMultiNavigationBar(
      index: myCounter
      pageNavigators: pages,
      onIndexChanged: (index) {
        setState({
          myCounter = index
        })
      },
    );
  }

4. Navigate #

You can use the Navigator.of(context).pushNamed() as usual

    Navigator.of(context).pushNamed("/page2") 

With passing data:

    //push your data
    Navigator.of(context).pushNamed("/page2-2",arguments: "Test data")

    //in your PageNavigator
    PageNavigator(
      bottomNavigationIcon: Icon(Icons.ac_unit),
      bottomNavigationText: "Page 2",
      onGenerateRoute: (settings) {
        if(settings.name == PageNavigator.home)
          return MaterialPageRoute(builder: (_) => Test(test: "page2-1",index: 1,));
        if(settings.name == "/page2-2")
          if(settings.arguments is String)
            return MaterialPageRoute(builder: (_) => Test(test: settings.arguments,index: 1,));
          //else error handling
    }
  ),

Using the FlutterIntent navigation system #

This system is especially developed for this package and imitates the intent system of the Android Framework. Please be aware that you use only one of the provided navigation system. So if you want to use the onGenerateRoute attribute the flutterIntentService has to be null and vice versa.

1. Use the flutterIntentService attribute of the PageNavigator class #

PageNavigator(
    bottomNavigationIcon: Icon(Icons.ac_unit),
    bottomNavigationText: "Page 1",
    flutterIntentService: FlutterIntentService(
      onIntent: (intent) {
      if(intent.name == "/")
        return Test(name: intent.getStringExtra("str_page_name"));
      if(intent.name == "/page2")
        //we now that we get a boolean 
        return TestBool(isTrue: intent.getBoolExtra("bool_value"));
      }
    )
  ),

The intent which is passed as parameter holds the data. From there you can get your data like in the example above.

2. Send an intent #

For sending an intent use the FlutterIntent() class:

FlutterIntent(context: context,name: "/page2")
..putExtra("bool_value",true)
..startActivity();

Don't forget to call the startActivity in the end. This will start the next activity and pass your data to the next page which you defined in the PageNavigator in step 1.

Example #

For an example GIF checkout the github link :)

[1.1.2] - 09.02.2020 #

  • added new navigation system FlutterIntent for simplifying data exchange between widgets
  • optimizing and fixes

[1.0.0] - 09.02.2020 #

  • initial release

Use this package as a library

1. Depend on it

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


dependencies:
  bottommultinavigationbar: ^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:bottommultinavigationbar/bottommultinavigationbar.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
18
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
57
Learn more about scoring.

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

  • Dart: 2.7.1
  • pana: 0.13.6
  • Flutter: 1.12.13+hotfix.8

Health suggestions

Format lib/bottommultinavigationbar.dart.

Run flutter format to format lib/bottommultinavigationbar.dart.

Format lib/src/bottom_multi_navigation_bar.dart.

Run flutter format to format lib/src/bottom_multi_navigation_bar.dart.

Format lib/src/flutter_intent.dart.

Run flutter format to format lib/src/flutter_intent.dart.

Format lib/src/page_navigator.dart.

Run flutter format to format lib/src/page_navigator.dart.

Maintenance suggestions

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package.

Common filename patterns include main.dart, example.dart, and bottommultinavigationbar.dart. Packages with multiple examples should provide example/README.md.

For more information see the pub package layout conventions.

Dependencies

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