fbpx
Lección 1 de 0
En Progreso

QR Flutter | Generando códigos QR dinamicamente

Jorge L. febrero 22, 2024

Nombre: Qr
Link: https://pub.dev/packages/qr_flutter
Dependencias: qr_flutter

Parámetros
data | String | Nullable
backgroundColor | Color | Nullable
foregroundColor | Color | Nullable
semanticsLabel | String | Nullable

Código

import 'package:qr_flutter/qr_flutter.dart';

class Qr extends StatefulWidget {
  const Qr({
    Key? key,
    this.width,
    this.height,
    this.data,
    this.size,
    this.backgroundColor,
    this.foregroundColor,
    this.semanticsLabel,
  }) : super(key: key);

  final double? width;
  final double? height;
  final String? data;
  final double? size;
  final Color? backgroundColor;
  final Color? foregroundColor;
  final String? semanticsLabel;

  @override
  _QrState createState() => _QrState();
}

class _QrState extends State<Qr> {
  @override
  Widget build(BuildContext context) {
    return Container(
      //height: widget.height,
      //width: widget.width,
      child: QrImage(
          version: QrVersions.auto,
          data: widget.data.toString(),
          size: widget.size,
          backgroundColor: widget.backgroundColor!,
          foregroundColor: widget.foregroundColor!,
          gapless: true,
          semanticsLabel: widget.semanticsLabel.toString()),
    );
  }
}

¿Cómo de útil te ha parecido esta clase?