show_star_reward_dialog.dart 813 Bytes
import 'package:flutter/material.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(); // 关闭对话框
          },
        ),
      );
    },
  );
}