패키지, 저장소 및 앱 카테고리 검색

infinite_scroll 표지
패키지 상세v1.1.1

infinite_scroll

무한 스크롤 뷰를 위한 목록 및 그리드 위젯을 제공하는 플러터 패키지입니다.

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
1.2천
좋아요
34
Pub 점수
140

패키지 설치

flutter pub add infinite_scroll

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

무한 스크롤 인터페이스를 위한 리스트 및 그리드 위젯을 제공하는 플러터 패키지입니다. 사용자가 스크롤할 때 부드럽고 지연 로딩 방식으로 콘텐츠를 제공하여 성능 저하 없이 대규모 데이터셋을 표시하는 데 이상적입니다. 안드로이드, iOS, 웹, 맥OS, 윈도우, 리눅스 등 여러 플랫폼을 지원하며 크로스플랫폼 애플리케이션에 유용합니다. 간단함을 중시해 설계되었으며 직관적인 API를 통해 기존 플러터 프로젝트에 쉽게 통합할 수 있습니다. 피드, 제품 목록 또는 지속적인 콘텐츠 로딩이 필요한 모든 상황에 적합합니다.

사용 사례

  • 소셜 미디어 피드
  • 제품 카탈로그
  • 뉴스 기사 목록
  • 이미지 갤러리
  • 채팅 메시지 스트림

주요 기능

  • 무한 스크롤 목록
  • 그리드 레이아웃 지원
  • 지연 로딩 최적화
  • 크로스 플랫폼 호환성
  • 간단한 통합 API
  • 내장된 풀투리프레시

적합한 대상

  • 대규모 데이터 세트를 포함하는 앱
  • 콘텐츠 중심의 UI
  • 실시간 데이터 표시
  • 모바일 및 웹 애플리케이션
  • 간편한 페이지네이션을 원하는 개발자

고려 사항

  • 데이터 소스를 신중하게 다뤄야 합니다
  • 사용자 지정 로딩 표시기 필요할 수 있음
  • 작은 정적 목록에 적합하지 않음
  • 성능은 항목의 복잡성에 따라 달라집니다
  • 네트워크 요청에 적절한 오류 처리가 필요합니다

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

Infinite Scroll

This package provides InfiniteScrollList and InfiniteScrollGrid widgets to display lists or grids as infinite scrolling views. You can make API calls during the loading state of the list or grid. Please refer to the example project to learn how you can use these widgets in your app.

InfiniteScrollList InfiniteScrollGrid
Created By Syed Waleed Shah
Please Contribute Github Repository

Features

  • Build your list or grid on demand.
  • Show default or your own custom loading indicator during loading of new data.
  • Make API calls within onStartLoading(int) callback.
Examples

🔥 You can also refer to this example project

InfiniteScrollList
import 'package:flutter/material.dart';
import 'package:infinite_scroll/infinite_scroll.dart';

class ListExample extends StatefulWidget {
  const ListExample({Key? key}) : super(key: key);

  @override
  State<ListExample> createState() => _ListExampleState();
}

class _ListExampleState extends State<ListExample> {
  Future<List<String>> getNextPageData(int page) async {
    await Future.delayed(const Duration(seconds: 2));
    if (page == 3) return [];
    final items = List<String>.generate(14, (i) => "Item $i Page $page");
    return items;
  }

  List<String> data = [];
  bool everyThingLoaded = false;

  @override
  void initState() {
    super.initState();

    loadInitialData();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('🔥 List Example')),
      body: InfiniteScrollList(
        physics: const BouncingScrollPhysics(),
        shrinkWrap: true,
        children: data.map((e) => ListItem(text: e)).toList(),
        onLoadingStart: (page) async {
          List<String> newData = await getNextPageData(page);
          setState(() {
            data += newData;
            if (newData.isEmpty) {
              everyThingLoaded = true;
            }
          });
        },
        everythingLoaded: everyThingLoaded,
      ),
    );
  }

  Future<void> loadInitialData() async {
    data = await getNextPageData(0);
    setState(() {});
  }
}

class ListItem extends StatelessWidget {
  final String text;
  const ListItem({
    Key? key,
    required this.text,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: const EdgeInsets.all(10),
      margin: const EdgeInsets.symmetric(horizontal: 10, vertical: 5),
      decoration: BoxDecoration(
        color: Theme.of(context).primaryColor.withOpacity(.3),
        borderRadius: BorderRadius.circular(15),
      ),
      child: Row(
        children: [
          const CircleAvatar(
            child: Icon(Icons.image),
          ),
          const SizedBox(width: 10),
          Text(
            text,
            style: Theme.of(context).textTheme.bodyText1,
          ),
        ],
      ),
    );
  }
}

InfiniteScrollGrid
import 'package:flutter/material.dart';
import 'package:infinite_scroll/infinite_scroll.dart';

class GridExample extends StatefulWidget {
  const GridExample({Key? key}) : super(key: key);

  @override
  State<GridExample> createState() => _GridExampleState();
}

class _GridExampleState extends State<GridExample> {
  Future<List<String>> getNextPageData(int page) async {
    await Future.delayed(const Duration(seconds: 2));
    if (page == 3) return [];
    final items = List<String>.generate(20, (i) => "Item $i Page $page");
    return items;
  }

  List<String> data = [];
  bool everyThingLoaded = false;

  @override
  void initState() {
    super.initState();

    loadInitialData();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('🔥 Grid Example')),
      body: InfiniteScrollGrid(
        physics: const BouncingScrollPhysics(),
        padding: const EdgeInsets.all(10),
        crossAxisSpacing: 10,
        mainAxisSpacing: 10,
        children: data
            .map(
              (e) => GridItem(text: e),
            )
            .toList(),
        onLoadingStart: (page) async {
          List<String> newData = await getNextPageData(page);
          setState(() {
            data += newData;
            if (newData.isEmpty) {
              everyThingLoaded = true;
            }
          });
        },
        everythingLoaded: everyThingLoaded,
        crossAxisCount: 3,
      ),
    );
  }

  Future<void> loadInitialData() async {
    data = await getNextPageData(0);
    setState(() {});
  }
}

class GridItem extends StatelessWidget {
  final String text;
  const GridItem({Key? key, required this.text}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
        padding: const EdgeInsets.all(10),
        alignment: Alignment.center,
        decoration: BoxDecoration(
            color: Theme.of(context).primaryColor.withOpacity(.3),
            borderRadius: BorderRadius.circular(10)),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.spaceAround,
          children: [
            const CircleAvatar(
              child: Icon(Icons.image),
            ),
            Text(
              text,
              style: Theme.of(context).textTheme.bodyText1,
              textAlign: TextAlign.center,
            ),
          ],
        ));
  }
}

카테고리

소스 저장소

이 패키지를 사용하는 프로젝트

아직 데이터가 없습니다.