@@ -15,8 +15,7 @@ typedef InnerDrawerCallback = void Function(bool isOpened);
15
15
16
16
/// Signature for when a pointer that is in contact with the screen and moves to the right or left
17
17
/// values between 1 and 0
18
- typedef InnerDragUpdateCallback = void Function (
19
- double value, InnerDrawerDirection ? direction);
18
+ typedef InnerDragUpdateCallback = void Function (double value, InnerDrawerDirection ? direction);
20
19
21
20
/// The possible position of a [InnerDrawer] .
22
21
enum InnerDrawerDirection {
@@ -134,12 +133,9 @@ class InnerDrawer extends StatefulWidget {
134
133
InnerDrawerState createState () => InnerDrawerState ();
135
134
}
136
135
137
- class InnerDrawerState extends State <InnerDrawer >
138
- with SingleTickerProviderStateMixin {
139
- ColorTween _colorTransitionChild =
140
- ColorTween (begin: Colors .transparent, end: Colors .black54);
141
- ColorTween _colorTransitionScaffold =
142
- ColorTween (begin: Colors .black54, end: Colors .transparent);
136
+ class InnerDrawerState extends State <InnerDrawer > with SingleTickerProviderStateMixin {
137
+ ColorTween _colorTransitionChild = ColorTween (begin: Colors .transparent, end: Colors .black54);
138
+ ColorTween _colorTransitionScaffold = ColorTween (begin: Colors .black54, end: Colors .transparent);
143
139
144
140
double _initWidth = _kWidth;
145
141
Orientation _orientation = Orientation .portrait;
@@ -172,15 +168,13 @@ class InnerDrawerState extends State<InnerDrawer>
172
168
setState (() {
173
169
// The animation controller's state is our build state, and it changed already.
174
170
});
175
- if (widget.colorTransitionChild != null )
176
- _colorTransitionChild = ColorTween (
177
- begin: widget.colorTransitionChild! .withOpacity (0.0 ),
178
- end: widget.colorTransitionChild);
171
+ if (widget.colorTransitionChild != null ) {
172
+ _colorTransitionChild = ColorTween (begin: widget.colorTransitionChild! .withOpacity (0.0 ), end: widget.colorTransitionChild);
173
+ }
179
174
180
- if (widget.colorTransitionScaffold != null )
181
- _colorTransitionScaffold = ColorTween (
182
- begin: widget.colorTransitionScaffold,
183
- end: widget.colorTransitionScaffold! .withOpacity (0.0 ));
175
+ if (widget.colorTransitionScaffold != null ) {
176
+ _colorTransitionScaffold = ColorTween (begin: widget.colorTransitionScaffold, end: widget.colorTransitionScaffold! .withOpacity (0.0 ));
177
+ }
184
178
185
179
if (widget.onDragUpdate != null && _controller.value < 1 ) {
186
180
widget.onDragUpdate !((1 - _controller.value), _position);
@@ -212,16 +206,18 @@ class InnerDrawerState extends State<InnerDrawer>
212
206
case AnimationStatus .dismissed:
213
207
if (_previouslyOpened != opened) {
214
208
_previouslyOpened = opened;
215
- if (widget.innerDrawerCallback != null )
209
+ if (widget.innerDrawerCallback != null ) {
216
210
widget.innerDrawerCallback !(opened);
211
+ }
217
212
}
218
213
_ensureHistoryEntry ();
219
214
break ;
220
215
case AnimationStatus .completed:
221
216
if (_previouslyOpened != opened) {
222
217
_previouslyOpened = opened;
223
- if (widget.innerDrawerCallback != null )
218
+ if (widget.innerDrawerCallback != null ) {
224
219
widget.innerDrawerCallback !(opened);
220
+ }
225
221
}
226
222
_historyEntry? .remove ();
227
223
_historyEntry = null ;
@@ -253,8 +249,7 @@ class InnerDrawerState extends State<InnerDrawer>
253
249
/// get width of screen after initState
254
250
void _updateWidth () {
255
251
WidgetsBinding .instance! .addPostFrameCallback ((_) {
256
- final RenderBox ? box =
257
- _drawerKey.currentContext! .findRenderObject () as RenderBox ? ;
252
+ final RenderBox ? box = _drawerKey.currentContext! .findRenderObject () as RenderBox ? ;
258
253
//final RenderBox box = context.findRenderObject();
259
254
if (box != null &&
260
255
box.hasSize &&
@@ -271,10 +266,11 @@ class InnerDrawerState extends State<InnerDrawer>
271
266
void _move (DragUpdateDetails details) {
272
267
double delta = details.primaryDelta! / _width;
273
268
274
- if (delta > 0 && _controller.value == 1 && _leftChild != null )
269
+ if (delta > 0 && _controller.value == 1 && _leftChild != null ) {
275
270
_position = InnerDrawerDirection .start;
276
- else if (delta < 0 && _controller.value == 1 && _rightChild != null )
271
+ } else if (delta < 0 && _controller.value == 1 && _rightChild != null ) {
277
272
_position = InnerDrawerDirection .end;
273
+ }
278
274
279
275
double offset = _position == InnerDrawerDirection .start
280
276
? widget.offset.left
@@ -431,11 +427,7 @@ class InnerDrawerState extends State<InnerDrawer>
431
427
432
428
final Widget ? invC = _invisibleCover ();
433
429
434
- final Widget scaffoldChild = Stack (
435
- children: < Widget ? > [widget.scaffold, invC != null ? invC : null ]
436
- .where ((a) => a != null )
437
- .toList () as List <Widget >,
438
- );
430
+ final Widget scaffoldChild = Stack (children: [widget.scaffold, invC ?? Container ()].where ((Widget a) => a.runtimeType.toString ().toLowerCase () != 'container' ).toList ());
439
431
440
432
Widget container = Container (
441
433
key: _drawerKey,
@@ -580,10 +572,7 @@ class InnerDrawerState extends State<InnerDrawer>
580
572
final double wFactor = (_controller.value * (1 - offset)) + offset;
581
573
582
574
return Container (
583
- decoration: widget.backgroundDecoration ??
584
- BoxDecoration (
585
- color: Theme .of (context).backgroundColor,
586
- ),
575
+ decoration: widget.backgroundDecoration ?? BoxDecoration (color: Theme .of (context).backgroundColor),
587
576
child: Stack (
588
577
alignment: _drawerInnerAlignment! ,
589
578
children: < Widget > [
@@ -597,13 +586,10 @@ class InnerDrawerState extends State<InnerDrawer>
597
586
excludeFromSemantics: true ,
598
587
child: RepaintBoundary (
599
588
child: Stack (
600
- children: < Widget ? > [
589
+ children: [
601
590
///Gradient
602
591
Container (
603
- width: _controller.value == 0 ||
604
- _animationType == InnerDrawerAnimation .linear
605
- ? 0
606
- : null ,
592
+ width: _controller.value == 0 || _animationType == InnerDrawerAnimation .linear ? 0 : null ,
607
593
color: _colorTransitionChild.evaluate (_controller),
608
594
),
609
595
Align (
@@ -613,11 +599,10 @@ class InnerDrawerState extends State<InnerDrawer>
613
599
widthFactor: wFactor,
614
600
child: RepaintBoundary (child: _scaffold ())),
615
601
),
616
-
617
602
///Trigger
618
- _trigger (AlignmentDirectional .centerStart, _leftChild),
619
- _trigger (AlignmentDirectional .centerEnd, _rightChild),
620
- ].where ((a) => a != null ).toList () as List < Widget > ,
603
+ _trigger (AlignmentDirectional .centerStart, _leftChild) ?? Container () ,
604
+ _trigger (AlignmentDirectional .centerEnd, _rightChild) ?? Container () ,
605
+ ].where ((a) => a.runtimeType. toString (). toLowerCase () != 'container' ).toList (),
621
606
),
622
607
),
623
608
),
@@ -662,4 +647,4 @@ class IDOffset {
662
647
663
648
/// The offset from the bottom.
664
649
final double bottom;
665
- }
650
+ }
0 commit comments