@@ -206,6 +206,10 @@ class AdaptiveLayout extends StatefulWidget {
206
206
class _AdaptiveLayoutState extends State <AdaptiveLayout >
207
207
with TickerProviderStateMixin {
208
208
late AnimationController _controller;
209
+ late final CurvedAnimation _sizeAnimation = CurvedAnimation (
210
+ parent: _controller,
211
+ curve: Curves .easeInOutCubic,
212
+ );
209
213
210
214
late Map <String , SlotLayoutConfig ?> chosenWidgets =
211
215
< String , SlotLayoutConfig ? > {};
@@ -250,6 +254,10 @@ class _AdaptiveLayoutState extends State<AdaptiveLayout>
250
254
@override
251
255
void dispose () {
252
256
_controller.dispose ();
257
+ _sizeAnimation.dispose ();
258
+ for (final ValueNotifier <Key ?> notifier in notifiers.values) {
259
+ notifier.dispose ();
260
+ }
253
261
super .dispose ();
254
262
}
255
263
@@ -314,6 +322,7 @@ class _AdaptiveLayoutState extends State<AdaptiveLayout>
314
322
bodyOrientation: widget.bodyOrientation,
315
323
textDirection: Directionality .of (context) == TextDirection .ltr,
316
324
hinge: hinge,
325
+ sizeAnimation: _sizeAnimation,
317
326
),
318
327
children: entries,
319
328
);
@@ -333,6 +342,7 @@ class _AdaptiveLayoutDelegate extends MultiChildLayoutDelegate {
333
342
required this .internalAnimations,
334
343
required this .bodyOrientation,
335
344
required this .textDirection,
345
+ required this .sizeAnimation,
336
346
this .hinge,
337
347
}) : super (relayout: controller);
338
348
@@ -346,6 +356,7 @@ class _AdaptiveLayoutDelegate extends MultiChildLayoutDelegate {
346
356
final Axis bodyOrientation;
347
357
final bool textDirection;
348
358
final Rect ? hinge;
359
+ final Animation <double > sizeAnimation;
349
360
350
361
@override
351
362
void performLayout (Size size) {
@@ -359,10 +370,7 @@ class _AdaptiveLayoutDelegate extends MultiChildLayoutDelegate {
359
370
double animatedSize (double begin, double end) {
360
371
if (isAnimating.contains (_SlotIds .secondaryBody.name)) {
361
372
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
366
374
: end;
367
375
}
368
376
return end;
0 commit comments