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

パッケージ詳細v0.2.4

stacked_hooks

stacked パッケージを使用する際にフックを使用するのを支援するクラス

AndroidiOSWebmacOSWindowsLinux
30日間ダウンロード
6890
いいね数
70
Pub ポイント
140

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

flutter pub add stacked_hooks

パッケージ概要

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

Stacked Hooks は、Flutter パッケージであり、Stacked アーキテクチャを拡張し、React スタイルのフックを状態管理ワークフローにスムーズに統合できるユーティリティクラスを提供します。これにより、開発者は Stacked のビューモデル内で useState、useEffect、useStream などのフックを使用でき、よりクリーンでモジュール性の高いコードを実現できます。既に Stacked パッケージを使用している開発者向けに設計されており、既存のロジックを完全に再作成する必要なく、UI コンポーネントでの状態処理を簡素化します。このパッケージはすべての主要プラットフォームをサポートしており、Android、iOS、Web、macOS、Windows、Linux で一貫した動作を保証します。

用途

  • 最小限のボイラープレートでリアクティブなUIを構築する
  • スタックされたビュー モデルでのローカル状態の管理
  • useEffect に似たロジックで副作用を簡素化する
  • ストリームと非同期操作の統合
  • 再利用可能な状態付きウィジェットの作成
  • 複雑なビューの保守性の向上

主な機能

  • Stacked 用の組み込みフックユーティリティ
  • useState、useEffect、useStream のサポート
  • Stackedアーキテクチャとのシームレスな統合
  • クロスプラットフォーム互換性
  • 最小限のセットアップが必要
  • 型安全で直感的な API

適している対象

  • Stacked パッケージを使用する開発者
  • より明確な状態管理を求めるチーム
  • 複雑な UI ロジックを持つ Flutter アプリ
  • ボイラープレートを削減することを目指すプロジェクト
  • React Hooks に慣れ親しんだ人
  • 複数のプラットフォームをターゲットにするアプリ

注意事項

  • Stacked パッケージが必要です
  • スタックベースのプロジェクトに限定
  • 新しいフックユーザーには学習曲線が必要になる可能性があります
  • スタックされていないアーキテクチャには適していません
  • 中規模から大規模なアプリで最も効果的に使用される
  • Dart の非同期およびストリーム処理に依存しています

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

Stacked Hooks

This package contains widgets that allow you to use the Flutter Hooks package with the StackedView in the Stacked architecture.

StackedHookView

The StackedView is an implementation of a widget class that returns a value provided by Provider as a parameter in the build function of the widget. This allows for easier consumption and use of ViewModel without boilerplate. The StackedHookView allows you to use this widget and make use of Flutter Hooks inside the build function. This is very useful when you want to use TextEditing controllers and you're implementing this architecture.

// View that creates and provides the viewmodel
class StackedHookViewExample extends StackedView<HomeViewModel> {
  const StackedHookViewExample({Key key}) : super(key: key);

  @override
  Widget builder(BuildContext context, HomeViewModel model, Widget? child) {
    return Scaffold(
      body: Center(child: _HookForm()),
    );
  }

  @override
  HomeViewModel modelBuilder(BuildContext context) {
    return HomeViewModel();
  }
}

// Form that makes use of the ViewModel provided above but also makes use of hooks
class _HookForm extends StackedHookView<HomeViewModel> {
  @override
  Widget buildStackedView(BuildContext context, HomeViewModel model) {
    final title = useTextEditingController();
    return Column(
      mainAxisSize: MainAxisSize.min,
      children: <Widget>[
        Text(model.title),
        TextField(controller: title, onChanged: model.updateTitle),
      ],
    );
  }
}

// ViewModel
class HomeViewModel extends BaseViewModel {
  String title = 'default';

  void updateTitle(String value) {
    title = value;
    notifyListeners();
  }
}

カテゴリー

依存関係

依存関係一覧 2 件

ソースリポジトリ

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