Files
enaklo-flutter/android/app/src/main/kotlin/com/apskel/enaklocustomer/MainActivity.kt
T

37 lines
1.5 KiB
Kotlin
Raw Normal View History

2026-10-01 10:48:25 +07:00
package com.apskel.enaklocustomer
2025-08-27 12:17:23 +07:00
import android.os.Build
2025-08-27 12:17:23 +07:00
import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.engine.FlutterEngine
import io.flutter.plugin.common.MethodChannel
import io.flutter.plugins.webviewflutter.WebViewFlutterAndroidExternalApi
2025-08-27 12:17:23 +07:00
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 {
2026-10-01 10:48:25 +07:00
const val WEBVIEW_CHANNEL = "com.apskel.enaklocustomer/webview"
}
}