-1

I am doing a voting app and I have a problem, I want to stack images as many time there is votes(1 stack per vote). This is a picture of what I want to do. I tried to use Listview like this

ListView(
  children: <Widget>[
    Image(
      image: AssetImage('assets/images/results/green.png'),
    ),
    Image(
      image: AssetImage('assets/images/results/green.png'),
    ),
  ],
),

The problem is that there is so much space between the 2 images. Can you help me ?

enter image description here

Abion47
  • 22,211
  • 4
  • 65
  • 88
luc
  • 1,301
  • 2
  • 14
  • 30

1 Answers1

1

Try to wrap the image with:

Align(
  alignment: Alignment.topLeft,
  heightFactor: 0.94/*change this value until you are satisfied (between 0 and 1)*/,
  child: //your image
),
Edin
  • 758
  • 6
  • 18
  • Thank you it works ! Do you know how can I have one child per vote ? – luc Jan 21 '20 at 09:51
  • I dont understand what you mean can you describe it a little more please? – Edin Jan 21 '20 at 09:54
  • On the screen there are 6 "green plates", it is for 6 votes. I want to pass a number as argument and it will display the number of image I passed. Example: There is 5 vote so I want to add 5 images in Listview – luc Jan 21 '20 at 10:04
  • @LucaMathevet use `ListView.builder` – pskink Jan 21 '20 at 10:07
  • 1
    just use this: ListView.builder( itemCount: /*put the number of items here*/, itemBuilder: (BuildContext context,int index) { return: Align( alignment: Alignment.topLeft, heightFactor: 0.94/*change this value until you are satisfied (between 0 and 1)*/, child: //your image ); } ) – Edin Jan 21 '20 at 10:11