DEV Community

Discussion on: Sharing data between ViewModels in Compose

Collapse
 
rafa_b8907973ce09a8a0e663 profile image
Rafa

If you know how to navigate back from Screen2 to Screen1 and send data back. I.e.: in screen two the user types a text and once it presses system's back button, it navigates back to screen one and that text he typed earlier has to appear now in a textfield in screen1.

Thread Thread
 
mardsoul profile image
Aleksei Laptev • Edited

You can use BackHandler, it overrides system back button. Here you are an example with navigation with arguments.
As I mentioned in the article it's not the best practice, but like a variant... Better try another approach.