@@ -206,6 +206,10 @@ class AdaptiveLayout extends StatefulWidget {
206206class _AdaptiveLayoutState extends State <AdaptiveLayout >
207207 with TickerProviderStateMixin {
208208 late AnimationController _controller;
209+ late final CurvedAnimation _sizeAnimation = CurvedAnimation (
210+ parent: _controller,
211+ curve: Curves .easeInOutCubic,
212+ );
209213
210214 late Map <String , SlotLayoutConfig ?> chosenWidgets =
211215 < String , SlotLayoutConfig ? > {};
@@ -250,6 +254,10 @@ class _AdaptiveLayoutState extends State<AdaptiveLayout>
250254 @override
251255 void dispose () {
252256 _controller.dispose ();
257+ _sizeAnimation.dispose ();
258+ for (final ValueNotifier <Key ?> notifier in notifiers.values) {
259+ notifier.dispose ();
260+ }
253261 super .dispose ();
254262 }
255263
@@ -314,6 +322,7 @@ class _AdaptiveLayoutState extends State<AdaptiveLayout>
314322 bodyOrientation: widget.bodyOrientation,
315323 textDirection: Directionality .of (context) == TextDirection .ltr,
316324 hinge: hinge,
325+ sizeAnimation: _sizeAnimation,
317326 ),
318327 children: entries,
319328 );
@@ -333,6 +342,7 @@ class _AdaptiveLayoutDelegate extends MultiChildLayoutDelegate {
333342 required this .internalAnimations,
334343 required this .bodyOrientation,
335344 required this .textDirection,
345+ required this .sizeAnimation,
336346 this .hinge,
337347 }) : super (relayout: controller);
338348
@@ -346,6 +356,7 @@ class _AdaptiveLayoutDelegate extends MultiChildLayoutDelegate {
346356 final Axis bodyOrientation;
347357 final bool textDirection;
348358 final Rect ? hinge;
359+ final Animation <double > sizeAnimation;
349360
350361 @override
351362 void performLayout (Size size) {
@@ -359,10 +370,7 @@ class _AdaptiveLayoutDelegate extends MultiChildLayoutDelegate {
359370 double animatedSize (double begin, double end) {
360371 if (isAnimating.contains (_SlotIds .secondaryBody.name)) {
361372 return internalAnimations
362- ? Tween <double >(begin: begin, end: end)
363- .animate (CurvedAnimation (
364- parent: controller, curve: Curves .easeInOutCubic))
365- .value
373+ ? Tween <double >(begin: begin, end: end).animate (sizeAnimation).value
366374 : end;
367375 }
368376 return end;
0 commit comments