phased
專注於動畫的簡化狀態管理
專注於動畫的簡化狀態管理
以下為英文專案原文快照,最新內容請造訪 GitHub。
Simplified state management focused on animations
❗ In order to start using Phased you must have the Flutter SDK installed on your machine.
Add phased to your pubspec.yaml:
dependencies:
phased:
Install it:
flutter packages get
Phased is a simple state management meant to be used to build animations, its objective is to provide an easy, boilerplateless way to create and manage the state of an animation, so developers can focus on building the animations themselves.
The package consists of two classes: PhasedState, which describes the state and offers control methods for an animation, and Phased, an abstract Widget that will build the animation itself.
To build a simple animation that blinks a child using opacity, the following code can be used:
class BlinkState extends PhasedState<bool> {
BlinkState() : super(values: [true, false]);
}
class Blink extends Phased<bool> {
const Blink({
super.key,
required super.state,
required this.child,
});
final Widget child;
@override
Widget build(BuildContext context) {
return AnimatedOpacity(
opacity: state.phaseValue(
values: const {true: 1},
defaultValue: 0,
),
onEnd: state.next,
duration: const Duration(milliseconds: 250),
child: child,
);
}
}
Then to use it:
Blink(
state: BlinkState(),
child: Container(
width: 100,
height: 100,
color: Colors.blue,
),
);
For more complex examples, check the example folder.
依賴清單 4 項
{"sdk":"flutter"}{"sdk":"flutter"}^0.3.0^3.1.0先依使用情境篩選,再比較專案活躍情況,最後到原始儲存庫確認使用要求。
“A repository is the most basic element of GitHub.”
GitHub Docs — About repositories ↗