AndroidManifest.xml需要在 中添加以下权限:
<uses-permission android:name="android.permission.INTERNET"/><uses-permission android:name="android.permission.CAMERA"/><uses-permission android:name="android.permission.RECORD_AUDIO"/><uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/><uses-permission android:name="android.permission.VIDEO_CAPTURE"/><uses-permission android:name="android.permission.AUDIO_CAPTURE"/>
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
import 'package:permission_handler/permission_handler.dart';
Future main() async {
WidgetsFlutterBinding.ensureInitialized();
await Permission.camera.request();
await Permission.microphone.request();runApp(MyApp());}
class MyApp extends StatefulWidget {
@override
_MyAppState createState()=> new _MyAppState();}
class _MyAppState extends State<MyApp>{
@override
Widget build(BuildContext context){returnMaterialApp(
home:InAppWebViewPage());}}
class InAppWebViewPage extends StatefulWidget {
@override
_InAppWebViewPageState createState()=> new _InAppWebViewPageState();}
class _InAppWebViewPageState extends State<InAppWebViewPage>{
InAppWebViewController _webViewController;
@override
Widget build(BuildContext context){returnScaffold(
appBar:AppBar(
title:Text("InAppWebView")),
body:Container(
child:Column(children:<Widget>[Expanded(
child:Container(
child:InAppWebView(
initialUrlRequest:URLRequest(url: Uri.parse('url')),
initialOptions:InAppWebViewGroupOptions(
crossPlatform:InAppWebViewOptions(
mediaPlaybackRequiresUserGesture: false,
debuggingEnabled: true,),),
onWebViewCreated:(InAppWebViewController controller){
_webViewController = controller;},
androidOnPermissionRequest:(InAppWebViewController controller, String origin, List<String> resources) async {returnPermissionRequestResponse(resources: resources, action: PermissionRequestResponseAction.GRANT);//主要是这行代码是授权的}),),),])));}}
标签:
flutter
本文转载自: https://blog.csdn.net/weixin_44911775/article/details/134605161
版权归原作者 氤氲息 所有, 如有侵权,请联系我们删除。
版权归原作者 氤氲息 所有, 如有侵权,请联系我们删除。