clovisnicolas / flutter_lamp

Lamp plugin for flutter
MIT License
28 stars 30 forks source link

camera permission not working for flashlight , Have to restart app to make it work for flashlight using lamp 0.0.6 plugin #9

Open Shavneet opened 5 years ago

Shavneet commented 5 years ago

I am using this code :

getCameraPermissionStatus() async { var get = ''; List permissions = await Permission.getPermissionsStatus( [PermissionName.Camera,]); permissions.forEach((permission) { get += '${permission.permissionName}: ${permission.permissionStatus}'; if (get != "PermissionName.Camera: PermissionStatus.allow") { requestCameraPermission(); } else { Lamp.turnOn(); } }); }

requestCameraPermission() async { final res = await Permission.requestPermissions([PermissionName.Camera,]); res.forEach((permission) { String a = '${permission.permissionStatus}'; setState(() { if (a == 'PermissionStatus.allow') { Lamp.turnOn(); } else { Permission.openSettings; } }); }); }

So with this code I am successfully turning On the camera permission but ''Lamp.turnOn()'' is not turning on the flash in first attempt . Has to restart the app to turn it on . Permission gets turned on in first attempt (can be checked in app info ) but starts working after killing app and restarting app .

Packages I am using : permission: ^0.1.1 lamp: ^0.0.6 .

Please help if anyone knows anything about this or any other ideas will be appreciated . Thanks .