I'm learning how to use dart.I created a simple application that scans the qrCodes, and displays the text. My question is: How do I open the text as a link? Since the url is displayed to me as text.
Currently the application works without errors, but I would like to create a tap to open the links in the browser. This is my main.dart
void main() {
runApp(MaterialApp(home: MyApp()));
}
class MyApp extends StatefulWidget{
@override
State<StatefulWidget> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
GlobalKey qrKey =GlobalKey();
var qrText = "";
QRViewController controller;
@override
Widget build(BuildContext context) {
// TODO: implement build
return Scaffold(body: Column(children: [
Expanded(
flex:5,
child: QRView(key: qrKey,
overlay: QrScannerOverlayShape(
borderRadius:10,
borderColor: Colors.red,
borderLength: 30,
borderWidth: 10,
cutOutSize:300
),
onQRViewCreated: _onQRViewCreate,)
),
Expanded(
flex: 1,
child: Center(
child: Text('Scan result: $qrText'),
),
)
],
),
);
}
@override
void dispose() {
controller?.dispose();
super.dispose();
}
void _onQRViewCreate(QRViewController controller ) {
this.controller = controller;
controller.scannedDataStream.listen((scanData) {
setState(() {
qrText = scanData;
});
});
}
}