add a default anim duration arg to controller

This commit is contained in:
2025-07-26 23:36:05 +00:00
parent 12137ba4dd
commit 1fb559f5f0
+10 -5
View File
@@ -28,10 +28,15 @@ class LazyCanvasController with ChangeNotifier {
late BuildContext _context; late BuildContext _context;
bool debug; bool debug;
final Duration defaultAnimationDuration;
LazyCanvasController({this.debug = false, Offset? buildCacheExtent, Size hashCellSize = const Size(100, 100)}) LazyCanvasController({
: _hashCellSize = hashCellSize, this.debug = false,
_buildCacheExtent = buildCacheExtent != null ? buildCacheExtent + Offset(50, 50) : null Offset? buildCacheExtent,
Size hashCellSize = const Size(100, 100),
this.defaultAnimationDuration = const Duration(milliseconds: 300),
}) : _hashCellSize = hashCellSize,
_buildCacheExtent = buildCacheExtent != null ? buildCacheExtent + Offset(50, 50) : null
// only top left is considered so if a widget has long width, it'll not be rendered // only top left is considered so if a widget has long width, it'll not be rendered
// unless the cache extent is sufficient // unless the cache extent is sufficient
{ {
@@ -284,10 +289,10 @@ class LazyCanvasController with ChangeNotifier {
Future<void> animateToOffsetAndScale({ Future<void> animateToOffsetAndScale({
required Offset offset, required Offset offset,
required double scale, required double scale,
Duration? duration = const Duration(milliseconds: 300), Duration? duration,
Curve curve = Curves.easeInOut, Curve curve = Curves.easeInOut,
}) async { }) async {
final anim = AnimationController(vsync: _ticker!, duration: duration); final anim = AnimationController(vsync: _ticker!, duration: duration ?? defaultAnimationDuration);
final offsetTween = Tween<Offset>(begin: _gsTopLeftOffset, end: offset); final offsetTween = Tween<Offset>(begin: _gsTopLeftOffset, end: offset);
final scaleTween = Tween<double>(begin: _scale, end: scale); final scaleTween = Tween<double>(begin: _scale, end: scale);