Buscar pacotes, repositórios e categorias de apps

Capa de contextualactionbar
Detalhes do pacotev3.1.0

contextualactionbar

Uma solução alternativa para a Barra de Ações Contextuais (CAB) no Flutter. A CAB é uma barra superior que substitui a barra do aplicativo e fornece ações contextuais para itens selecionados.

AndroidiOSWebmacOSWindowsLinux
Downloads em 30 dias
121
Curtidas
66
Pontos Pub
150

Instalar pacote

flutter pub add contextualactionbar

Visão geral do pacote

Orientação gerada a partir de informações públicas. Apenas para referência.

O pacote contextualactionbar fornece uma solução alternativa para implementar uma Barra de Ações Contextual (CAB) no Flutter, permitindo uma barra superior dinâmica que substitui a barra padrão do aplicativo para exibir ações específicas do contexto quando itens são selecionados. Projetado para uso em múltiplas plataformas, incluindo Android, iOS, Web, macOS, Windows e Linux, ele melhora a interação do usuário ao oferecer controles direcionados durante os modos de seleção. O pacote se integra perfeitamente a aplicativos existentes do Flutter e suporta estilos e comportamentos personalizados. É especialmente útil em interfaces de lista ou grade onde os usuários precisam realizar operações em lote.

Casos de uso

  • Seleção em lote de itens em listas
  • Ações sensíveis ao contexto em grades
  • Interação aprimorada do usuário em aplicativos móveis
  • sobreposições de ação personalizáveis
  • Implementação multiplataforma
  • Melhorias na interface de usuário do modo de seleção

Principais recursos

  • Substituição dinâmica da barra de aplicativo
  • Suporte para múltiplas plataformas
  • Botões de ação personalizáveis
  • Integração com modos de seleção
  • Leve e fácil de implementar
  • Design responsivo para todos os dispositivos

Indicado para

  • Desenvolvedores criando interfaces de lista interativas
  • Aplicativos que exigem operações em lote
  • Aplicações móveis multiplataforma
  • Interfaces com fluxos de trabalho baseados em seleção
  • Equipes procurando soluções CAB independentes de plataforma
  • Projetos do Flutter que precisam de suporte a ações contextuais

Considerações

  • Requer manipulação manual do estado de seleção
  • animações embutidas limitadas
  • Pode ser necessário estilização adicional para consistência
  • Depende da integração adequada com elementos rolagens
  • Não adequado para interfaces de usuário estáticas simples
  • Melhor usado com padrões de gerenciamento de estado

README original

Snapshot do README original do repositório-fonte vinculado. Consulte o repositório para o conteúdo mais recente.

Flutter contextual action bar(CAB)

CAB & Flutter

CAB is a top app bar that replace the application 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

  • ContextualScaffold
  • ContextualAppBar
  • ContextualAction
  • ContextualActionWidget

ContextualScaffold<?>

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

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

You can provide multiple ContextualScaffold as needed

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.

A closer look at ContextualActionWidget<?>

The ContextualActionWidget<?> takes other optional parameters like

  • selectedColor
  • selectedWidget
  • unselectedWidget

The selectedColor is the color of the background for the selected item, it defaults to the splash color, if not provided. The selectedColor works well with ListTile.

selectedWidget and unselectedWidget are stacked on top of the provided child widget. By default, they are positioned at the center of the provided child widget. Since They are stacked, you can use Row, Align, Positioned Widget or any other combination of widgets to position them where desired.

The selectedWidget is shown when the ActionMode is enabled and the item is selected, while the unselectedWidget is shown when ActionMode is enabled and the item is not selected. See example(status_saver) image below with both the selectedWidget and unselectedWidget aligned to the top-right corner.

ActionMode

This contextual action bar workaround does not support zero item in the ActionMode.

  • Use the ActionMode.addItem<?> to add an item to the selected items. If this is the first selection, the ActionMode is will be enabled.

  • Use the ActionMode.addItems<?> to add a list of items.

  • Use the ActionMode.disable<?> to disable and deselect all selected items.

  • Use the ActionMode.enabledStream<?> to emit true or false depending on if the Action mode is enabled or disabled respectively.

Note: In most cases, you won't need to use ActionMode.disable<?> because the package already do that for you where needed.

Study complete examples at example page. If you like the project, don't forget to star ⭐️

Other Packages authored by me

License

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

Categorias

Dependências

Lista de dependências 1 itens

Repositório-fonte

Projetos que usam este pacote

Ainda não há dados.