Updated 27 April 2023
If you have worked on Android applications before then you must be aware that there is a function as startActivityForResult, which starts an activity and that activity returns a result to the previous activity.
Check more about our Flutter app development.
In this blog, we will see how we can achieve this in Flutter
1 |
await Navigator.pushNamed(context, secondWidgetRoute); |
1 |
Navigator.pop(context, result); |
1 |
var results = await Navigator.pushNamed(context, secondWidgetRoute); |
1 2 3 |
if (results != null) { // you code goes here } |
Remember to keep the await function inside an async function. It will only in this condition.
1 2 3 4 5 6 |
_startSecondWidget() async { var results = await Navigator.pushNamed(context, secondWidgeteRoute); if (results != null) { // You code goes here. } } |
You can easily achieve the functionality of startActivityForResult just like the native Android.
That’s all for this blog. Thank you very much. This is Vedesh Kumar signing off.
If you have more details or questions, you can reply to the received confirmation email.
Back to Home
Be the first to comment.