Last active
March 1, 2023 10:16
-
-
Save pichillilorenzo/6608a42e28d9aea5447cd66a1c697965 to your computer and use it in GitHub Desktop.
InAppWebView - WebRTC on Android
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { | |
return MaterialApp( | |
home: InAppWebViewPage() | |
); | |
} | |
} | |
class InAppWebViewPage extends StatefulWidget { | |
@override | |
_InAppWebViewPageState createState() => new _InAppWebViewPageState(); | |
} | |
class _InAppWebViewPageState extends State<InAppWebViewPage> { | |
InAppWebViewController _webViewController; | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar( | |
title: Text("InAppWebView") | |
), | |
body: Container( | |
child: Column(children: <Widget>[ | |
Expanded( | |
child: Container( | |
child: InAppWebView( | |
initialUrl: "https://appr.tc/r/704328056", | |
initialOptions: InAppWebViewGroupOptions( | |
crossPlatform: InAppWebViewOptions( | |
mediaPlaybackRequiresUserGesture: false, | |
debuggingEnabled: true, | |
), | |
), | |
onWebViewCreated: (InAppWebViewController controller) { | |
_webViewController = controller; | |
}, | |
androidOnPermissionRequest: (InAppWebViewController controller, String origin, List<String> resources) async { | |
return PermissionRequestResponse(resources: resources, action: PermissionRequestResponseAction.GRANT); | |
} | |
), | |
), | |
), | |
])) | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
sir, can u tell me where is import 'package:permission_handler/permission_handler.dart';