简体   繁体   中英

how to pass a variable value from one flutter page to another

suppose, I have a file body1.dart where I created a variable "hello" which was initially empty!

String hello = "";

Now, in the same file, I have created a loop which will set and update the value of hello after every iteration!

Now the thing is whenever the value of "hello" get changed, I want to display that inside a Text Field which is in a different file body2.dart. I want to retrieve the real-time value at that exact moment! (Not the final outcome at the end of the loop)

Can you provide code snippet for this? So that we can best assist you.

Otherwise the best option would be to use a stream. You can have multiple dart classes subscribed to the same stream.

Streams provide an asynchronous sequence of data. Data sequences include user-generated events and data read from files. You can process a stream using either await for or listen() from the Stream API

Checkout official documentation from dart.dev

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM