This commit is contained in:
efrilm
2026-10-01 10:48:25 +07:00
parent 5a8b020256
commit 8f0a5d3fb5
12 changed files with 877 additions and 21 deletions
@@ -0,0 +1,36 @@
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"
}
}