customer_service_qr_dialog.dart 1.6 KB
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

Future<void> showCustomerServiceQrDialog(
  BuildContext context,
  String imageUrl,
) {
  return showDialog<void>(
    context: context,
    barrierColor: Colors.black54,
    barrierDismissible: true,
    builder: (context) => Dialog(
      backgroundColor: Colors.transparent,
      insetPadding: EdgeInsets.symmetric(horizontal: 24.w, vertical: 10.h),
      child: ClipRRect(
        borderRadius: BorderRadius.circular(12.r),
        child: SizedBox(
          height: 340.h,
          child: AspectRatio(
            aspectRatio: 870 / 1110,
            child: Image.network(
              imageUrl,
              width: double.infinity,
              height: double.infinity,
              fit: BoxFit.cover,
              loadingBuilder: (context, child, progress) {
                if (progress == null) {
                  return child;
                }
                return Container(
                  color: Colors.white,
                  alignment: Alignment.center,
                  child: const CircularProgressIndicator(),
                );
              },
              errorBuilder: (context, error, stackTrace) => Container(
                color: Colors.white,
                alignment: Alignment.center,
                child: Text(
                  '图片加载失败',
                  style: TextStyle(
                    color: Colors.grey[600],
                    fontSize: 14.sp,
                  ),
                ),
              ),
            ),
          ),
        ),
      ),
    ),
  );
}