Flutter local_auth platform exception requires activity to be a fragmentactivity flutter

Viewed 48

I am using the plugin local_auth to let users authenticate by their fingerprint, now I know that there are some changes that need to be done on 'mainActivity.kt' so the plugin gets working without the error local_auth plugin requires activity to be a fragmentactivity flutter

but the problem is I am using google_ads plugin too and I am registering native ads with it that using the context inside the class FlutterActivity so I can't change it to FlutterFragmentActivity or I am getting Unresolved reference: context

package app.masarifi

import io.flutter.embedding.android.FlutterFragmentActivity
import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.engine.FlutterEngine
import io.flutter.plugins.GeneratedPluginRegistrant
import io.flutter.plugins.googlemobileads.GoogleMobileAdsPlugin


class MainActivity: FlutterActivity() {
    override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
        super.configureFlutterEngine(flutterEngine)
//        GeneratedPluginRegistrant.registerWith(flutterEngine)
//
        GoogleMobileAdsPlugin.registerNativeAdFactory(
                flutterEngine, "listTile", ListTileNativeAdFactory(context))

        GoogleMobileAdsPlugin.registerNativeAdFactory(
                flutterEngine, "mediumAd", MediumNativeAdFactory(context))

    }

    override fun cleanUpFlutterEngine(flutterEngine: FlutterEngine) {
        super.cleanUpFlutterEngine(flutterEngine)

        GoogleMobileAdsPlugin.unregisterNativeAdFactory(flutterEngine, "listTile")
        GoogleMobileAdsPlugin.unregisterNativeAdFactory(flutterEngine, "mediumAd")
    }

}
0 Answers
Related