import 'package:flutter/material.dart';
import 'package:qr_flutter/qr_flutter.dart' as qr;

/// 二维码显示组件（避免和 flutter_inappwebview 包内同名类型冲突）
class QrImageView extends StatelessWidget {
  final String data;
  final double size;
  final Color? backgroundColor;

  const QrImageView({
    super.key,
    required this.data,
    this.size = 200,
    this.backgroundColor,
  });

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: const EdgeInsets.all(8),
      decoration: BoxDecoration(
        color: backgroundColor ?? Colors.white,
        borderRadius: BorderRadius.circular(8),
      ),
      child: qr.QrImageView(
        data: data,
        version: qr.QrVersions.auto,
        size: size,
      ),
    );
  }
}
