showPopView function
void
showPopView({})
Implementation
void showPopView({
required BuildContext context,
Widget? widget,
double? top,
double? left,
double? right,
double width = 100,
double? height,
Color backgroundColor = Colors.white,
required Color barrierColor,
bool hiddenArrow = false,
bool barrierDismissible = true,
}) {
RenderBox renderBox = context.findRenderObject() as RenderBox;
Rect position = renderBox.localToGlobal(Offset.zero) & renderBox.size;
if (top == null) {
top = position.bottom;
}
if ((left == null && right == null)) {
left = position.left - renderBox.size.width;
}
_buildMenusView() {
return Material(
type: MaterialType.transparency,
child: Stack(
children: [
Positioned(
top: top,
left: left,
right: right,
child: Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: <Widget>[
if (!hiddenArrow)
Container(
padding: EdgeInsets.only(right: 10),
child: TriangleUpWidget(height: 10, width: 14,color:backgroundColor),
),
ClipRRect(
borderRadius: BorderRadius.circular(5),
child: Container(
color: backgroundColor,
width: width,
height: height,
child: widget,
))
],
),
),
],
),
);
}
int animalType = -1;
showGeneralDialog(
barrierDismissible: barrierDismissible,
barrierLabel: 'menus',
barrierColor: barrierColor,
context: context,
transitionDuration: Duration(milliseconds: 200),
transitionBuilder: (BuildContext c, Animation<double> animation,
Animation<double> secondaryAnimation, Widget child) {
if (animalType == 0) {
return FadeTransition(
opacity: Tween(begin: 0.0, end: 1.0).animate(CurvedAnimation(
parent: animation,
curve: Curves.fastOutSlowIn,
)),
child: child,
);
} else if (animalType == 1) {
return ScaleTransition(
scale: Tween(
begin: 0.0,
end: 1.0,
).animate(
CurvedAnimation(parent: animation, curve: Curves.fastOutSlowIn),
),
child: child,
);
} else if (animalType == 2) {
return RotationTransition(
turns: Tween(
begin: 0.0,
end: 1.0,
).animate(
CurvedAnimation(
parent: animation,
curve: Curves.fastOutSlowIn,
),
),
child: child,
);
} else if (animalType == 3) {
return SlideTransition(
position: Tween<Offset>(
begin: Offset(-1.0, 0.0),
end: Offset(0.0, 0.0),
).animate(
CurvedAnimation(
parent: animation,
curve: Curves.fastOutSlowIn,
),
),
child: child,
);
}
return SizeTransition(
sizeFactor: Tween<double>(begin: 0.1, end: 1.0).animate(
CurvedAnimation(
parent: animation,
curve: Curves.linear,
),
),
child: child,
);
},
pageBuilder: (BuildContext c, Animation<double> animation,
Animation<double> secondaryAnimation) {
return _buildMenusView();
},
);
}