パッケージ、リポジトリ、アプリカテゴリを検索

パッケージ詳細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 との統合
  • 細粒度の依存関係制御

適している対象

  • 大規模なFlutterアプリケーション
  • テスト性を重視するチーム
  • 関数型ウィジェットパターンを使用する開発者
  • 複雑な状態の相互作用を持つアプリ
  • 依存関係の挿入を必要とするプロジェクト

注意事項

  • 初心者には学習曲線が急峻です
  • 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 件

ソースリポジトリ

このパッケージを使用しているプロジェクト