Let's say I'm passing data between screens using default way with Navigator.pop:
@override
void selectUserAction(BuildContext context) async {
final result = await Navigator.of(context).push(
MaterialPageRoute(builder: (context) => SelectUserPage()));
final User selectedUser = result as UserModel;
}
Navigator.pop(context, selectedUser);
So everything goes well in that case.
And I know I can handle back button interaction (onPressed) using AppBar leading property like this:
leading: IconButton(
icon: BackButtonIcon(),
onPressed: () {
Navigator.pop(context, selectedUser);
},
),
But there are few options how we can return to the previous screen (back on android, swipe to go back on iOS and etc). Then what should we do to handle this?
I need to return data to the previous screen in any case.