Я хочу что-то вроде этого:
Но пока у меня так:
Это мой код:
import 'dart:ui' as ui;
import 'package:flutter/material.dart';
class CustomTimePainter extends CustomPainter {
CustomTimePainter({
required this.animation,
required this.backgroundColor,
required this.color,
}) : super(repaint: animation);
final Animation<double> animation;
final Color backgroundColor, color;
@override
void paint(Canvas canvas, Size size) {
var paint = Paint()..color = backgroundColor;
canvas.drawPaint(paint);
final top = ui.lerpDouble(0, size.height, animation.value)!;
Rect rect = Rect.fromLTRB(0, 0, size.width, top);
Path path = Path()..addRect(rect);
canvas.drawPath(path, paint..color = color);
}
@override
bool shouldRepaint(CustomTimePainter old) {
return animation.value != old.animation.value ||
color != old.color ||
backgroundColor != old.backgroundColor;
}
}
Как запустить анимацию сверху вниз, как в первом видео?
Спасибо за любую помощь, которую вы можете предоставить
Переключите свой прямоугольник
От
Rect rect = Rect.fromLTRB(0, 0, size.width, top);
К
Rect rect = Rect.fromLTRB(0, top, size.width, size.height);
Таким образом, низ всегда будет size.height.
Подробнее о Rect.fromLTRB
поменяй местами lerpDouble
лайк final top = ui.lerpDouble(size.height, 0, animation.value)!;
Привет @YeasinSheikh, к сожалению, это не работает, это мой репозиторий на GitHub: github.com/codemotozu/stack-overflow-questin если хотите, можете попробовать сами и посмотреть, что происходит