有没有办法在 Flutter 中创建图像网格(用户添加的图像),并且网格中的每个新图像都添加到添加按钮之前?

问题描述 投票:0回答:0

我是 Flutter 的新手。我正在尝试实现一个带有可扩展图像网格(用户要添加的图像)的对话框,并且每次用户添加图像(使用添加/加号按钮)时,添加的图像都会在添加/加号按钮之前插入.

我想要实现的目标的图示: enter image description here

我希望我的问题/代码/图片有意义。提前致谢。

我目前不完整的代码:

List<Widget> getAttachFileDialogContent() {
    List<Widget> content = [];
    content.add(
      Column(
        children: [
          Container(
            decoration: BoxDecoration(
                borderRadius: BorderRadius.circular(20),
                border: Border.all(
                  color: purple1.withOpacity(0.25),
                )),
            margin: const EdgeInsets.only(left: 16, right: 16, bottom: 8),
            padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 20),
            width: double.infinity,
            height: 135,
            child: //I want to use the grid here,
                   //I tried to use GridView, but didn't know how to add/insert images
                   //Even if I had added images, I couldn't know how to add to specific index 
                     position
          ),

        MyElevatedButton(
                width: 100,
                text: 'Done',
                elevation: 0,
                onPressed: () {},
              ),
            ],
          ),
        ],
      ),
    );
    return content;
  }
flutter gridview insert grid add
© www.soinside.com 2019 - 2024. All rights reserved.