Reputation: 490
Iam new to flutter,tried hello_services example provided by flutter.io . in that example both flutter view and native view are in same screen. My question is, how to navigate to two different screens like one written in flutter and another in native(android/ios) with params or extras.Please help !!!! thanks
Upvotes: 3
Views: 2878
Reputation: 5914
The only solution I found, it is to send a message to your native view (https://flutter.io/platform-services/), catch the message in Java or Swift/ObjectiveC code then navigate to the other view.
Dart Code
Map params = <String, dynamic>{
"view": "MyView"
};
PlatformMessages.sendJson("navigateTo", params);
Java Code
flutterView.addOnMessageListener("navigateTo", new FlutterView.OnMessageListener() {
@Override
public String onMessage(FlutterView view, String message) {
try {
JSONObject object = new JSONObject(message);
if (object.getString("view") == "MyView") {
// navigate to MyView
}
} catch (JSONException e) {
e.printStackTrace();
}
return null;
}
});
Upvotes: 4