Buscar pacotes, repositórios e categorias de apps

Capa de sticky_and_expandable_list
Detalhes do pacotev1.1.3

sticky_and_expandable_list

Crie uma lista agrupada que suporte expansão/colapso de seções e cabeçalhos grudados, e que suporte o uso com widgets Sliver.

AndroidiOSWebmacOSWindowsLinux
Downloads em 30 dias
7,8 mil
Curtidas
175
Pontos Pub
140

Instalar pacote

flutter pub add sticky_and_expandable_list

Visão geral do pacote

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

Um pacote Flutter que permite a criação de listas agrupadas com seções colapsáveis e cabeçalhos grudados, ideal para organizar conteúdo hierarquicamente. Integra-se perfeitamente com widgets Sliver, tornando-o adequado para uso em visualizações personalizadas de rolagem como CustomScrollView. O pacote suporta todas as principais plataformas, incluindo Android, iOS, Web, macOS, Windows e Linux, oferecendo uma experiência consistente entre dispositivos. Simplifica interações complexas com código mínimo de boilerplate.

Casos de uso

  • Exibição de dados agrupados
  • Lista de seções colapsáveis
  • Navegação de cabeçalho aderente
  • Visualizações de rolagem personalizadas
  • Organização de conteúdo dinâmico
  • Interface do usuário aprimorada para listas longas

Principais recursos

  • Seções expansíveis/recolhíveis
  • Cabeçalhos de seção grudados
  • Compatibilidade com widget Sliver
  • Suporte multiplataforma
  • Configuração mínima necessária
  • Animações suaves

Indicado para

  • Desenvolvedores construindo listas complexas
  • Designers de UI que precisam de layouts interativos
  • Aplicativos com dados hierárquicos
  • Interfaces escalonáveis com cabeçalhos
  • Aplicações móveis e web

Considerações

  • Requer conhecimento sobre widgets Sliver
  • Pode afetar o desempenho com conjuntos de dados muito grandes
  • Personalização limitada além da estilização básica
  • Mais adequado para dados agrupados de tamanho moderado
  • Não recomendado para listas planas simples

README original

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

sticky_and_expandable_list

Flutter implementation of sticky headers and expandable list.Support use it in a CustomScrollView.

Pub README i18n:中文说明

Screenshot

Features

  • Build a grouped list, which support expand/collapse section and sticky header.
  • Use it with CustomScrollView、SliverAppBar.
  • Listen the scroll offset of current sticky header, current sticky header index and switching header index.
  • Only use one list widget, so it supports large data and a normal memory usage.
  • More section customization support, you can return a new section widget by sectionBuilder, to customize background,expand/collapse animation, section layout, and so on.
  • Support add divider.
  • Support overlap content.
  • Support scroll to index like ListView, by scroll-to-index.
  • Pull to refresh and load more, by pull_to_refresh.

Getting Started

In the pubspec.yaml of your flutter project, add the following dependency:

dependencies:
  sticky_and_expandable_list: ^1.1.3

Basic Usage

sectionList is a custom data source for ExpandableListView. We should create a model list to store the information of each section, the model must implement ExpandableListSection.

    //In this example, we create a custom model class(ExampleSection).
    //class ExampleSection implements ExpandableListSection<String> {}
    //so: SliverExpandableChildDelegate<String, ExampleSection>()
    List<ExampleSection> sectionList = List<ExampleSection>();
    return ExpandableListView(
      builder: SliverExpandableChildDelegate<String, ExampleSection>(
          sectionList: sectionList,
          headerBuilder: (context, sectionIndex, index) =>
              Text("Header #$sectionIndex"),
          itemBuilder: (context, sectionIndex, itemIndex, index) {
            String item = sectionList[sectionIndex].items[itemIndex];
            return ListTile(
              leading: CircleAvatar(
                child: Text("$index"),
              ),
              title: Text(item),
            );
          }),
    );

Detail Examples

If you want to use it with sliver widget, use SliverExpandableList instead of ExpandableListView.

FAQ

How to expand/collapse item?
setState(() {
  sectionList[i].setSectionExpanded(true);
});

Example

How to listen current sticky header or the sticky header scroll offset?
  @override
  Widget build(BuildContext context) {
    ExpandableListView(
      builder: SliverExpandableChildDelegate<String, ExampleSection>(
        headerController: _getHeaderController(),
      ),
    )
  }

  _getHeaderController() {
    var controller = ExpandableListController();
    controller.addListener(() {
      print("switchingSectionIndex:${controller.switchingSectionIndex}, stickySectionIndex:" +
          "${controller.stickySectionIndex},scrollPercent:${controller.percent}");
    });
    return controller;
  }
How to set background for each section?

Use sectionBuilder

Customize expand/collapse animation support?

Example

Change Log

CHANGELOG

Categorias

Repositório-fonte

Projetos que usam este pacote