-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Description
I am using webview_flutter: ^0.3.15+1 for in-app browser in flutter here and want to open this URL check here which have a camera but it's not opening as expected nor camera is loaded on that webpage
Code for webView Page :
import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:webview_flutter/webview_flutter.dart';
import 'dart:async';
class ExamWebView extends StatefulWidget {
final PageController controller;
final int destination;
const ExamWebView({Key key, this.controller, Key index, this.destination})
: super(key: key);
@override
_ExamWebViewState createState() => _ExamWebViewState();
}
class _ExamWebViewState extends State<ExamWebView> {
Completer<WebViewController> _controller = Completer<WebViewController>();
JavascriptChannel _toasterJavascriptChannel(BuildContext context) {
return JavascriptChannel(
name: '_Toaster',
onMessageReceived: (JavascriptMessage message) {
Scaffold.of(context).showSnackBar(
SnackBar(content: Text(message.message)),
);
});
}
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Center(
child: Text("Exam"),
),
),
body: Column(
children: <Widget>[
Expanded(
child: WebView(
initialUrl:
"https://therealtechwiz.github.io/project/facerecognition",
gestureRecognizers: Set()
..add(
Factory<VerticalDragGestureRecognizer>(
() => VerticalDragGestureRecognizer(),
),
),
// Factory<VerticalDragGestureRecognizer>(
// () => VerticalDragGestureRecognizer()..onUpdate = (_) {},
// ),
initialMediaPlaybackPolicy: AutoMediaPlaybackPolicy
.require_user_action_for_all_media_types,
javascriptMode: JavascriptMode.unrestricted,
onWebViewCreated: (WebViewController webViewController) {
_controller.complete(webViewController);
},
javascriptChannels: <JavascriptChannel>[
_toasterJavascriptChannel(context),
].toSet(),
),
)
],
));
}
}Added these Permissions in android/app/src/main/AndroidManifest.xml
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<uses-permission android:name="android.permission.INTERNET"/>
response in terminal:
D/EgretLoader(23485): EgretLoader(Context context)
D/EgretLoader(23485): The context is not activity
W/ContentCatcher(23485): Failed to notify a WebView
I/chromium(23485): [INFO:CONSOLE(79)] "[object DOMException] please use the fiddle instead", source: https://therealtechwiz.github.io/project/facerecognition/script.js (79)
I/chromium(23485): [INFO:CONSOLE(1)] "Uncaught (in promise) Error: failed to fetch: (404) , from url: https://therealtechwiz.github.io/models/face_recognition_model-weights_manifest.json", source: https://therealtechwiz.github.io/project/facerecognition/face-api.min.js (1)
W/Choreographer(23485): Frame time is 0.077364 ms in the future! Check that graphics HAL is generating vsync timestamps using the correct timebase.
Getting this output :
output Expected: can be seen here
flutter doctor -v output:
`[√] Flutter (Channel stable, 2.0.2, on Microsoft Windows [Version 10.0.18363.1440], locale en-US)
• Flutter version 2.0.2 at C:\flutter
• Framework revision 8962f6d (3 days ago), 2021-03-11 13:22:20 -0800
• Engine revision 5d8bf81
• Dart version 2.12.1
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
• Android SDK at C:\Users\Tarun jain\AppData\Local\Android\sdk
• Platform android-30, build-tools 30.0.3
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
• All Android licenses accepted.
[√] Chrome - develop for the web
• Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe
[√] Android Studio (version 4.1.0)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin can be installed from:
https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
[√] VS Code (version 1.54.2)
• VS Code at C:\Users\Tarun jain\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.20.0
[√] Connected device (3 available)
• Redmi Note 9 Pro (mobile) • e8e60b33 • android-arm64 • Android 11 (API 30)
• Chrome (web) • chrome • web-javascript • Google Chrome 89.0.4389.82
• Edge (web) • edge • web-javascript • Microsoft Edge 89.0.774.50
• No issues found!`

