You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
108 lines
3.3 KiB
Dart
108 lines
3.3 KiB
Dart
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
|
|
|
|
class VideoCallWebPage extends StatelessWidget{
|
|
final GlobalKey webViewKey = GlobalKey();
|
|
|
|
InAppWebViewController webViewController;
|
|
InAppWebViewController controller;
|
|
|
|
URLRequest request;
|
|
final String receiverId;
|
|
final String callerId;
|
|
VideoCallWebPage({@required this.receiverId, @required this.callerId}){
|
|
request = URLRequest(url: Uri.parse("https://vcallapi.hmg.com/index.html?username=$receiverId"));
|
|
}
|
|
|
|
InAppWebViewGroupOptions options = InAppWebViewGroupOptions(
|
|
crossPlatform: InAppWebViewOptions(
|
|
cacheEnabled: false,
|
|
clearCache: true,
|
|
disableHorizontalScroll: true,
|
|
disableVerticalScroll: true,
|
|
disableContextMenu: true,
|
|
supportZoom: false,
|
|
javaScriptEnabled: true,
|
|
preferredContentMode: UserPreferredContentMode.MOBILE,
|
|
useShouldOverrideUrlLoading: true,
|
|
mediaPlaybackRequiresUserGesture: false,
|
|
|
|
),
|
|
android: AndroidInAppWebViewOptions(
|
|
hardwareAcceleration: true,
|
|
useHybridComposition: true,
|
|
),
|
|
ios: IOSInAppWebViewOptions(
|
|
allowsAirPlayForMediaPlayback: true,
|
|
allowsPictureInPictureMediaPlayback: true,
|
|
allowsInlineMediaPlayback: true,
|
|
)
|
|
);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
primary: true,
|
|
appBar: AppBar(
|
|
backgroundColor: Colors.transparent, leading: Container(),
|
|
systemOverlayStyle: SystemUiOverlayStyle(statusBarColor: Colors.black),
|
|
),
|
|
extendBodyBehindAppBar: true,
|
|
extendBody: false,
|
|
backgroundColor: Colors.white,
|
|
body: Column(
|
|
children: [
|
|
SizedBox(height: MediaQuery.of(context).viewPadding.top),
|
|
Expanded(
|
|
child: InAppWebView(
|
|
androidOnPermissionRequest: androidOnPermissionRequest,
|
|
initialOptions: options,
|
|
initialUrlRequest: request,
|
|
onWebViewCreated: onWebViewCreated,
|
|
onLoadStart: onLoadStart,
|
|
onLoadError: onError,
|
|
onConsoleMessage: onConsoleMessage,
|
|
shouldOverrideUrlLoading: shouldRedirect ,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
|
|
ChromeSafariBrowser();
|
|
}
|
|
|
|
|
|
Future<PermissionRequestResponse> androidOnPermissionRequest(InAppWebViewController controller, String origin, List<String> resources) async {
|
|
return PermissionRequestResponse(
|
|
resources: resources,
|
|
action: PermissionRequestResponseAction.GRANT
|
|
);
|
|
}
|
|
|
|
onWebViewCreated(InAppWebViewController controller) => this.controller = controller;
|
|
|
|
onConsoleMessage(controller, ConsoleMessage consoleMessage){
|
|
print(consoleMessage);
|
|
}
|
|
|
|
onError(InAppWebViewController controller, Uri url, int code, String message) {
|
|
|
|
}
|
|
|
|
onLoadStart(InAppWebViewController controller, Uri url) {
|
|
}
|
|
|
|
Future<NavigationActionPolicy> shouldRedirect(InAppWebViewController controller, NavigationAction navigationAction) async {
|
|
var uri = navigationAction.request.url;
|
|
if(uri.queryParameters['exit'] == "yes"){
|
|
Navigator.pop(webViewKey.currentContext);
|
|
}
|
|
|
|
return NavigationActionPolicy.ALLOW;
|
|
}
|
|
|
|
|
|
} |