I have a strange problem and I can't figure out what's causing it. My application has a screen with a webview using the flutter_inappwebview package. In the future, I will need access to the camera and gallery to select photos.
For the camera, I request permission via permission_handler and it works fine, but when I try to pick photos from the gallery, the application crashes with the error java.lang.IllegalArgumentException: Couldn't find meta-data for provider with authority com.example.webapp.flutter_inappwebview.fileprovider
.
Code:
`class _WebViewPageState extends State<WebViewPage> {
late final InAppWebViewController _webViewController;
Future<bool> _onGoBack() async {
if (await _webViewController.canGoBack()) {
_webViewController.goBack();
}
return false;
}
Future<void> _permissionsRequest() async {
await [
Permission.camera,
Permission.storage,
].request();
}
@override
void initState() {
super.initState();
_permissionsRequest();
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: WillPopScope(
onWillPop: _onGoBack,
child: InAppWebView(
onWebViewCreated: (controller) {
_webViewController = controller;
},
initialUrlRequest: URLRequest(
url: Uri.parse(widget.mainWebViewLink),
),
initialOptions: InAppWebViewGroupOptions(
crossPlatform: InAppWebViewOptions(
useShouldOverrideUrlLoading: true,
javaScriptCanOpenWindowsAutomatically: true,
mediaPlaybackRequiresUserGesture: false,
),
),
androidOnPermissionRequest: (_, origin, resources) async {
return PermissionRequestResponse(
resources: resources,
action: PermissionRequestResponseAction.GRANT,
);
},
),
),
),
);
}
}`
I tried adding a fileprovider in the manifest, but that didn't work either :(. It is noteworthy that if you do not give access to the camera, the gallery opens and everything works, only in this case the camera does not work.