Orientação gerada a partir de informações públicas. Apenas para referência.
Um pacote Flutter que constrói listas roláveis de forma eficiente e fornece notificações em tempo real quando itens da lista entram ou saem da área visível da tela. Ele aproveita o poder do `ListView`, adicionando um mecanismo reativo para detectar o status de visualização, permitindo renderização otimizada, carregamento preguiçoso e melhorias de desempenho. Ideal para cenários como carregamento de imagens, rastreamento de análise ou animações acionadas pela visibilidade. O pacote suporta todas as principais plataformas, incluindo dispositivos móveis, web e desktop.
Casos de uso
Carregamento preguiçoso de imagens ou conteúdo
Rastreamento de visibilidade para análise
Disparando animações na visibilidade
Otimizando o uso de recursos em listas longas
Implementando rolagem infinita com verificações de visibilidade
Principais recursos
Detecção em tempo real de visualização
Reutilização eficiente de widget com ListView
Suporte multiplataforma
API simples baseada em retorno de chamada
Boilerplate mínimo para integração
Indicado para
Desenvolvedores construindo listas sensíveis ao desempenho
Aplicativos que exigem ações baseadas em visibilidade
Aplicações com conteúdo pesado e dados dinâmicos
Equipes priorizando rolagem suave e responsividade
Considerações
Pode aumentar o uso de memória se muitos ouvintes estiverem ativos
Requer manipulação cuidadosa de callbacks para evitar vazamentos
Não é ideal para listas muito curtas onde o custo de overhead supera os benefícios
Mais adequado para listas com atualizações frequentes ou grandes conjuntos de dados
README original
Snapshot do README original do repositório-fonte vinculado. Consulte o repositório para o conteúdo mais recente.
inview_notifier_list
A Flutter package that builds a ListView or CustomScrollView and notifies when the widgets are on screen within a provided area.
Add the required property isInViewPortCondition to the InViewNotifierList widget. This is the function that defines the area which the widgets overlap should be notified as currently in-view.
deltaTop: It is the distance from top of the widget to be notified in the list view to top of the viewport(0.0).
deltaBottom: It is the distance from bottom of the widget to be notified in the list view to top of the viewport(0.0).
viewPortDimension: The height or width of the viewport depending on the srollDirection property provided. The image below showcases the values if the srollDirection is Axis.vertical.
Here is an example that returns true only when the widget's top is above the halfway of the viewport and the widget's bottom is below the halfway of the viewport. It is shown in example1.
Use the InViewNotifierWidget to get notified if the required widget is currently in-view or not.
The InViewNotifierWidget consists of the following properties:
id: a required String property. This should be unique for every widget that wants to get notified.
builder : Signature for a function that creates a widget for a given index. The function that defines and returns the widget that should be notified as inView. See InViewNotifierWidgetBuilder.
isInViewPortCondition: [Required] The function that defines the area within which the widgets should be notified as in-view.
initialInViewIds: The String list of unique ids of the child widgets that should be initialized as in-view when the list view is built for the first time.
endNotificationOffset: The distance from the bottom of the list where the onListEndReached should be invoked. Defaults to the end of the list i.e 0.0.
onListEndReached: The function that is invoked when the list scroll reaches the end or the endNotificationOffset if provided.
throttleDuration: The duration to be used for throttling the scroll notification. Defaults to 200 milliseconds.
scrollDirection: The axis along which the scroll view scrolls.
scrollViewWrapper: An optional callback that wraps the internal scroll view with an additional widget, such as a pull-to-refresh or shimmer wrapper, while keeping in-view detection working. It receives the fully built scroll view and must return a widget that contains it.
Note: The wrapper must let ScrollNotification events bubble up from the inner scroll view (most widgets do by default). If the wrapper provides its own ScrollController, make sure it does not conflict with the one passed to InViewNotifierList.