Dependencies:
qr_flutter: ^4.0.0
Code:
// Automatic FlutterFlow imports
import '/backend/backend.dart';
import '/flutter_flow/flutter_flow_theme.dart';
import '/flutter_flow/flutter_flow_util.dart';
import '/custom_code/widgets/index.dart'; // Imports other custom widgets
import '/flutter_flow/custom_functions.dart'; // Imports custom functions
import 'package:flutter/material.dart';
// Begin custom widget code
// DO NOT REMOVE OR MODIFY THE CODE ABOVE!
import 'package:qr_flutter/qr_flutter.dart';
class QRCodeGenerator extends StatefulWidget {
const QRCodeGenerator({
Key? key,
this.width,
this.height,
required this.qrData,
this.qrSize,
this.gapLess,
this.qrVersion,
this.qrPadding,
this.qrBorderRadius,
this.semanticsLabel,
this.qrBackgroundColor,
this.qrForegroundColor,
}) : super(key: key);
final double? width;
final double? height;
final String qrData;
final double? qrSize;
final bool? gapLess;
final int? qrVersion;
final double? qrPadding;
final double? qrBorderRadius;
final String? semanticsLabel;
final Color? qrBackgroundColor;
final Color? qrForegroundColor;
@override
_QRCodeGeneratorState createState() => _QRCodeGeneratorState();
}
class _QRCodeGeneratorState extends State<QRCodeGenerator> {
@override
Widget build(BuildContext context) {
return Container(
width: widget.width,
height: widget.height,
padding: EdgeInsets.all(widget.qrPadding ?? 0),
child: QrImageView(
data: widget.qrData,
version: widget.qrVersion ?? QrVersions.auto,
size: widget.qrSize ?? 200,
gapless: widget.gapLess ?? true,
padding: EdgeInsets.all(widget.qrPadding ?? 0),
backgroundColor: widget.qrBackgroundColor ??
Colors.white, // Default value set to Colors.white
semanticsLabel: widget.semanticsLabel ?? 'QR code',
// Add other customization based on the documentation
),
);
}
}