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

パッケージ詳細v4.0.7

riverpod_annotation

riverpod_generator 用のアノテーションを公開するパッケージ

AndroidiOSWebmacOSWindowsLinux
30日間ダウンロード
142万
いいね数
181
Pub ポイント
130

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

flutter pub add riverpod_annotation

パッケージ概要

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

riverpod_annotation は、Flutter アプリケーションで Riverpod プロバイダーを作成するのを簡素化するためのコード生成パッケージです。riverpod_generator と連携して、ボイラープレートコードを自動的に生成し、手作業による作業と潜在的なエラーを減らします。簡単なアノテーションを使用することで、開発者は状態管理ロジックをより効率的に定義でき、コードの読みやすさと保守性が向上します。このパッケージはすべての主要プラットフォームをサポートしており、クロスプラットフォーム開発に最適です。

用途

  • プロバイダの生成を自動化する
  • 状態管理のセットアップを簡素化する
  • Riverpod コードにおけるボイラープレートの削減
  • 型安全な依存関係の有効化
  • 大規模アプリアーキテクチャのサポート

主な機能

  • プロバイダを定義するためのアノテーション
  • riverpod_generator との統合
  • 型安全の強制
  • クロスプラットフォーム互換性
  • 最小の実行時オーバーヘッド

適している対象

  • Riverpod を使用する Flutter 開発者
  • コードの保守性を優先するチーム
  • スケーラブルな状態管理を必要とするプロジェクト
  • ボイラープレートを減らしたい開発者
  • 複数のプラットフォームをターゲットにするアプリ

注意事項

  • riverpod_generator を含める必要があります
  • コード生成には build_runner が必要です
  • ビルド時間をわずかに増加させる可能性があります
  • 実行時プロバイダ作成には適していません
  • 正しいアノテーションの使用に依存する

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

カテゴリー

依存関係

依存関係一覧 2 件

ソースリポジトリ

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