패키지, 저장소 및 앱 카테고리 검색

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 개

소스 저장소

이 패키지를 사용하는 프로젝트