【发布时间】:2020-12-13 19:49:46
【问题描述】:
我正在尝试制作一个 qrCode 生成器,但由于页面太大,我无法正确完成。有人可以帮我吗?................................................ ..................................................... ..................................................... ..................................................... ..........
import 'package:flutter/material.dart';
import 'package:parse_server_sdk_flutter/parse_server_sdk.dart';
import 'package:qr_flutter/qr_flutter.dart';
class Generate extends StatefulWidget {
@override
_GenerateState createState() => _GenerateState();
}
class _GenerateState extends State<Generate> {
String qrData = "SHS HTW App";
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('QrCode Generate'),
),
body: Container(
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
Container(
child: Padding(
padding: const EdgeInsets.fromLTRB(80, 10, 10, 180),
child: QrImage(
//place where the qr image will be shown
data: qrData,
size: 200,
),
),
),
SizedBox(
height: 40.0,
),
Text("get your data/ linked to the QR Code"),
TextField(
//place where we enter the text od data
controller: qrText,
decoration: InputDecoration(
hintText: "Enter the data/Link",
),
),
Padding(
padding: const EdgeInsets.fromLTRB(40, 20, 40, 0),
child: FlatButton(
padding: EdgeInsets.all(15.0),
child: Text("generate qr code"),
//what should ahppen when we press the button
onPressed: () {
if (qrText.text.isEmpty) {
setState(() {
qrData = "";
});
} else {
qrData = qrText.text;
}
},
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20.0),
side: BorderSide(color: Colors.green, width: 3.0)),
),
),
],
),
),
),
);
}
final qrText = TextEditingController();
}
【问题讨论】: