Skip to content

Instantly share code, notes, and snippets.

@Frankdroid7
Last active November 17, 2021 12:08
Show Gist options
  • Save Frankdroid7/90ad3f3c19893eaff6bf6c2238730d8d to your computer and use it in GitHub Desktop.
Save Frankdroid7/90ad3f3c19893eaff6bf6c2238730d8d to your computer and use it in GitHub Desktop.
import 'package:flutter/material.dart';
import 'package:qr_flutter/qr_flutter.dart';
import 'package:screenshot/screenshot.dart';
class QRCodePlayground extends StatefulWidget {
@override
_QRCodePlaygroundState createState() => _QRCodePlaygroundState();
}
class _QRCodePlaygroundState extends State<QRCodePlayground> {
ScreenshotController screenshotController = ScreenshotController();
final TextEditingController tfController = TextEditingController();
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: ListView(
children: [
tfController.text.isEmpty
? SizedBox.shrink()
: Screenshot(
controller: screenshotController,
child: QrImage(data: tfController.text)),
SizedBox(height: 20),
TextField(
controller: tfController,
decoration: InputDecoration(
border: OutlineInputBorder(
borderSide: BorderSide(color: Colors.blue))),
),
SizedBox(height: 20),
RaisedButton(
color: Colors.blue,
textColor: Colors.white,
child: Text('Generate QR Code'),
onPressed: () => setState(() {}),
padding: EdgeInsets.symmetric(vertical: 12),
),
RaisedButton(
onPressed: () {},
color: Colors.blue,
textColor: Colors.white,
child: Text('Share QR code'),
padding: EdgeInsets.symmetric(vertical: 12),
),
],
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment