从相机/图库中选择图像后如何将图像从一个屏幕传递到另一个屏幕并在导航到第二个屏幕时自动显示在第二个屏幕中

时间:2021-04-20 07:48:33

标签: iphone flutter logic coding-style

如何在从相机或图库中选择图像后将图像从一个屏幕传递到另一个屏幕,并在我导航到第二个屏幕时自动显示在第二个屏幕中。基本上,我想要一个在第二个屏幕中的方法,当我从相机或图库中选择图像并导航到第二个屏幕时,该方法会自动运行。 这是从图库中选择图像并导航到第二个屏幕的代码

Future<void> predictImagePickerGallery(BuildContext context) async {
    final navigator = Navigator.of(context);
    var image = await ImagePicker.pickImage(source: ImageSource.gallery);
    if (image == null) return;
    setState(() {
      _busy = true;
      _image = image;
    });
    if (image != null) {
      print(image.path);
      await navigator.push(
        MaterialPageRoute(
          builder: (context) =>
              Test2(
                  _image
              ),
        ),
      );

    }
    Navigator.of(context).pop();
   // recognizeImage(image);
  }

现在如何在导航时自动在第二个屏幕中显示此图像。

0 个答案:

没有答案