#flutter #dart
Вопрос:
Для моего виджета анимация, которая у меня есть, проходит половину пути, потому что я использую это:
TweenSequenceItem<Alignment>(
tween: AlignmentTween(
begin: Alignment.topCenter, end: Alignment.bottomCenter),
weight: 1.0),
Я определил, когда используется topCenter
, чтобы bottomCenter
он, кажется, пересекал половину пути, когда анимация запущена.
Результат:
Я хочу, чтобы он полностью отображался на экране, не мог бы я указать для этого координаты? Если это так, то как бы эти координаты стали динамичными при разных размерах экрана?
Код:
class _BouncingBallState extends State<BouncingBall>
with TickerProviderStateMixin {
AnimationController controller;
Animation<Alignment> alignmentAnimation; // Create animation object
void initState() {
super.initState();
controller = AnimationController(
vsync: this,
duration: Duration(seconds: 60),
);
controller.repeat(); // Make animation repeat
// Initialize using TweenSequence, that contains TweenSequenceItem, we can add multiple TweenSequenceItem as per our animation requirement
alignmentAnimation = TweenSequence<Alignment>([
// First point move from top center to bottom center
TweenSequenceItem<Alignment>(
tween: AlignmentTween(
begin: Alignment.topCenter, end: Alignment.bottomCenter),
weight: 1.0),
}