Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD

bottom_nav_layout

it is a quick flutter app layout for building an app with a bottom nav bar. you can get an app with fluent behavior running in 15 lines of code.

125905278-4c0c7f21-a1df-42a9-aaff-c2b901267339

why bottom_nav_layout?

  • eliminates all boilerplate code for bottom nav bar coordination.
  • offers additional common features.
    • page state preservation
    • lazy page loading
    • page transition animations
    • in-page navigation
    • back button navigation for android
  • works with any bottom bar you want. use the material or cupertino bottom bar, grab one from pub.dev or use your own.
  • you can customize or turn of any feature.

125903612-92e0d0ac-eaf1-4714-850d-90747b94cee5

usage

installation

add the following to your pubspec.yaml file.

dependencies:
  bottom_nav_layout: latest_version

quick start example

import 'package:bottom_nav_layout/bottom_nav_layout.dart';

void main() => runapp(materialapp(
      home: bottomnavlayout(
        // the app's destinations
        pages: [
          (_) => center(child: text("welcome to bottom_nav_layout")),
          (_) => sliderpage(),
          (_) => center(child: textfield(decoration: inputdecoration(hinttext: 'go..'))),
        ],
        bottomnavigationbar: (currentindex, ontap) => bottomnavigationbar(
          currentindex: currentindex,
          ontap: (index) => ontap(index),
          items: [
            bottomnavigationbaritem(icon: icon(icons.home), label: 'home'),
            bottomnavigationbaritem(icon: icon(icons.linear_scale), label: 'slider'),
            bottomnavigationbaritem(icon: icon(icons.search), label: 'search'),
          ],
        ),
      ),
    ));

done. you have a complete, working application.

sliderpage code

parameters

name description default
pages the app’s destinations. n/a
bottomnavigationbar the bottom navbar of the layout. n/a
savepagestate when false, the pages are reinitialized every time they are navigated. (material behavior). when true, the pages are initialized once and hidden/shown on navigation. (cupertino behavior) false
lazyloadpages when false, pages are created in the beginning. when true, pages are created when they are navigated for the first time. false
pagestack navigation stack that remembers pages visited. enhances back button management on android. reordertofrontpagestack for android, nopagestack for ios
extendbody passed to scaffold.extendbody. false
resizetoavoidbottominset passed to scaffold.resizetoavoidbottominset. true
pagetransitiondata animation configuration for page transitions. null

inner widget tree

inner_widget_tree

 

image

page state preservation

the state changes you made in a page such as scroll amount, sub-navigation, form inputs etc. are preserved. you can enable it as per cupertino design guidelines or disable it as per material design guidelines

savepagestate: true, // default is false

lazy page loading

the layout offers the option to lazily create the pages using the passed in page builders. when lazyloadpages is set to true, the pages are not created until they are navigated to for the first time. this is useful when a non-initial page;

  • has a load animation.
  • runs a heavy process that is not needed until the page is opened.
lazyloadpages: true, // default is false

page back stack

documentation example
documentation

the layout remembers the order of pages navigated and when back button is pressed, navigates back to the previously navigated page.

there are many useful page back stack behaviors implemented such as reorder-to-front and replace-except-first. you can also implement your own.

you also specify the initialpage inside pagestack.

// default is reordertofrontpagestack for android and nopagestack for ios.
pagestack: reordertofrontpagestack(initialpage: 0),

for details.

page transition animation

documentation example
example

you can set an transition animation between pages. create your own animationbuilder or use one of the built in ones.

these animation work with both bottom navbar and android back button.

// default is null.
pagetransitiondata: pagetransitiondata(
  builder: prebuiltanimationbuilderbuilders.zoominandfadeout,
  duration: 150,
  direction: animationdirection.inandout,
),

in-page navigation

documentation example
documentation example

the layout maintains a flat navigation pattern.

figure: flat navigation

benefits

  1. a navigator per page can be used with ease.
  2. android back button navigates both in-page and among pages.
  3. bottom bar pops all in-page stack when the current bar item is reselected.

to do this, the page should have a navigator widget that use the passed in globalkey as its key.

different bottom bars

documentation example
documentation example

so far, we only worked on material bottom nav bar. the layout supports any bottom bar.

example usage of flutter_snake_navigationbar:

bottomnavigationbar: (currentindex, ontap) => snakenavigationbar.color(
  currentindex: currentindex,
  ontap: (index) => ontap(index),
  items: [
    bottomnavigationbaritem(icon: icon(icons.home), label: 'home'),
    bottomnavigationbaritem(icon: icon(icons.linear_scale), label: 'slider'),
    bottomnavigationbaritem(icon: icon(icons.search), label: 'search'),
  ],
),

improvements

  • tell me if you want to see a feature your app has/needs in this package. i will do my best to integrate it.
  • i am also considering to make a drawer_nav_layout package. if you are interested, let me know!

Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD

Comments are closed.