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

패키지 상세v3.5.0

riverpod

반응형 캐싱 및 데이터 바인딩 프레임워크입니다. Riverpod은 비동기 코드 작업을 쉽게 만듭니다.

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
449만
좋아요
4천
Pub 점수
160

패키지 설치

flutter pub add riverpod

패키지 개요

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

Riverpod은 Flutter용 반응형 상태 관리 및 종속성 주입 프레임워크로, 비동기 작업과 상태 업데이트를 간편하게 처리할 수 있도록 도와줍니다. 강력한 타입 지정, 테스트 가능성, 효율적인 반응성을 갖춘 명확하고 확장 가능한 앱 상태 관리 방법을 제공합니다. Riverpod은 기존의 상태 관리 솔루션(예: Provider)에서 흔히 발생하는 문제를 피하면서 종속성에 대해 세밀한 제어를 가능하게 합니다. 캐시 메커니즘을 통해 중복 계산을 방지하여 성능을 향상시킵니다.

사용 사례

  • 전역 애플리케이션 상태 관리
  • 비동기 데이터 로딩 처리
  • 대규모 앱에서의 의존성 주입
  • 상태 있는 로직 테스트
  • 반응형 UI 업데이트
  • 위젯 간에 데이터 공유

주요 기능

  • 반응형 상태 업데이트
  • 내장된 비동기 지원
  • 세밀한 종속성 제어
  • 강력한 타입 안전성
  • 간편한 테스트
  • 성능을 위한 캐싱

적합한 대상

  • 대규모 플러터 애플리케이션
  • 유지보수성을 우선시하는 팀
  • 강력한 비동기 처리가 필요한 개발자
  • 모듈식 아키텍처가 필요한 앱
  • 테스트 가능성에 중점을 둔 프로젝트

고려 사항

  • 초보자를 위한 학습 곡선이 더 가파릅니다
  • 반응형 프로그래밍에 대한 이해가 필요합니다
  • 간단한 앱에서 오버헤드를 유발할 수 있습니다
  • 오래된 대안들에 비해 문서가 제한적입니다

원본 README

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

Build Status codecov Star on Github License: MIT Discord

Deploys by Netlify

Riverpod


A reactive caching and data-binding framework. https://riverpod.dev Riverpod makes working with asynchronous code a breeze by:

  • Handling errors/loading states by default. No need to manually catch errors
  • Natively supporting advanced scenarios, such as pull-to-refresh
  • Separating the logic from your UI
  • Ensuring your code is testable, scalable and reusable
riverpod pub package
flutter_riverpod pub package
hooks_riverpod pub package

Welcome to Riverpod (anagram of Provider)!

For learning how to use Riverpod, see its documentation: >>> https://riverpod.dev <<<

Long story short:

  • Define network requests by writing a function annotated with @riverpod:

    @riverpod
    Future<String> boredSuggestion(Ref ref) async {
      final response = await http.get(
        Uri.https('boredapi.com', '/api/activity'),
      );
      final json = jsonDecode(response.body);
      return json['activity']! as String;
    }
    
  • Listen to the network request in your UI and gracefully handle loading/error states.

    class Home extends ConsumerWidget {
      @override
      Widget build(BuildContext context, WidgetRef ref) {
        final boredSuggestion = ref.watch(boredSuggestionProvider);
        // Perform a switch-case on the result to handle loading/error states
        return switch (boredSuggestion) {
          AsyncData(:final value) => Text('data: $value'),
          AsyncError(:final error) => Text('error: $error'),
          _ => const Text('loading'),
        };
      }
    }
    

Contributing

Contributions are welcome!

Here is a curated list of how you can help:

  • Report bugs and scenarios that are difficult to implement
  • Report parts of the documentation that are unclear
  • Fix typos/grammar mistakes
  • Update the documentation or add examples
  • Implement new features by making a pull-request

Sponsors

카테고리

의존성

의존성 목록 9 개

소스 저장소

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

순위