@@ -11,6 +11,7 @@ class AdvancedDrawer extends StatefulWidget {
11
11
this .backdrop,
12
12
this .openRatio = 0.75 ,
13
13
this .openScale = 0.85 ,
14
+ this .drawerSlideRatio = 0 ,
14
15
this .animationDuration = const Duration (milliseconds: 250 ),
15
16
this .animationCurve,
16
17
this .childDecoration,
@@ -41,6 +42,11 @@ class AdvancedDrawer extends StatefulWidget {
41
42
/// Opening ratio.
42
43
final double openScale;
43
44
45
+ /// How far the drawer segment should slide with the content
46
+ /// 0 = no slide distance
47
+ /// 1 = slide from completely off screen
48
+ final double drawerSlideRatio;
49
+
44
50
/// Animation duration.
45
51
final Duration animationDuration;
46
52
@@ -77,6 +83,7 @@ class _AdvancedDrawerState extends State<AdvancedDrawer>
77
83
late Animation <double > _drawerScaleAnimation;
78
84
late Animation <Offset > _childSlideAnimation;
79
85
late Animation <double > _childScaleAnimation;
86
+ late Animation <Offset > _drawerSlideAnimation;
80
87
late Animation <Decoration > _childDecorationAnimation;
81
88
82
89
late double _offsetValue;
@@ -120,15 +127,18 @@ class _AdvancedDrawerState extends State<AdvancedDrawer>
120
127
alignment: widget.rtlOpening
121
128
? Alignment .centerRight
122
129
: Alignment .centerLeft,
123
- child: FractionallySizedBox (
124
- widthFactor: widget.openRatio,
125
- child: ScaleTransition (
126
- scale: _drawerScaleAnimation,
127
- alignment: widget.rtlOpening
128
- ? Alignment .centerLeft
129
- : Alignment .centerRight,
130
- child: RepaintBoundary (
131
- child: widget.drawer,
130
+ child: SlideTransition (
131
+ position: _drawerSlideAnimation,
132
+ child: FractionallySizedBox (
133
+ widthFactor: widget.openRatio,
134
+ child: ScaleTransition (
135
+ scale: _drawerScaleAnimation,
136
+ alignment: widget.rtlOpening
137
+ ? Alignment .centerLeft
138
+ : Alignment .centerRight,
139
+ child: RepaintBoundary (
140
+ child: widget.drawer,
141
+ ),
132
142
),
133
143
),
134
144
),
@@ -232,6 +242,11 @@ class _AdvancedDrawerState extends State<AdvancedDrawer>
232
242
end: 1.0 ,
233
243
).animate (parentAnimation);
234
244
245
+ _drawerSlideAnimation = Tween <Offset >(
246
+ begin: Offset (- widget.drawerSlideRatio, 0 ),
247
+ end: Offset .zero,
248
+ ).animate (parentAnimation);
249
+
235
250
_childSlideAnimation = Tween <Offset >(
236
251
begin: Offset .zero,
237
252
end: Offset (widget.openRatio, 0 ),
@@ -252,7 +267,9 @@ class _AdvancedDrawerState extends State<AdvancedDrawer>
252
267
// If widget is not mounted do nothing
253
268
if (! mounted) return ;
254
269
// If the value of _controller is visible, forward the animation; otherwise, reverse it
255
- _controller.value.visible ? _animationController.forward () : _animationController.reverse ();
270
+ _controller.value.visible
271
+ ? _animationController.forward ()
272
+ : _animationController.reverse ();
256
273
}
257
274
258
275
void _handleDragStart (DragStartDetails details) {
0 commit comments