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

パッケージ詳細v4.0.9

riverpod_generator

Riverpod用のコードジェネレーターです。構文を簡略化し、状態付きホットリロードなどの機能を強化します。

AndroidiOSmacOSWindowsLinux
30日間ダウンロード
114万
いいね数
437
Pub ポイント
130

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

flutter pub add riverpod_generator

パッケージ概要

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

Riverpod_generator は、Flutter の Riverpod 状態管理ライブラリ向けのコード生成ツールです。プロバイダー定義を自動的に生成することで、ボイラープレートを簡素化し、より洗練された構文と向上した開発者体験を実現します。状態付きホットリロードをサポートしており、開発中に再起動せずに状態を保持できます。Riverpod のエコシステムとシームレスに統合され、手動でのコーディングを減らし、保守性を高めます。パフォーマンスと使いやすさを意識して設計されており、開発者が反復的なセットアップではなく論理に集中できるように支援します。

用途

  • 複雑なプロバイダ宣言の簡素化
  • 開発中にステートフルなホットリロードを有効にする
  • 大規模アプリにおけるボイラープレートの削減
  • 複数のファイルにわたるプロバイダ作成の自動化
  • コードの可読性と保守性の向上

主な機能

  • 自動プロバイダーコード生成
  • 状態付きホットリロードをサポート
  • 手動のボイラープレートを削減する
  • RiverpodのAPIと統合されます
  • 型安全なコードを生成します

適している対象

  • Riverpod を使用する Flutter 開発者
  • スケーラブルな状態管理アプリを開発するチーム
  • ホットリロードによる迅速な反復を求める開発者
  • クリーンでメンテナブルな状態論理を必要とするプロジェクト
  • 繰り返しのプロバイダ設定を最小限に抑えたい人

注意事項

  • Dart コード生成の設定が必要です
  • 適切な build_runner 設定が必要です
  • ビルド時間をわずかに増加させる可能性があります
  • Riverpod コアパッケージに依存しています
  • シンプルで手書きのプロバイダには不要

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

カテゴリー

依存関係

依存関係一覧 12 件

ソースリポジトリ

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