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

local_hero のカバー
パッケージ詳細v0.3.0

local_hero

同じルート内でその位置が変更されたときに、暗黙的にヒーローアニメーションを開始するウィジェットです。

AndroidiOSWebmacOSWindowsLinux
30日間ダウンロード
1.2万
いいね数
274
Pub ポイント
150

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

flutter pub add local_hero

パッケージ概要

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

local_hero パッケージは、同じルート内でウィジェットの位置が変更されたときに暗黙的なヒーローアニメーションを有効にします。ウィジェットの古い位置から新しい位置への移動を自動的にアニメーション化することで、遷移を簡素化し、スムーズな視覚的フローによりユーザー体験を向上させます。単一画面内のナビゲーションや動的なUI更新に最適で、Android、iOS、Web、macOS、Windows、Linuxなどすべての主要プラットフォームで動作します。パッケージは軽量であり、Flutterの既存のアニメーションシステムとシームレスに統合されます。

用途

  • 単一のルート内のスムーズな画面遷移
  • 状態変更中のウィジェット再配置のアニメーション
  • 動的リストにおけるUIフィードバックの向上
  • 直感的なナビゲーション体験の構築
  • レスポンシブレイアウトのシフトをサポート
  • インタラクティブなアプリにおける視覚的連続性の向上

主な機能

  • 位置変更時の自動ヒーローアニメーション
  • Flutter のアニメーションシステムとのシームレスな統合
  • クロスプラットフォーム対応
  • 最小限のボイラープレートが必要
  • 同じルート内でのみ動作します
  • 既存の Hero ウィジェットを補完する

適している対象

  • インタラクティブなUIを構築する開発者
  • 滑らかな遷移を必要とするアプリ
  • UXの一貫性を重視するチーム
  • 動的レイアウトを使用するプロジェクト
  • Flutterの初心者がアニメーションを学習中
  • 頻繁なウィジェット再配置を伴うアプリ

注意事項

  • 同じルートのアニメーションに限定
  • ルート間の遷移をサポートしていません
  • 予期しない動作を避けるために慎重な配置が必要です
  • 複雑なマルチスクリーンナビゲーションには適していません
  • 過剰に使用するとパフォーマンスに影響を与える可能性があります
  • 安定したウィジェットキーと併用するのが最適です

元の README

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

local_hero

Pub

A widget which implicitly launches a hero animation when its position changed within the same route.

Overview

Getting started

In the pubspec.yaml of your flutter project, add the following dependency:

dependencies:
  ...
  local_hero:

In your library add the following import:

import 'package:local_hero/local_hero.dart';

Usage

To be animated implicitly, a widget needs to be surrounded by a LocalHero widget with a unique tag:

const LocalHero(
    tag: 'my_widget_tag',
    child: MyWidget(),
),

A LocalHero widget must have a LocalHeroScope ancestor which hosts the animations properties (duration, curve, etc.). At each frame we must have only one LocalHero per tag, per LocalHeroScope.

The following example shows the basic usage of a LocalHero widget:

class _LocalHeroPage extends StatelessWidget {
  const _LocalHeroPage({
    Key key,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: SafeArea(
        child: LocalHeroScope(
          duration: const Duration(milliseconds: 300),
          curve: Curves.easeInOut,
          child: const _LocalHeroPlayground(),
        ),
      ),
    );
  }
}

class _LocalHeroPlayground extends StatefulWidget {
  const _LocalHeroPlayground({
    Key key,
  }) : super(key: key);

  @override
  _LocalHeroPlaygroundState createState() => _LocalHeroPlaygroundState();
}

class _LocalHeroPlaygroundState extends State<_LocalHeroPlayground> {
  AlignmentGeometry alignment = Alignment.topLeft;

  @override
  Widget build(BuildContext context) {
    return Column(
      children: <Widget>[
        Expanded(
          child: Padding(
            padding: const EdgeInsets.all(8),
            child: Align(
              alignment: alignment,
              child: const LocalHero(
                tag: 'id',
                child: _Box(),
              ),
            ),
          ),
        ),
        RaisedButton(
          onPressed: () {
            setState(() {
              alignment = alignment == Alignment.topLeft
                  ? Alignment.bottomRight
                  : Alignment.topLeft;
            });
          },
          child: const Text('Move'),
        ),
      ],
    );
  }
}

class _Box extends StatelessWidget {
  const _Box({
    Key key,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      color: Colors.red,
      width: 50,
      height: 50,
    );
  }
}

Example

Sponsoring

I'm working on my packages on my free-time, but I don't have as much time as I would. If this package or any other package I created is helping you, please consider to sponsor me so that I can take time to read the issues, fix bugs, merge pull requests and add features to these packages.

Changelog

Please see the Changelog page to know what's recently changed.

Contributions

Feel free to contribute to this project.

If you find a bug or want a feature, but don't know how to fix/implement it, please fill an issue.
If you fixed a bug or implemented a feature, please send a pull request.

カテゴリー

依存関係

依存関係一覧 1 件

ソースリポジトリ

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