I have a Flutter app that lunch a native activity that contains a form (first and last name fields), when I fill in the fields and click the finish button I want to get these data back to Flutter widget.
Basically, all what I did, was lunch the FormActivity, how can I get the form data from FormActivity and display them on my Flutter widget?
override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {
super.configureFlutterEngine(flutterEngine)
MethodChannel(flutterEngine.dartExecutor.binaryMessenger, CHANNEL).setMethodCallHandler {
call, result ->
if (call.method == "lunchActivity") {
val intent = Intent(this, FormActivity::class.java)
startActivity(intent)
}
}
}
CodePudding user response:
Use startActivityForResult to launch an activity, return a result from the activity with setResult, implement ActivityResultListener to handle the result and finally call success on a channel to return the result to Flutter side.
See details for Flutter - Android communication.