import 'package:flutter/material.dart'; import '../widgets/cheer_reward_widget.dart'; import '../widgets/star_reward_widget.dart'; void showStarRewardDialog(BuildContext context, { double width = 200, double height = 200, int starCount = 3, }) { showDialog( context: context, barrierDismissible: false, // 点击对话框外部不关闭对话框 builder: (BuildContext context) { return Dialog( backgroundColor: Colors.transparent, // 设置对话框背景为透明 insetPadding: const EdgeInsets.all(0), // 去除对话框的内边距 child: StarRewardWidget( width: width, height: height, isPlaying: true, starCount: starCount, onAnimationEnd: () { Navigator.of(context).pop(); // 关闭对话框 }, ), ); }, ); } void showCheerRewardDialog(BuildContext context, { required String lottieFile, double width = 200, double height = 200, }) { showDialog( context: context, barrierDismissible: false, // 点击对话框外部不关闭对话框 builder: (BuildContext context) { return Dialog( backgroundColor: Colors.transparent, // 设置对话框背景为透明 insetPadding: const EdgeInsets.all(0), // 去除对话框的内边距 child: CheerRewardWidget( lottieFile: lottieFile, width: width, height: height, isPlaying: true, onAnimationEnd: () { Navigator.of(context).pop(); // 关闭对话框 }, ), ); }, ); }