i try to request camera permission on real iphone to scan qr code using qr_code_scanner
but the popup doesn't open i add NSCameraUsageDescription
in info.plist
and added in my podfile
this
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
target.build_configurations.each do |config|
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
'$(inherited)',
'PERMISSION_CAMERA=0',
'PERMISSION_PHOTOS=0',
'PERMISSION_MEDIA_LIBRARY=0',
]
end
end
end
and this my code for ask
i try this
getCamera() async {
var status = await Permission.camera.status;
if (!status.isGranted) {
final result = await Permission.camera.request();
if (result.isGranted) {
setState(() {
getPerm = true;
});
}
} else {
setState(() {
getPerm = true;
});
}
}
and this
void initState() {
super.initState();
WidgetsBinding.instance.addPostFrameCallback(onLayoutDone);
}
void onLayoutDone(Duration timeStamp) async {
_permissionStatus = await Permission.camera.status;
if (_permissionStatus.isGranted) {
setState(() {
getPerm = true;
});
}
}
void _askCameraPermission() async {
await Permission.camera.request();
if (await Permission.camera.request().isGranted) {
_permissionStatus = await Permission.camera.status;
setState(() {
getPerm = true;
});
}
}
and call _askCameraPermission function on pressed in button
nothing of this ways is working with me and all Permission other than camera working
question from:
https://stackoverflow.com/questions/65838026/flutter-popup-is-not-coming-to-ask-permission-to-access-camera 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…