AnyAnimatedButton은 Flutter 패키지로, 대기, 진행, 성공 및 오류 상태 간에 부드러운 애니메이션을 제공하는 사용자 정의 가능한 버튼을 제공합니다. 폼 제출이나 데이터 로딩과 같은 작업 중 백그라운드 프로세스의 진행 상황을 시각적으로 표시하여 사용자 피드백을 향상시킵니다. 색상, 아이콘, 레이블 및 애니메이션 지속 시간 등 다양한 커스터마이징 옵션을 지원합니다. Android, iOS, Web, macOS, Windows, Linux에서 원활하게 작동하는 크로스플랫폼용으로 설계되었습니다. 실시간 피드백이 필요한 앱의 UX 개선에 이상적입니다.
사용 사례
로딩 상태와 함께 폼 제출
파일 업로드 진행률 표시기
성공/오류 피드백이 있는 인증 흐름
애니메이션 전환을 사용한 온보딩 프로세스
백그라운드 작업 상태 시각화
주요 기능
부드러운 상태 전환 애니메이션
사용자 정의 가능한 성공 및 오류 상태
상태별로 아이콘 및 텍스트 변경을 지원
크로스 플랫폼 호환성
사용자 정의 가능한 애니메이션 지속 시간 및 이징
확장 가능한 스타일 옵션
적합한 대상
직관적인 UI 피드백을 원하는 개발자
자주 비동기 작업을 수행하는 앱
사용자 경험 중심의 모바일 및 웹 애플리케이션
빠르게 상호작용 버튼 프로토타이핑하기
진행률 표시기용 최소한의 블록 코드가 필요한 프로젝트
고려 사항
Flutter의 상태 관리에 대한 이해가 필요합니다
상태 변경을 트리거하기 위해 추가 로직이 필요할 수 있습니다
다중 인스턴스와 성능 영향
사전 정의된 애니메이션 유형에 제한됨
제공된 상태를 초과하는 복잡한 사용자 정의 애니메이션에는 적합하지 않습니다
원본 README
연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.
any_animated_button
Very often after tapping a button we send some data or form to remote API and we need to signalize it to the user. This package makes it easy for us by creating expandable AnyAnimatedButton and AnyAnimatedButtonBloc.
Easy usage
AnyAnimatedButton depends on bloc pattern. To create custom button we need to create new bloc and
widget.
AnyAnimatedButtonBloc
We need to create class, which extends AnyAnimatedButtonBloc and override asyncAction.
AnyAnimatedButton is based on AnimatedContainer. To create our own button we need to create class, which extends CustomAnyAnimatedButton. CustomAnyAnimatedButton consists of 2 fields, which needs to be overridden:
bloc - AnyAnimatedButtonBloc? - bloc which should be connected with the button. If we won't pass it, the button won't animate
defaultParams - AnyAnimatedButtonParams - params object, which describes how button should look and behave
and 3 optional fields:
progressParams - AnyAnimatedButtonParams - params object for describing button in progress state
successParams - AnyAnimatedButtonParams - params object for describing button in success state
errorParams - AnyAnimatedButtonParams - params object for describing button in error state
AnyAnimatedButtonParams
The class that holds all the data about button look and behavior. All properties that we want to animate should be put directly inside all corresponding fields. Rest of them (like Text) should go to child field, which takes Widget.
The only required field is height, rest of them are optional.
We have got also 3 factory constructors, which describe default progress, error and success button state. We can reuse them with changed colors and size.
double.infinity - the button expands as much as he can
null - the button is as small as it can - it fits its content
fixed - we can set fixed width i.e. 200 and the button will always be this wide
Splash effect
There is one problem with InkWell splash effect. If we want the splash effect to work we need to put in child field firstly Material with transparent color → InkWell → rest of the child.
The package has built-in BlocListener, which makes it easier for you to listen to the state changes. AnyAnimatedButtonBlocListener<Input, Output, Failure> takes 3 generic types,Input is type of data that goes into the bloc, Output is type of data returned on success and Failure is the error which will be returned, when any error occurs in bloc.
updating text on button with width set to null does not work properly. The button width will adjust only to the first text width. The workaround is to set fixed width of the longer text instead of null.