Flutter_blue error when permission denied

Viewed 596

I use package Flutter_blue, it asks permission for bluetooth at start and crashes app when permission denied. How can I stop app from crashing? I want it to work even when user denies bluetooth access and for example show screen saying 'give access to bluetooth'

1 Answers

It should actually not ask for permission referring the following from the permission_handler package, according to them:

Some permissions will not show a dialog asking the user to allow or deny the requested permission. This is because the OS setting(s) of the app are being retrieved for the corresponding permission. The status of the setting will determine whether the permission is granted or denied.

The following permissions will show no dialog: Notification, Bluetooth

Well, you can do ask for permission if not granted on iOS though with permission_handler, for more information checkout the permission_handler package (more specifically Bluetooth constant)

Just make sure to add those permissions in the AndroidManifest & Info.plist specified in the flutter_blue package docs.

Just a little disclaimer, for the concept regarding requesting permission on android, I might be wrong. Please correct me if wrong.

Related