expandable_bottom_bar 1.0.2

  • Readme
  • Changelog
  • Example
  • Installing
  • 91

ExpandableBottomAppBar #

pub package

Animatable bottom app bar with expandable sheet

Preview #

preview

Getting Started #

Add the plugin:

dependencies:
  ...
  expandable_bottom_bar: any

Basic Usage #

Adding the widget

bottomNavigationBar: BottomExpandableAppBar(
        // Provide the bar controller in build method or default controller as ancestor in a tree 
        controller: bbc,
        expandedHeight: expandedHeight.value,
        horizontalMargin: 16,
        expandedBackColor: Theme.of(context).backgroundColor,
        // Your bottom sheet code here
        expandedBody: Center(
          child: Text("Hello world!"),
        ),
        // Your bottom app bar code here
        bottomAppBarBody: Padding(
          padding: const EdgeInsets.all(8.0),
          child: Row(
            mainAxisSize: MainAxisSize.max,
            children: <Widget>[
              Expanded(
                child: Text(
                  "Hello",
                  textAlign: TextAlign.center,
                ),
              ),
              Spacer(
                flex: 2,
              ),
              Expanded(
                child: Text(
                  "World",
                  textAlign: TextAlign.center,
                ),
              ),
            ],
          ),
        ),
      )

Customization (Optional) #

BottomExpandableAppBar #

horizontalMargin - distance of sheet's sides from edge<br/> bottomOffset - distance of top sheet's edge from top appbar's edge in closed state<br/> shape - notch shape for FAB<br/> appBarHeight - if you need change app bar height<br/>

bottomAppBarColor - background color of appbar container<br/> or appBarDecoration - decoration of appbar container<br/>

expandedBackColor - background color of sheet container<br/> or expandedDecoration - decoration of sheet container<br/>

Controls #

BottomAppBarController #

Settings

snap - if true sheet will snap to opened and closed state<br/> dragLength - distance that pointer should travel for fully open/close the sheet<br/>

Callbacks

Should have dragLength defined<br/> onDrag - use that with GestureDetector for swipe control<br/> onDragEnd - use that with GestureDetector for swipe control<br/>

open - switch the sheet to closed state<br/> close - switch the sheet to opened state<br/> swap - if sheet is opened closes the sheet and vice versa<br/>

[1.0.0] - 11 January 2020 #

Breaking

  • Changed isOpen from a method to a getter.

Backwards-compatible:

  • Documented public members & methods

  • Replaced deprecated inheritFromWidgetOfExactType with findAncestorWidgetOfExactType

  • Added getters isOpen, isOpening, isClosed, isClosing

  • Changed to AnimationStatus for status checking

  • Controller notifies listeners when animation status is updated, not just on completion

  • Added optional named velocity parameter to close, open and swap methods

  • Clarified deprecation message for animation getter

[0.1.1] - 18 May 2019 #

  • Pub Hub deployed

[0.0.1] - 09 May 2019 #

  • Initial release

example/example.dart

import 'package:expandable_bottom_bar/expandable_bottom_bar.dart';
import 'package:flutter/material.dart';
import 'theme.dart';

void main() => runApp(MaterialApp(home: Example()));

class Example extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: FlutterDark.dark(ThemeData.dark()),
      home: DefaultBottomBarController(
        child: Page(),
      ),
    );
  }
}

class Page extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Theme.of(context).canvasColor,

      //Set to true for bottom appbar overlap body content
      extendBody: true,

      appBar: AppBar(
        title: Text("Panel Showcase"),
        backgroundColor: Theme.of(context).bottomAppBarColor,
      ),

      // Lets use docked FAB for handling state of sheet
      floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
      floatingActionButton: GestureDetector(
        // Set onVerticalDrag event to drag handlers of controller for swipe effect
        onVerticalDragUpdate: DefaultBottomBarController.of(context).onDrag,
        onVerticalDragEnd: DefaultBottomBarController.of(context).onDragEnd,
        child: FloatingActionButton.extended(
          label: Text("Pull up"),
          elevation: 2,
          backgroundColor: Colors.deepOrange,
          foregroundColor: Colors.white,

          //Set onPressed event to swap state of bottom bar
          onPressed: () => DefaultBottomBarController.of(context).swap(),
        ),
      ),

      // Actual expandable bottom bar
      bottomNavigationBar: BottomExpandableAppBar(
        expandedHeight: 550,
        horizontalMargin: 16,
        shape: AutomaticNotchedShape(
            RoundedRectangleBorder(), StadiumBorder(side: BorderSide())),
        expandedBackColor: Theme.of(context).backgroundColor,
        expandedBody: Center(
          child: Text("Hello world!"),
        ),
        bottomAppBarBody: Padding(
          padding: const EdgeInsets.all(8.0),
          child: Row(
            mainAxisSize: MainAxisSize.max,
            children: <Widget>[
              Expanded(
                child: Text(
                  "Tets",
                  textAlign: TextAlign.center,
                ),
              ),
              Spacer(
                flex: 2,
              ),
              Expanded(
                child: Text(
                  "Stet",
                  textAlign: TextAlign.center,
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  expandable_bottom_bar: ^1.0.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:expandable_bottom_bar/expandable_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 Apr 7, 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

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