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

パッケージ詳細v3.5.0

riverpod

リアクティブなキャッシュおよびデータバインディングフレームワーク。Riverpod は非同期コードの扱いを簡単にする。

AndroidiOSWebmacOSWindowsLinux
30日間ダウンロード
449万
いいね数
4040
Pub ポイント
160

パッケージをインストール

flutter pub add riverpod

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

Riverpod は、Flutter向けのリアクティブな状態管理および依存関係の挿入フレームワークであり、非同期操作や状態の更新を簡単に扱うことができます。強力な型付け、テスト可能性、効率的な反応性を備えた、明確でスケーラブルなアプリケーション状態の管理方法を提供します。Riverpod は、Provider などの古い状態管理ソリューションにありがちな落とし穴を回避しつつ、依存関係に対して細かく制御できます。そのキャッシュ機構により、重複した計算を避けることでパフォーマンスが向上します。

用途

  • グローバルなアプリケーション状態の管理
  • 非同期データ読み込みの処理
  • 大規模アプリにおける依存関係の挿入
  • 状態付きロジックのテスト
  • リアクティブUIの更新
  • ウィジェット間でデータを共有する

主な機能

  • リアクティブな状態の更新
  • 組み込みの非同期サポート
  • 細粒度の依存関係制御
  • 強力な型安全
  • 簡単なテスト
  • パフォーマンスのためのキャッシュ

適している対象

  • 大規模なFlutterアプリケーション
  • 保守性を重視するチーム
  • 堅牢な非同期処理を必要とする開発者
  • モジュールアーキテクチャを必要とするアプリ
  • テスト性を重視するプロジェクト

注意事項

  • 初心者には学習曲線が急峻です
  • リアクティブプログラミングの理解が必要です
  • シンプルなアプリではオーバーヘッドが発生する可能性があります
  • 古い代替手段と比べてドキュメントが限られている

元の 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 件

ソースリポジトリ

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

ランキング