Home > Mobile >  QRCode Generator
QRCode Generator

Time:07-14

In my flutter application I wanted to generate QR code that have the current time and user ID as data.Whenever I click on the button new QR code should be generated based on the time. This is my code for my qr

QrImage(
   data: tdata   userId,
   size: 250,
),

this is the code for my button

Button(
  onPressed: () {
  },
  label: const Text(
    'Generate',
  ),
),

CodePudding user response:

I have used this package preview

Edit Create an int

int maxAttempt = 10;

On each button tap decrease this value

maxAttempt--;
setState((){});

Now on button click setState only if maxAttempt > 0 or you can also add condition in widget

(maxAttempt> 0) ? QrImage(): Text("max attempts reached")
  • Related