搜索插件、代码仓与 APP 分类

插件详情v1.3.0

lazy_load_scrollview

一个 ScrollView 的包装器,当到达页面底部时会触发回调

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
2.3万
喜欢数
434
Pub 分数
150

安装插件

flutter pub add lazy_load_scrollview

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

一个 Flutter 包,用于包装 ScrollView,当用户滚动到可滚动内容的底部时触发回调。该包专为实现无限滚动或懒加载列表和网格而设计,非常适合分页数据检索。该包可在所有主要平台(包括 Android、iOS、Web、macOS、Windows 和 Linux)上运行。它简化了检测滚动位置并动态加载更多数据的过程,无需复杂的自定义逻辑。

适合场景

  • 无限滚动列表
  • 懒加载图片或数据
  • 网页应用中的分页内容
  • 动态列表更新
  • 滚动时加载更多项目

主要特点

  • 自动底部检测
  • 跨平台支持
  • 简单的回调机制
  • 最小化样板代码
  • 适用于 ListView、GridView 及其他可滚动组件

适合对象

  • 开发分页 UI 的开发者
  • 大型数据集的应用程序
  • 内容密集型界面
  • 需要动态加载的 Web 和移动应用程序

使用建议

  • 需要正确处理加载状态
  • 快速滚动时可能需要防抖
  • 不适用于固定大小的列表
  • 应与错误处理结合使用
  • 性能取决于数据源的效率

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

Lazy load scrollview

A wrapper for a ScrollView that will enable lazy loading

Usage

Add lazy_load_scrollview dependency to your pubspec.yaml:

dependencies:
  lazy_load_scrollview: 1.3.0

In your Dart code, import package:lazy_load_scrollview/lazy_load_scrollview.dart Then you can wrap your ListView, GridView, RefreshIndicator etc with the LazyLoadScrollView. Make sure you add an endOfPageListener which will receive the call when the bottom of the list has been reached.

import 'package:lazy_load_scrollview/lazy_load_scrollview.dart';


@override
Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: LazyLoadScrollView(
        onEndOfPage: () => loadMore(),
        child: ListView.builder(
          itemCount: data.length,
          itemBuilder: (context, position) {
            return Text("Position $position");
          },
        ),
      ),
    );
}

Class definition


LazyLoadScrollView(
  endOfPageListener: () => loadMore(), // The callback when reaching the end of the list
  scrollOffset: 100 // Pixels from the bottom that should trigger a callback 
  child: Widget, // A subclass of `ScrollView`
);

所属分类

源码仓库

使用此插件的项目