@@ -15,6 +15,7 @@ class YYDialog {
1515 double height; //弹窗高度
1616 Duration duration = Duration (milliseconds: 250 ); //弹窗动画出现的时间
1717 Gravity gravity = Gravity .center; //弹窗出现的位置
18+ bool gravityAnimationEnable = false ; //弹窗出现的位置带有的默认动画是否可用
1819 Color barrierColor = Colors .black.withOpacity (.3 ); //弹窗外的背景色
1920 Color backgroundColor = Colors .white; //弹窗内的背景色
2021 double borderRadius = 0.0 ; //弹窗圆角
@@ -214,12 +215,19 @@ class YYDialog {
214215 );
215216 }
216217
217- void show () {
218+ /// x坐标
219+ /// y坐标
220+ void show ([x, y]) {
218221 var mainAxisAlignment = getColumnMainAxisAlignment (gravity);
219222 var crossAxisAlignment = getColumnCrossAxisAlignment (gravity);
220223 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+ }
221228 CustomDialog (
222229 gravity: gravity,
230+ gravityAnimationEnable: gravityAnimationEnable,
223231 context: context,
224232 barrierColor: barrierColor,
225233 animatedFunc: animatedFunc,
@@ -375,6 +383,7 @@ class CustomDialog {
375383 RouteTransitionsBuilder _transitionsBuilder;
376384 bool _barrierDismissible;
377385 Gravity _gravity;
386+ bool _gravityAnimationEnable;
378387 Function _animatedFunc;
379388
380389 CustomDialog ({
@@ -384,11 +393,13 @@ class CustomDialog {
384393 Color barrierColor,
385394 RouteTransitionsBuilder transitionsBuilder,
386395 Gravity gravity,
396+ bool gravityAnimationEnable,
387397 Function animatedFunc,
388398 bool barrierDismissible,
389399 }) : _child = child,
390400 _context = context,
391401 _gravity = gravity,
402+ _gravityAnimationEnable = gravityAnimationEnable,
392403 _duration = duration,
393404 _barrierColor = barrierColor,
394405 _animatedFunc = animatedFunc,
@@ -467,10 +478,19 @@ class CustomDialog {
467478 break ;
468479 }
469480
481+ //自定义动画
470482 if (_animatedFunc != null ) {
471483 return _animatedFunc (child, animation);
472484 }
473485
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+
474494 return SlideTransition (
475495 position: custom,
476496 child: child,
0 commit comments