PPP
PPP

Reputation: 1870

How to call this.superClassMethod on Kotlin?

I have the following code:

class MainActivity: FlutterActivity() {
    companion object {
        private val STREAM: String = "com.example.my_app/stream";

        private lateinit var EVENT_CHANNEL: EventChannel
        init {

            EVENT_CHANNEL = EventChannel(this.getFlutterEngine().getDartExecutor().getBinaryMessenger(), STREAM)
            

but I get Unresolved reference: getFlutterEngine, but the method exists: https://api.flutter.dev/javadoc/io/flutter/embedding/android/FlutterActivity.html#getFlutterEngine()

I also tried [email protected]() and [email protected](). I think the problem is that things are inside the Companion object.

How to call getFlutterEngine?

Upvotes: 0

Views: 61

Answers (1)

Pemassi
Pemassi

Reputation: 642

this is Pointing MainActivity.companion, not MainActivity, since you're calling inside of companion object

Seems like you are trying to achieve to make EVENT_CAHNNEL that can access from anywhere. You might need to think to change design.

Upvotes: 1

Related Questions