@@ -15,6 +15,7 @@ class YYDialog {
15
15
double height; //弹窗高度
16
16
Duration duration = Duration (milliseconds: 250 ); //弹窗动画出现的时间
17
17
Gravity gravity = Gravity .center; //弹窗出现的位置
18
+ bool gravityAnimationEnable = false ; //弹窗出现的位置带有的默认动画是否可用
18
19
Color barrierColor = Colors .black.withOpacity (.3 ); //弹窗外的背景色
19
20
Color backgroundColor = Colors .white; //弹窗内的背景色
20
21
double borderRadius = 0.0 ; //弹窗圆角
@@ -214,12 +215,19 @@ class YYDialog {
214
215
);
215
216
}
216
217
217
- void show () {
218
+ /// x坐标
219
+ /// y坐标
220
+ void show ([x, y]) {
218
221
var mainAxisAlignment = getColumnMainAxisAlignment (gravity);
219
222
var crossAxisAlignment = getColumnCrossAxisAlignment (gravity);
220
223
Size size = MediaQuery .of (context).size;
224
+ if (x != null && y != null ) {
225
+ gravity = Gravity .leftTop;
226
+ margin = EdgeInsets .only (left: x, top: y);
227
+ }
221
228
CustomDialog (
222
229
gravity: gravity,
230
+ gravityAnimationEnable: gravityAnimationEnable,
223
231
context: context,
224
232
barrierColor: barrierColor,
225
233
animatedFunc: animatedFunc,
@@ -375,6 +383,7 @@ class CustomDialog {
375
383
RouteTransitionsBuilder _transitionsBuilder;
376
384
bool _barrierDismissible;
377
385
Gravity _gravity;
386
+ bool _gravityAnimationEnable;
378
387
Function _animatedFunc;
379
388
380
389
CustomDialog ({
@@ -384,11 +393,13 @@ class CustomDialog {
384
393
Color barrierColor,
385
394
RouteTransitionsBuilder transitionsBuilder,
386
395
Gravity gravity,
396
+ bool gravityAnimationEnable,
387
397
Function animatedFunc,
388
398
bool barrierDismissible,
389
399
}) : _child = child,
390
400
_context = context,
391
401
_gravity = gravity,
402
+ _gravityAnimationEnable = gravityAnimationEnable,
392
403
_duration = duration,
393
404
_barrierColor = barrierColor,
394
405
_animatedFunc = animatedFunc,
@@ -467,10 +478,19 @@ class CustomDialog {
467
478
break ;
468
479
}
469
480
481
+ //自定义动画
470
482
if (_animatedFunc != null ) {
471
483
return _animatedFunc (child, animation);
472
484
}
473
485
486
+ //不需要默认动画
487
+ if (! _gravityAnimationEnable) {
488
+ custom = Tween <Offset >(
489
+ begin: Offset (0.0 , 0.0 ),
490
+ end: Offset (0.0 , 0.0 ),
491
+ ).animate (animation);
492
+ }
493
+
474
494
return SlideTransition (
475
495
position: custom,
476
496
child: child,
0 commit comments