Last active
December 14, 2019 11:46
-
-
Save vishna/5f42dd5df670b61c0898500512d4b175 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import io.flutter.embedding.android.FlutterActivity // there are two FlutterActivities :| | |
import io.flutter.plugins.GeneratedPluginRegistrant // this is not seen by IntelliJ by works ¯\_(ツ)_/¯ | |
typealias FlutterCallback = (methodCall: MethodCall, result: MethodChannel.Result) -> Unit | |
class FlutterPathActivity : FlutterActivity() { | |
override fun configureFlutterEngine(flutterEngine: FlutterEngine) { | |
infix fun String.handles(callHandler: FlutterCallback) { | |
MethodChannel(flutterEngine.dartExecutor, this).setMethodCallHandler(callHandler) | |
} | |
GeneratedPluginRegistrant.registerWith(flutterEngine) // is this handled by default, I guess no? | |
val initialPath = intent.getStringExtra(ConstantsBase.KEY_FLUTTER_PATH) // avoid initalRoute | |
navChannel handles navCallback(initialPath) | |
} | |
} | |
private const val navChannel = "com.eyeem.app/nav" | |
private fun navCallback(initialPath: String): FlutterCallback { | |
return { methodCall, result -> | |
when (methodCall.method) { | |
"getInitialPath" -> result.success(initialPath) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment