@@ -15,6 +15,7 @@ class AdvancedDrawer extends StatefulWidget {
1515 this .animateChildDecoration = true ,
1616 this .rtlOpening = false ,
1717 this .disabledGestures = false ,
18+ this .animationController,
1819 }) : super (key: key);
1920
2021 /// Child widget. (Usually widget that represent a screen)
@@ -51,6 +52,9 @@ class AdvancedDrawer extends StatefulWidget {
5152 /// Disable gestures.
5253 final bool disabledGestures;
5354
55+ /// Controller that controlls widget animation.
56+ final AnimationController ? animationController;
57+
5458 @override
5559 _AdvancedDrawerState createState () => _AdvancedDrawerState ();
5660}
@@ -75,11 +79,13 @@ class _AdvancedDrawerState extends State<AdvancedDrawer>
7579 _controller = widget.controller ?? AdvancedDrawerController ();
7680 _controller.addListener (handleControllerChanged);
7781
78- _animationController = AnimationController (
79- vsync: this ,
80- duration: widget.animationDuration,
81- value: _controller.value.visible ? 1 : 0 ,
82- );
82+ _animationController = widget.animationController ??
83+ AnimationController (
84+ vsync: this ,
85+ value: _controller.value.visible ? 1 : 0 ,
86+ );
87+
88+ _animationController.duration = widget.animationDuration;
8389
8490 final parentAnimation = widget.animationCurve != null
8591 ? CurvedAnimation (
@@ -259,12 +265,15 @@ class _AdvancedDrawerState extends State<AdvancedDrawer>
259265 @override
260266 void dispose () {
261267 _controller.removeListener (handleControllerChanged);
262- _animationController.dispose ();
263268
264269 if (widget.controller == null ) {
265270 _controller.dispose ();
266271 }
267272
273+ if (widget.animationContoller == null ) {
274+ _animationController.dispose ();
275+ }
276+
268277 super .dispose ();
269278 }
270279}
0 commit comments