2022-04-25 20:36:21 +00:00
|
|
|
import 'dart:async';
|
|
|
|
import 'package:flutter/services.dart';
|
2023-11-27 11:09:17 +00:00
|
|
|
import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart';
|
2022-04-25 20:36:21 +00:00
|
|
|
|
|
|
|
import 'dart:js' as js;
|
|
|
|
|
|
|
|
import 'web_platform_manager.dart';
|
|
|
|
|
2023-11-11 12:18:02 +00:00
|
|
|
class PlatformUtil extends ChannelController {
|
2022-04-25 20:36:21 +00:00
|
|
|
late BinaryMessenger _messenger;
|
|
|
|
|
|
|
|
PlatformUtil({required BinaryMessenger messenger}) {
|
|
|
|
this._messenger = messenger;
|
2022-04-25 21:21:26 +00:00
|
|
|
|
2023-11-11 12:18:02 +00:00
|
|
|
channel = MethodChannel(
|
2022-04-25 20:36:21 +00:00
|
|
|
'com.pichillilorenzo/flutter_inappwebview_platformutil',
|
|
|
|
const StandardMethodCodec(),
|
|
|
|
_messenger,
|
|
|
|
);
|
2023-11-11 12:18:02 +00:00
|
|
|
handler = _handleMethod;
|
|
|
|
initMethodCallHandler();
|
2022-04-25 20:36:21 +00:00
|
|
|
}
|
|
|
|
|
2023-11-11 12:18:02 +00:00
|
|
|
Future<dynamic> _handleMethod(MethodCall call) async {
|
2022-04-25 20:36:21 +00:00
|
|
|
switch (call.method) {
|
|
|
|
case "getWebCookieExpirationDate":
|
|
|
|
int timestamp = call.arguments['date'];
|
|
|
|
return getWebCookieExpirationDate(timestamp);
|
|
|
|
default:
|
|
|
|
throw PlatformException(
|
|
|
|
code: 'Unimplemented',
|
2022-04-25 21:21:26 +00:00
|
|
|
details:
|
|
|
|
'flutter_inappwebview for web doesn\'t implement \'${call.method}\'',
|
2022-04-25 20:36:21 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
String getWebCookieExpirationDate(int timestamp) {
|
2022-04-25 21:21:26 +00:00
|
|
|
var bridgeJsObject = js.JsObject.fromBrowserObject(
|
|
|
|
js.context[WebPlatformManager.BRIDGE_JS_OBJECT_NAME]);
|
2022-04-25 20:36:21 +00:00
|
|
|
return bridgeJsObject.callMethod("getCookieExpirationDate", [timestamp]);
|
|
|
|
}
|
|
|
|
|
2022-05-13 07:35:50 +00:00
|
|
|
@override
|
2022-04-25 20:36:21 +00:00
|
|
|
void dispose() {
|
2023-11-11 12:18:02 +00:00
|
|
|
disposeChannel();
|
2022-04-25 20:36:21 +00:00
|
|
|
}
|
2022-04-25 21:21:26 +00:00
|
|
|
}
|