简体   繁体   中英

How to send back an image variable from one screen to another - Flutter

I am new to flutter and I am currently working on a project that uses cameras internally.This screen has two image variables that need to receive an image from the camera and store them easily. Right now the camera screen is closed like this:

onPressed: ()=> Navigator.pop(context,Image.file(File(imagePath)))

How do I change the Image variables from the previous screen?

I see you are passing a widget Image.file(File(imagePath)) to result parameter of Navigator.pop . So in this case, the code where you open the camera screen using Navigator.push , you can assign the return value of Navigator.push to some variable because the return type is Future<T> .

final imgWidget = await Navigator.push<Image>(...)

Flutter has no concept of different screens. Everything is Widgets and you have a Widget tree. Between straight Provider, Riverpod, Bloc and GetX there are a variety of different state management solutions that allow you to store information over the level of pages.

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