From 1fb559f5f09f84ab963b76f9d443672aebf456b5 Mon Sep 17 00:00:00 2001 From: ruinivist Date: Sat, 26 Jul 2025 23:36:05 +0000 Subject: [PATCH] add a default anim duration arg to controller --- lib/core/controller/controller.dart | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/core/controller/controller.dart b/lib/core/controller/controller.dart index c783e62..1bb610f 100644 --- a/lib/core/controller/controller.dart +++ b/lib/core/controller/controller.dart @@ -28,10 +28,15 @@ class LazyCanvasController with ChangeNotifier { late BuildContext _context; bool debug; + final Duration defaultAnimationDuration; - LazyCanvasController({this.debug = false, Offset? buildCacheExtent, Size hashCellSize = const Size(100, 100)}) - : _hashCellSize = hashCellSize, - _buildCacheExtent = buildCacheExtent != null ? buildCacheExtent + Offset(50, 50) : null + LazyCanvasController({ + this.debug = false, + 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 // unless the cache extent is sufficient { @@ -284,10 +289,10 @@ class LazyCanvasController with ChangeNotifier { Future animateToOffsetAndScale({ required Offset offset, required double scale, - Duration? duration = const Duration(milliseconds: 300), + Duration? duration, Curve curve = Curves.easeInOut, }) async { - final anim = AnimationController(vsync: _ticker!, duration: duration); + final anim = AnimationController(vsync: _ticker!, duration: duration ?? defaultAnimationDuration); final offsetTween = Tween(begin: _gsTopLeftOffset, end: offset); final scaleTween = Tween(begin: _scale, end: scale);