简体   繁体   English

如何将图像变量从一个屏幕发送回另一个屏幕 - Flutter

[英]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.我是 flutter 的新手,我目前正在做一个内部使用相机的项目。这个屏幕有两个图像变量,需要从相机接收图像并轻松存储它们。 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 .我看到您正在将小部件Image.file(File(imagePath))传递给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> .因此,在这种情况下,使用Navigator.push打开相机屏幕的代码,您可以将Navigator.push的返回值分配给某个变量,因为返回类型是Future<T>

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

Flutter has no concept of different screens. Flutter没有不同屏的概念。 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.在 direct Provider、Riverpod、Bloc 和 GetX 之间,有各种不同的 state 管理解决方案,允许您在页面级别上存储信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 "将图像从一个屏幕传递到另一个屏幕 - Flutter" - Passing image from one screen to another - Flutter 将数据从一个屏幕发送到另一屏幕抖动 - send data from one screen to another screen flutter 在 flutter 中将图像从一个屏幕传递到另一个屏幕 - Passing image from one screen to another screen in flutter 从 flutter 中的另一个屏幕返回时如何调用方法? - How to call a method when navigating back from another screen in flutter? 如何在FLutter中使用pushNamed将数据从一个屏幕传递到另一个屏幕? - how to pass data from one screen to another screen with pushNamed in FLutter? 如何:将 flutter 屏幕从一个 flutter 应用程序添加到另一个应用程序? - How To: Add flutter screen from one flutter app to another? 如何将数据从一个 flutter 应用程序发送到另一个 flutter 应用程序 - How to send data from one flutter app to another flutter app 如何将一个小部件的值发送到同一屏幕上的另一个小部件? (扑) - how to send a value from a widget to another on the same screen ? (flutter) 如何将列表中的文本字段数据发送到 flutter 中的另一个屏幕 - How to send text fields data from list to another screen in flutter 如何在不按动颤动的情况下从一个屏幕导航到另一个屏幕? - How to navigate from one screen to another without onpressed in flutter?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM