在元素之间发送图像

2024-04-01

我正在向我的PhotoPreviewScreen一旦照片在我这里拍摄camera通过此按钮页面:

onPressed: () async {
                var result = await controller.takePicture();
                Navigator.push(
                    context,
                    MaterialPageRoute(
                        builder: (context) => PhotoPreviewScreen(
                              imagePath: result.path,

但是,我希望能够将其从我的网格视图发送到我的主页PhotoPreview Screen单击此按钮后:

OutlineButton(
          onPressed: () async {
            var result = widget.imagePath;
            Navigator.push(
                context,
                MaterialPageRoute(
                    builder: (context) => PhotoPreviewScreen(
                          imagePath: result.path,

然而,这并不成功。我试图定义这些元素PhotoPreview Screen通过这些项目

class _PhotoPreviewScreenState extends State<PhotoPreviewScreen> {
  var image;
  String imgPath;

  Future _openGallery() async {
    if (widget.setData != null) {
      widget.setData(File(image.path));
    }
  }

我哪里出错了,如何重构这段代码? 总而言之,流程是:

  1. 将拍摄的照片发送至PhotoPreviewScreen(完全的)
  2. 拍摄照片开启PhotoPreviewScreen(完全的)
  3. 将照片发送至GridView on my Homepage单击上面指定的按钮后(需要指导)

这里是GridView我需要在单击按钮时将图像发送到它

: GridView.count(
                          shrinkWrap: true,
                          crossAxisCount: 2,
                          crossAxisSpacing: 25,
                          mainAxisSpacing: 25,
                          childAspectRatio: (80 / 150),
                          padding: const EdgeInsets.all(2.0),
                          children:
                              List.generate(widget.imageArray.length, (index) {
                            return Container(
                              decoration: new BoxDecoration(
                                color: const Color(0xff000000),
                                borderRadius: BorderRadius.circular(10),
                                image: new DecorationImage(
                                  image: FileImage(widget.imageArray[index]),
                                  fit: BoxFit.fill,
                                  colorFilter: new ColorFilter.mode(
                                      Colors.black.withOpacity(0.4),
                                      BlendMode.dstATop)

除了上述内容之外,这里还有相关的主页:

class Homepage extends StatefulWidget {
  final List<File> imageArray;
  Homepage({Key key, this.imageArray}) : super(key: key);

  @override
  _HomepageState createState() => _HomepageState();
}

class _HomepageState extends State<Homepage> {
  var image;

None

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

在元素之间发送图像 的相关文章

随机推荐