contextualactionbar 1.0.0 copy "contextualactionbar: ^1.0.0" to clipboard
contextualactionbar: ^1.0.0 copied to clipboard

outdated

A Contextual Action Bar(CAB) workaround for flutter

Flutter contextual action bar(CAB) #

A reliable contextual action bar workaround for flutter.

CAB & Flutter #

CAB is a top app bar that replace the app app bar to provide contextual actions to selected items. Check the material implementation and requirement here

Flutter does not natively support CAB yet. see issue Until CAB is natively supported, this package should provide you with an elegant way to implement the contextual action bar in flutter.

How it works #

  • ContextualActionScaffold
  • ContextualAppBar
  • ContextualAction
  • ContextualActionWidget

ContextualActionScaffold<?> #

The ContextualActionScaffold<?> is similar to the normal material Scaffold except that it also takes a required contextualAppBar.

ContextualActionScaffold<?>(
      appBar: AppBar(),
      contextualAppBar: ContextualAppBar(),
      body: Body(),
    )

ContextualAppBar<?> #

The ContextualAppBar<?> is similar to the normal material Appbar but takes a counterBuilder instead of title and also a contextualActions instead of `actions.

 ContextualAppBar(
      counterBuilder: (int itemsCount){
        return Text("$itemsCount Selected");
      },
      contextualActions: <ContextualAction>[],
    )

ContextualAction<?> #

The ContextualAction<?> allows you to take actions on the selected items, with the help of itemsHandler callback.

ContextualAction(
            itemsHandler: (List<?> items) {
              items.forEach((item) {
                Scaffold.of(context).showSnackBar(SnackBar(
                  content: Text("$item saved"),
                ));
              });
            },
            child: Icon(Icons.save),
          ),

ContextualActionWidget<?> #

You can use the ContextualActionWidget anywhere in the ContextualActionScaffold body to notify ContextualActionScaffold that an item have been selected in order to show the ContextualAppBar.

   ContextualActionWidget(
          data: ?,
          child: ChildWidget(),
        )

Note: It is important that the child widget does not handle onLongPress.

Study complete examples at example page

Other Packages authored by me #

License #

This package is licensed under the MIT license. See LICENSE for details.

66
likes
0
points
103
downloads

Publisher

unverified uploader

Weekly Downloads

A Contextual Action Bar(CAB) workaround for flutter

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, provider

More

Packages that depend on contextualactionbar