-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #53 from Maruti54/main
QR Code Scanner
- Loading branch information
Showing
8 changed files
with
276 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"v":"5.6.6","ip":0,"op":80,"fr":60,"w":28,"h":28,"layers":[{"ind":17588,"nm":"surface73409","ao":0,"ip":0,"op":80,"st":0,"ty":4,"ks":{"ty":"tr","o":{"k":100},"r":{"k":0},"p":{"a":0,"k":[0,0,0],"ix":2},"a":{"k":[0,0]},"s":{"k":[133.33,133.33]},"sk":{"k":0},"sa":{"k":0}},"shapes":[{"ty":"gr","hd":false,"nm":"surface73409","it":[{"ty":"gr","hd":false,"it":[{"ty":"sh","ks":{"k":{"i":[[0,0],[0,0],[0.11,0.06],[0.12,-0.03],[-0.05,-0.25],[0,0],[0,0],[-0.21,0],[0,0.25],[0.01,0.04]],"o":[[0,0],[-0.03,-0.12],[-0.1,-0.06],[-0.25,0.06],[0,0],[0,0],[0.04,0.21],[0.25,0],[0,-0.04],[0,0]],"v":[[7.57,3.38],[6.95,0.75],[6.74,0.47],[6.4,0.42],[6.06,0.97],[6.68,3.59],[6.68,3.59],[7.12,3.95],[7.58,3.49],[7.57,3.38]],"c":true}}},{"ty":"fl","o":{"k":100},"c":{"k":[0,0,0,1]}},{"ty":"tr","o":{"k":100},"r":{"k":0},"p":{"k":[0,0]},"a":{"k":[0,0]},"s":{"k":[100,100]},"sk":{"k":0},"sa":{"k":0},"hd":false}]},{"ty":"gr","hd":false,"it":[{"ty":"sh","ks":{"k":{"i":[[0,0],[0.1,-0.06],[0.03,-0.12],[0,0],[-0.25,-0.06],[-0.06,0.25],[0,0],[0,0],[0.25,0.06]],"o":[[-0.12,-0.03],[-0.1,0.07],[0,0],[-0.06,0.25],[0.25,0.06],[0,0],[0,0],[0.05,-0.25],[0,0]],"v":[[14.6,0.42],[14.26,0.47],[14.05,0.76],[13.43,3.38],[13.77,3.93],[14.32,3.59],[14.94,0.97],[14.94,0.97],[14.6,0.42]],"c":true}}},{"ty":"fl","o":{"k":100},"c":{"k":[0,0,0,1]}},{"ty":"tr","o":{"k":100},"r":{"k":0},"p":{"k":[0,0]},"a":{"k":[0,0]},"s":{"k":[100,100]},"sk":{"k":0},"sa":{"k":0},"hd":false}]},{"ty":"gr","hd":false,"it":[{"ty":"sh","ks":{"k":{"i":[[0,0],[0,-0.25],[0,0],[-0.25,0],[0,0.25],[0,0],[0.09,0.09],[0.12,0]],"o":[[-0.25,0],[0,0],[0,0.25],[0.25,0],[0,0],[0,-0.12],[-0.09,-0.09],[0,0]],"v":[[10.5,0],[10.04,0.46],[10.04,3.46],[10.5,3.91],[10.96,3.46],[10.96,0.46],[10.82,0.13],[10.5,0]],"c":true}}},{"ty":"fl","o":{"k":100},"c":{"k":[0,0,0,1]}},{"ty":"tr","o":{"k":100},"r":{"k":0},"p":{"k":[0,0]},"a":{"k":[0,0]},"s":{"k":[100,100]},"sk":{"k":0},"sa":{"k":0},"hd":false}]},{"ty":"gr","hd":false,"it":[{"ty":"sh","ks":{"k":{"i":[[0,0],[0.01,0.06],[0,0],[0.08,0.09],[0.12,0],[0,0],[0.01,-0.25],[0,0],[-0.06,-0.08],[0,0],[0,0],[-0.86,0],[0,0],[-0.01,0.86],[0,0],[0,0],[-0.08,0.09],[0,0.12],[0,0],[0.24,0.01],[0,0],[0,0]],"o":[[0.01,-0.06],[0,0],[0.01,-0.12],[-0.08,-0.09],[0,0],[-0.25,0],[0,0],[0,0.11],[0,0],[0,0],[0.01,0.86],[0,0],[0.86,0],[0,0],[0,0],[0.12,0],[0.08,-0.09],[0,0],[0.01,-0.24],[0,0],[0,0],[0,0]],"v":[[14.8,8.4],[14.8,8.21],[14.8,5.73],[14.69,5.4],[14.37,5.25],[6.61,5.25],[6.14,5.71],[6.14,8.25],[6.24,8.54],[7.79,11.86],[7.79,19.45],[9.37,21],[11.62,21],[13.19,19.45],[13.19,16.09],[13.76,16.09],[14.08,15.95],[14.2,15.63],[14.2,13.88],[13.79,13.43],[13.19,13.43],[13.19,11.82]],"c":true}}},{"ty":"sh","ks":{"k":{"i":[[0,0],[0,0],[0,0],[0,0]],"o":[[0,0],[0,0],[0,0],[0,0]],"v":[[7.07,6.19],[13.89,6.19],[13.89,7.75],[7.07,7.75]],"c":true}}},{"ty":"sh","ks":{"k":{"i":[[0,0],[0.35,0],[0,0],[0.01,0.35],[0,0],[0,0]],"o":[[-0.01,0.35],[0,0],[-0.36,0],[0,0],[0,0],[0,0]],"v":[[12.32,19.45],[11.66,20.09],[9.41,20.09],[8.76,19.45],[8.76,18.8],[12.33,18.8]],"c":true}}},{"ty":"sh","ks":{"k":{"i":[[0,0],[0,0],[0,0],[0,0]],"o":[[0,0],[0,0],[0,0],[0,0]],"v":[[13.33,14.36],[13.33,15.18],[13.24,15.18],[13.24,14.36]],"c":true}}},{"ty":"sh","ks":{"k":{"i":[[0,0],[0,-0.07],[0,0],[0,0],[0,0],[0.02,0.07],[0,0],[0,0]],"o":[[-0.03,0.07],[0,0],[0,0],[0,0],[0.02,-0.07],[0,0],[0,0],[0,0]],"v":[[12.35,11.52],[12.32,11.72],[12.32,17.88],[8.71,17.88],[8.71,11.72],[8.71,11.52],[7.38,8.67],[13.7,8.67]],"c":true}}},{"ty":"fl","o":{"k":100},"c":{"k":[0,0,0,1]}},{"ty":"tr","o":{"k":100},"r":{"k":0},"p":{"k":[0,0]},"a":{"k":[0,0]},"s":{"k":[100,100]},"sk":{"k":0},"sa":{"k":0},"hd":false}]},{"ty":"tr","o":{"k":100},"r":{"k":0},"p":{"k":[0,0]},"a":{"k":[0,0]},"s":{"k":[100,100]},"sk":{"k":0},"sa":{"k":0},"hd":false}]},{"ty":"tm","s":{"a":0,"k":0,"ix":1},"e":{"a":1,"k":[{"i":{"x":[0.35],"y":[1]},"o":{"x":[0.17],"y":[0.17]},"t":0,"s":[25]},{"t":55,"s":[100]}],"ix":2},"o":{"a":0,"k":0,"ix":3},"m":1,"ix":2,"nm":"Trim Paths 1","mn":"ADBE Vector Filter - Trim","hd":false}]}],"meta":{"g":"LF SVG to Lottie"}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
131 changes: 131 additions & 0 deletions
131
projects/ev_stations/lib/screens/users/ev_charging_stations.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,132 @@ | ||
// ev_charging_stations | ||
import 'package:flutter/foundation.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:qr_code_scanner/qr_code_scanner.dart'; | ||
import 'package:url_launcher/url_launcher.dart'; | ||
import 'package:lottie/lottie.dart'; | ||
import 'package:torch_light/torch_light.dart'; | ||
|
||
class Scanner extends StatefulWidget { | ||
const Scanner({Key? key}) : super(key: key); | ||
|
||
@override | ||
_ScannerState createState() => _ScannerState(); | ||
} | ||
|
||
class _ScannerState extends State<Scanner> { | ||
final GlobalKey qrKey = GlobalKey(debugLabel: 'QR'); | ||
late QRViewController controller; | ||
|
||
@override | ||
void dispose() { | ||
controller.dispose(); | ||
super.dispose(); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Stack( | ||
children: [ | ||
QRView( | ||
key: qrKey, | ||
onQRViewCreated: _onQRViewCreated, | ||
), | ||
Column( | ||
mainAxisAlignment: MainAxisAlignment.center, | ||
children: [ | ||
Center( | ||
child: Container( | ||
width: 300, | ||
height: 300, | ||
decoration: BoxDecoration( | ||
border: Border.all( | ||
color: Colors.red, | ||
width: 4, | ||
), | ||
borderRadius: BorderRadius.circular(12), | ||
), | ||
), | ||
), | ||
const SizedBox( | ||
height: 100, | ||
), | ||
ElevatedButton( | ||
child: CircleAvatar( | ||
backgroundColor: Colors.transparent, | ||
child: LottieBuilder.asset('assets/lottie/torch.json'), | ||
), | ||
onPressed: () { | ||
_turnOnFlash(context); | ||
}) | ||
], | ||
), | ||
], | ||
); | ||
} | ||
|
||
void _onQRViewCreated(QRViewController controller) { | ||
this.controller = controller; | ||
controller.scannedDataStream.listen((scanData) async { | ||
controller.pauseCamera(); | ||
if (await canLaunchUrl(Uri.parse((scanData.code)!))) { | ||
await launchUrl(Uri.parse((scanData.code)!)); | ||
controller.resumeCamera(); | ||
} else { | ||
showDialog( | ||
context: context, | ||
builder: (BuildContext context) { | ||
return AlertDialog( | ||
title: const Text('Url'), | ||
content: SingleChildScrollView( | ||
child: ListBody( | ||
children: <Widget>[ | ||
Text('Barcode Type: ${describeEnum(scanData.format)}'), | ||
Text('Data: ${scanData.code}'), | ||
], | ||
), | ||
), | ||
actions: <Widget>[ | ||
TextButton( | ||
child: const Text('Ok'), | ||
onPressed: () { | ||
Navigator.of(context).pop(); | ||
_launchInBrowser(Uri.parse((scanData.code)!)); | ||
}, | ||
), | ||
], | ||
); | ||
}, | ||
).then((value) => controller.resumeCamera()); | ||
} | ||
}); | ||
} | ||
} | ||
|
||
Future<void> _launchInBrowser(Uri url) async { | ||
if (!await launchUrl( | ||
url, | ||
mode: LaunchMode.externalApplication, | ||
)) { | ||
throw 'Could not launch $url'; | ||
} | ||
} | ||
|
||
Future<void> _turnOnFlash(BuildContext context) async { | ||
try { | ||
await TorchLight.enableTorch(); | ||
} on Exception catch (_) { | ||
_showErrorMes('Could not enable Flashlight', context); | ||
} | ||
} | ||
|
||
Future<void> _turnOffFlash(BuildContext context) async { | ||
try { | ||
await TorchLight.disableTorch(); | ||
} on Exception catch (_) { | ||
_showErrorMes('Could not enable Flashlight', context); | ||
} | ||
} | ||
|
||
void _showErrorMes(String mes, BuildContext context) { | ||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(mes))); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.