37 lines
1.5 KiB
Kotlin
37 lines
1.5 KiB
Kotlin
package com.apskel.enaklocustomer
|
|
|
|
import android.os.Build
|
|
import io.flutter.embedding.android.FlutterActivity
|
|
import io.flutter.embedding.engine.FlutterEngine
|
|
import io.flutter.plugin.common.MethodChannel
|
|
import io.flutter.plugins.webviewflutter.WebViewFlutterAndroidExternalApi
|
|
|
|
class MainActivity : FlutterActivity() {
|
|
override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
|
|
super.configureFlutterEngine(flutterEngine)
|
|
|
|
// Pengaturan WebView yang tidak disediakan plugin webview_flutter.
|
|
MethodChannel(flutterEngine.dartExecutor.binaryMessenger, WEBVIEW_CHANNEL)
|
|
.setMethodCallHandler { call, result ->
|
|
when (call.method) {
|
|
"enableOffscreenPreRaster" -> {
|
|
val id = call.argument<Number>("webViewId")?.toLong()
|
|
@Suppress("DEPRECATION")
|
|
val webView = id?.let {
|
|
WebViewFlutterAndroidExternalApi.getWebView(flutterEngine, it)
|
|
}
|
|
if (webView != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
|
webView.settings.offscreenPreRaster = true
|
|
}
|
|
result.success(webView != null)
|
|
}
|
|
else -> result.notImplemented()
|
|
}
|
|
}
|
|
}
|
|
|
|
private companion object {
|
|
const val WEBVIEW_CHANNEL = "com.apskel.enaklocustomer/webview"
|
|
}
|
|
}
|