Issue
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?
Solution
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.
Answered By - Pemassi
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.