|
14 | 14 |
|
15 | 15 | package com.example.webcrypto
|
16 | 16 |
|
17 |
| -import androidx.annotation.NonNull; |
| 17 | +import androidx.annotation.NonNull |
18 | 18 |
|
19 | 19 | import io.flutter.embedding.engine.plugins.FlutterPlugin
|
20 | 20 | import io.flutter.plugin.common.MethodCall
|
21 | 21 | import io.flutter.plugin.common.MethodChannel
|
22 | 22 | import io.flutter.plugin.common.MethodChannel.MethodCallHandler
|
23 | 23 | import io.flutter.plugin.common.MethodChannel.Result
|
24 |
| -import io.flutter.plugin.common.PluginRegistry.Registrar |
25 | 24 |
|
26 | 25 | /** WebcryptoPlugin */
|
27 |
| -public class WebcryptoPlugin: FlutterPlugin, MethodCallHandler { |
| 26 | +class WebcryptoPlugin: FlutterPlugin, MethodCallHandler { |
28 | 27 | /// The MethodChannel that will the communication between Flutter and native Android
|
29 | 28 | ///
|
30 | 29 | /// This local reference serves to register the plugin with the Flutter Engine and unregister it
|
31 | 30 | /// when the Flutter Engine is detached from the Activity
|
32 | 31 | private lateinit var channel : MethodChannel
|
33 | 32 |
|
34 | 33 | override fun onAttachedToEngine(@NonNull flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) {
|
35 |
| - channel = MethodChannel(flutterPluginBinding.getFlutterEngine().getDartExecutor(), "webcrypto") |
36 |
| - channel.setMethodCallHandler(this); |
37 |
| - } |
38 |
| - |
39 |
| - // This static function is optional and equivalent to onAttachedToEngine. It supports the old |
40 |
| - // pre-Flutter-1.12 Android projects. You are encouraged to continue supporting |
41 |
| - // plugin registration via this function while apps migrate to use the new Android APIs |
42 |
| - // post-flutter-1.12 via https://flutter.dev/go/android-project-migration. |
43 |
| - // |
44 |
| - // It is encouraged to share logic between onAttachedToEngine and registerWith to keep |
45 |
| - // them functionally equivalent. Only one of onAttachedToEngine or registerWith will be called |
46 |
| - // depending on the user's project. onAttachedToEngine or registerWith must both be defined |
47 |
| - // in the same class. |
48 |
| - companion object { |
49 |
| - @JvmStatic |
50 |
| - fun registerWith(registrar: Registrar) { |
51 |
| - val channel = MethodChannel(registrar.messenger(), "webcrypto") |
52 |
| - channel.setMethodCallHandler(WebcryptoPlugin()) |
53 |
| - } |
| 34 | + channel = MethodChannel(flutterPluginBinding.binaryMessenger, "webcrypto") |
| 35 | + channel.setMethodCallHandler(this) |
54 | 36 | }
|
55 | 37 |
|
56 | 38 | override fun onMethodCall(@NonNull call: MethodCall, @NonNull result: Result) {
|
|
0 commit comments