@@ -12,6 +12,7 @@ class AdvancedDrawer extends StatefulWidget {
12
12
this .openRatio = 0.75 ,
13
13
this .openScale = 0.85 ,
14
14
this .initialDrawerScale = 0.75 ,
15
+ this .drawerSlideRatio = 0 ,
15
16
this .animationDuration = const Duration (milliseconds: 250 ),
16
17
this .animationCurve,
17
18
this .childDecoration,
@@ -46,6 +47,11 @@ class AdvancedDrawer extends StatefulWidget {
46
47
/// Set to 1 to disable drawer segment scale effect.
47
48
final double initialDrawerScale;
48
49
50
+ /// How far the drawer segment should slide with the content
51
+ /// 0 = no slide distance
52
+ /// 1 = slide from completely off screen
53
+ final double drawerSlideRatio;
54
+
49
55
/// Animation duration.
50
56
final Duration animationDuration;
51
57
@@ -82,6 +88,7 @@ class _AdvancedDrawerState extends State<AdvancedDrawer>
82
88
late Animation <double > _drawerScaleAnimation;
83
89
late Animation <Offset > _childSlideAnimation;
84
90
late Animation <double > _childScaleAnimation;
91
+ late Animation <Offset > _drawerSlideAnimation;
85
92
late Animation <Decoration > _childDecorationAnimation;
86
93
87
94
late double _offsetValue;
@@ -125,15 +132,18 @@ class _AdvancedDrawerState extends State<AdvancedDrawer>
125
132
alignment: widget.rtlOpening
126
133
? Alignment .centerRight
127
134
: Alignment .centerLeft,
128
- child: FractionallySizedBox (
129
- widthFactor: widget.openRatio,
130
- child: ScaleTransition (
131
- scale: _drawerScaleAnimation,
132
- alignment: widget.rtlOpening
133
- ? Alignment .centerLeft
134
- : Alignment .centerRight,
135
- child: RepaintBoundary (
136
- child: widget.drawer,
135
+ child: SlideTransition (
136
+ position: _drawerSlideAnimation,
137
+ child: FractionallySizedBox (
138
+ widthFactor: widget.openRatio,
139
+ child: ScaleTransition (
140
+ scale: _drawerScaleAnimation,
141
+ alignment: widget.rtlOpening
142
+ ? Alignment .centerLeft
143
+ : Alignment .centerRight,
144
+ child: RepaintBoundary (
145
+ child: widget.drawer,
146
+ ),
137
147
),
138
148
),
139
149
),
@@ -238,6 +248,11 @@ class _AdvancedDrawerState extends State<AdvancedDrawer>
238
248
end: 1.0 ,
239
249
).animate (parentAnimation);
240
250
251
+ _drawerSlideAnimation = Tween <Offset >(
252
+ begin: Offset (- widget.drawerSlideRatio, 0 ),
253
+ end: Offset .zero,
254
+ ).animate (parentAnimation);
255
+
241
256
_childSlideAnimation = Tween <Offset >(
242
257
begin: Offset .zero,
243
258
end: Offset (widget.openRatio, 0 ),
0 commit comments