I am partially new to Flutter. I am trying to achieve a Dialog which carries an expandable grid of images (images to be added by the user), and every time the user adds an image (using the add/plus button) the added image inserts before the add/plus button.
A pictorial representation of what I want to achieve:
enter image description here
I hope my question/code/image make sense. Thanks in advance.
My current incomplete code:
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;
}
2
Answers
You can use GridView from flutter. for more: https://docs.flutter.dev/cookbook/lists/grid-lists.
or If you want any examples. please visit Medium.com and search for what you want. You can find more informations posted by experienced devs. For example:
https://medium.com/flutter-community/flutter-widgets-grid-view-the-whole-picture-34d2dd6dff9f
If I understand what you want, it’s a bit similar to what I’m doing, except that instead of putting the images in a GrindView I’m putting them in a carousel . In this example I’m editing an ad for a Virtual Store. The part of images to be added in a temporary list before pressing the ADD button. which has not yet been implemented. But I think this might help you.
I hope I understood and was able to help you.