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

패키지 상세v3.4.3

hooks_riverpod

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

AndroidiOSmacOSWindowsLinux
30일 다운로드
65.9만
좋아요
931
Pub 점수
150

패키지 설치

flutter pub add hooks_riverpod

패키지 개요

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

Hooks Riverpod은 Flutter용 반응형 상태 관리 및 종속성 주입 프레임워크로, 비동기 작업과 데이터 바인딩 처리를 간소화합니다. Riverpod 생태계 위에 구축되어 있으며, Flutter의 훅 시스템과 원활하게 통합되어 함수형 위젯을 사용하여 상태를 효율적으로 관리할 수 있게 해줍니다. 자동 반응성, 캐싱, 명확한 관심사 분리 기능을 제공하여 복잡한 상태 로직을 유지보수하고 테스트하기 쉽게 만듭니다.

사용 사례

  • 앱 전반의 상태 관리
  • 비동기 데이터 로딩 처리
  • 반응형 UI 업데이트
  • 대규모 앱에서의 의존성 주입
  • 상태 있는 로직 테스트

주요 기능

  • 반응형 상태 업데이트
  • 내장 캐싱
  • 비동기 작업 지원
  • Flutter hooks와의 통합
  • 세밀한 종속성 제어

적합한 대상

  • 대규모 플러터 애플리케이션
  • 테스트 가능성에 중점을 둔 팀
  • 함수형 위젯 패턴을 사용하는 개발자
  • 복잡한 상태 상호작용을 가진 앱
  • 의존성 주입이 필요한 프로젝트

고려 사항

  • 초보자를 위한 학습 곡선이 더 가파릅니다
  • Dart의 async/await에 대한 이해가 필요합니다
  • 간단한 앱에서 오버헤드를 유발할 수 있습니다
  • 다른 대안들에 비해 문서가 제한적
  • 성능 문제를 피하기 위해 신중한 구조 설계가 필요합니다

원본 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

카테고리

의존성

의존성 목록 5 개

소스 저장소

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