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

패키지 상세v0.2.9+1

smart_flare

더 큰 flare 애니메이션과 상호작용을 처리하는 데 도움이 되는 패키지입니다.

30일 다운로드
53
좋아요
53
Pub 점수
40

패키지 설치

flutter pub add smart_flare

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

Smart Flare는 앱 내에서 대규모이고 복잡한 Flare 애니메이션 및 상호작용 요소를 통합하고 관리하는 것을 간편하게 만들어주는 Flutter 패키지입니다. 자산 로딩을 최적화하고 상태 전환을 처리하며 반응형 상호작용을 가능하게 함으로써 성능과 개발자 경험을 향상시킵니다. 게임과 풍부한 UI에 적합하며, 직관적인 API로 Flare의 애니메이션 기능 사용을 단순화합니다. 동적 콘텐츠 업데이트와 다양한 화면 크기에서 부드러운 재생을 지원합니다.

사용 사례

  • 인터랙티브 게임 인터페이스
  • 복잡한 애니메이션 온보딩 흐름
  • 앱 내 동적 UI 요소
  • 풍부한 스토리텔링 경험
  • 성능 최적화 애니메이션
  • 실시간 캐릭터 상호작용

주요 기능

  • 큰 Flare 파일에 대한 최적화된 로딩
  • 내장된 상호작용 처리
  • 애니메이션을 위한 상태 관리
  • 반응형 디자인 지원
  • Flutter 위젯과의 간편한 통합
  • 동적 애니메이션 변경 지원

적합한 대상

  • Flare를 사용하는 게임 개발자
  • UI 디자이너가 애니메이션 경험을 만들고 있습니다
  • 고성능 애니메이션을 필요로 하는 앱
  • 복잡한 Flare 자산을 사용하는 개발자
  • 원활한 사용자 상호작용에 집중하는 팀

고려 사항

  • 올바르게 내보낸 플레어 자산이 필요합니다
  • 이미 Flare를 사용 중인 프로젝트에 가장 적합
  • Flare 렌더링을 지원하는 플랫폼에 한정
  • 큰 애니메이션을 사용하면 앱 크기가 증가할 수 있습니다
  • FilledStacks의 Flare 생태계에 의존

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

Smart Flare - Customizable Interactable Flare actors

Interactive capabilities for larger Flare animations.

Installation

Add smart_flare as dependency to your pubspec file.

smart_flare: any

Example

Here is an example of how to use the functionality within this project.

Usage

If you want to just play a normal animation I would recommend using Flare's Flutter Package. This is for animations that you want some interaction on.

This is used the same as a Flare Actor is used with some additional properties. To use this actor at a minimum level you have to supply width, heigh and the filename to the animation. This will draw the animation on screen without playing anything.

import 'package:flutter/material.dart';
import 'package:smart_flare/smart_flare.dart';

class FlareDemo extends StatefulWidget {
  @override
  _FlareDemoState createState() => _FlareDemoState();
}

class _FlareDemoState extends State<FlareDemo> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.black,
        body: SmartFlareActor(
            width: 295.0,
            height: 251.0,
            filename: 'assets/button-animation.flr'));
  }
}

Additionally you can then give it a starting animation for it to play something.

SmartFlareActor(
    width: 295.0,
    height: 251.0,
    filename: 'assets/button-animation.flr',
    startingAnimation: 'deactivate')
Interactive Areas

The main feature of this package is to provide it's interactive nature. You can supply the actor with ActiveArea's which looks as follows.

class ActiveArea {
  final Rect area;
  final String animationName;
  final List<String> animationsToCycle;
  final Function onAreaTapped;
  final List<String> guardComingFrom;
  final bool debugArea;
  ...
}

Each active area requires an area and either an animationName to play when tapped, or a list of animationsToCycle through when tapped. You can also set debugArea to true and the touch area will display over the animation so you can see if your calculations are correct.

ActiveArea(
    debugArea: true,
    area: Rect.fromLTWH(thirdOfWidth*2, 0, thirdOfWidth, animationHeight / 2),
    animationName: 'image_tapped',
   ),

Areas can also be defined using relative placements.

 RelativeActiveArea(
    // from (0,0) with a width 35% of animation width and 50% of height
    area: Rect.fromLTRB(0, 0, 0.35, 0.5),
    animationName: 'camera_tapped'
),
Area Callbacks

If you want to perform an action when something is tapped, which you probably do you can supply a function to onAreaTapped and run your code in there.

ActiveArea(
    debugArea: true,
    area: Rect.fromLTWH(thirdOfWidth*2, 0, thirdOfWidth, animationHeight / 2),
    animationName: 'image_tapped',
    onAreaTapped: () {
      print('Area Tapped!');
    }
   )
Guarding against animation

If you want to make sure that an animation does not play after another you can supply it with a list of animations to guard against. This means that, the area animation you want to play, WILL NOT PLAY of the last played animation is contained in the guardComingFrom list. GuardGoingTo coming in next release.

ActiveArea(
          debugArea: true,
          area: Rect.fromLTWH(thirdOfWidth*2, 0, thirdOfWidth, animationHeight / 2),
          guardComingFrom: ['deactivate'],
          animationName: 'image_tapped',
          onAreaTapped: () {
            print('Image tapped!');
          }),

And that's it!

Specialized Actors
CycleFlareActor

Given a list of animations this actor will play one after the other as it is tapped.

CycleFlareActor(
    width: animationWidth,
    height: animationHeight,
    filename: 'assets/button-animation.flr',
    animations: ['deactivate', 'activate'],
  )
PanFlareActor

Given an open and close animation this actor will play those animations when panned across it. It plays the open animation in the direction supplied. If no close animation is provided the open animation will be reversed when swiping in the "closing" direction.

Currently only supports horizontal panning. Vertical panning on the way.

PanFlareActor(
    width: 135.0,
    height: screenSize.height,
    filename: "assets/tutorial-transition.flr",
    openAnimation: 'drawer-open',
    closeAnimation: 'drawer-close',
    direction: ActorAdvancingDirection.RightToLeft,
    threshold: 60.0,
    reverseOnRelease: true,
    activeAreas: [
      RelativePanArea(
        area: Rect.fromLTWH(0, 0.7, 1.0, 0.3),
        debugArea: true
      )
    ],
  )

threshold (optional): Total number of pixels to swipe to play the animation until the end when released.

reverseOnRelease (optional. Default true): Tells the actor to reverse the animation when the user stops interacting with the actor and the threshold is not reached.

activeAreas (required): You have to supply at least one relative pan area

Contribution

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request.

카테고리

의존성

의존성 목록 1 개

소스 저장소

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