From aad761dc3dd6fcd0db7e032da8115887c64c3452 Mon Sep 17 00:00:00 2001 From: Abdulraheem Ahmad Date: Wed, 9 Apr 2025 23:21:40 +0100 Subject: [PATCH] fixing kotlin reference isue --- .../kotlin/com/morbit/photogallery/PhotoGalleryPlugin.kt | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/android/src/main/kotlin/com/morbit/photogallery/PhotoGalleryPlugin.kt b/android/src/main/kotlin/com/morbit/photogallery/PhotoGalleryPlugin.kt index a6fee5f..c1baf68 100644 --- a/android/src/main/kotlin/com/morbit/photogallery/PhotoGalleryPlugin.kt +++ b/android/src/main/kotlin/com/morbit/photogallery/PhotoGalleryPlugin.kt @@ -19,7 +19,7 @@ import io.flutter.plugin.common.MethodCall import io.flutter.plugin.common.MethodChannel import io.flutter.plugin.common.MethodChannel.MethodCallHandler import io.flutter.plugin.common.MethodChannel.Result -import io.flutter.plugin.common.PluginRegistry.Registrar +//import io.flutter.plugin.common.PluginRegistry.Registrar import java.io.ByteArrayOutputStream import java.io.File import java.io.FileOutputStream @@ -40,11 +40,10 @@ class PhotoGalleryPlugin : FlutterPlugin, MethodCallHandler, ActivityAware { // depending on the user's project. onAttachedToEngine or registerWith must both be defined // in the same class. @JvmStatic - fun registerWith(registrar: Registrar) { + override fun onAttachedToEngine(flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) { + val channel = MethodChannel(flutterPluginBinding.binaryMessenger, "photo_gallery") val channel = MethodChannel(registrar.messenger(), "photo_gallery") - val plugin = PhotoGalleryPlugin() - plugin.context = registrar.activeContext() - channel.setMethodCallHandler(plugin) + channel.setMethodCallHandler(PhotoGalleryPlugin()) } const val imageType = "image"