Update code for ask permission if not set (force ios)
This commit is contained in:
parent
72ce2a47f3
commit
823620c13a
@ -26,22 +26,6 @@ class _ScannerDialogState extends State<ScannerDialog> {
|
|||||||
QRViewController? controller;
|
QRViewController? controller;
|
||||||
final GlobalKey qrKey = GlobalKey(debugLabel: 'QR');
|
final GlobalKey qrKey = GlobalKey(debugLabel: 'QR');
|
||||||
|
|
||||||
@override
|
|
||||||
Future<void> initState() async {
|
|
||||||
super.initState();
|
|
||||||
|
|
||||||
var status = await Permission.camera.status;
|
|
||||||
|
|
||||||
if(!status.isGranted) {
|
|
||||||
// You can request multiple permissions at once.
|
|
||||||
Map<Permission, PermissionStatus> statuses = await [
|
|
||||||
Permission.camera,
|
|
||||||
].request();
|
|
||||||
print(statuses[Permission.camera]);
|
|
||||||
print(status);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// In order to get hot reload to work we need to pause the camera if the platform
|
// In order to get hot reload to work we need to pause the camera if the platform
|
||||||
// is android, or resume the camera if the platform is iOS.
|
// is android, or resume the camera if the platform is iOS.
|
||||||
@override
|
@override
|
||||||
@ -56,6 +40,7 @@ class _ScannerDialogState extends State<ScannerDialog> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
Size size = MediaQuery.of(context).size;
|
Size size = MediaQuery.of(context).size;
|
||||||
|
|
||||||
return Container(
|
return Container(
|
||||||
height: size.height *0.5,
|
height: size.height *0.5,
|
||||||
width: size.width *0.9,
|
width: size.width *0.9,
|
||||||
@ -203,9 +188,7 @@ class _ScannerDialogState extends State<ScannerDialog> {
|
|||||||
Future<void> _onPermissionSet(BuildContext context, QRViewController ctrl, bool p) async {
|
Future<void> _onPermissionSet(BuildContext context, QRViewController ctrl, bool p) async {
|
||||||
//log('${DateTime.now().toIso8601String()}_onPermissionSet $p');
|
//log('${DateTime.now().toIso8601String()}_onPermissionSet $p');
|
||||||
if (!p) {
|
if (!p) {
|
||||||
|
|
||||||
var status = await Permission.camera.status;
|
var status = await Permission.camera.status;
|
||||||
|
|
||||||
if(!status.isGranted) {
|
if(!status.isGranted) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
const SnackBar(content: Text('no Permission')),
|
const SnackBar(content: Text('no Permission')),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user