update
This commit is contained in:
@@ -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"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user