user2570135
user2570135

Reputation: 2989

Flutter How do I display a list in flutter --2 item per row

I have a list in flutter that contain 5 item

{"i1","i2","i3","i4","i5")

and I would like to display it in rows of 2 items

How can I do this in Flutter

I have it displaying 1 line per item

 pw.Container(
              padding: const EdgeInsets.symmetric(horizontal: 16.0),
              child: pw.Column(
                children: <Widget>[
                  for (var skill in skillsList) ...[
                    pw.SizedBox(height: 5.0),
                    pw.Row(
                      children: <Widget>[
                        pw.Container(
                          width: 2.0,
                          height: 2.0,
                          decoration: BoxDecoration(
                            shape: pw.BoxShape.circle,
                            color: PdfColor.fromInt(Colors.black.value),
                          ),
                        ),
                        pw.SizedBox(width: 4.0),
                        makeTextField("$skill", size: 11.0),
                      ],
                    )
                  ]
                ],
              ),
            ),

This is what I wanted

*i1 *i2

*i2 *i4

*i5

Upvotes: 3

Views: 4090

Answers (2)

Mohamed Hammane
Mohamed Hammane

Reputation: 151

You can use something like this :

GridView.count(
    crossAxisCount: 2,
    childAspectRatio: (1 / .35),
    shrinkWrap: true,
    scrollDirection: Axis.vertical,
    children: List.generate(5,(i){
        return Text("hi");
    })
)

Upvotes: 0

srikanth7785
srikanth7785

Reputation: 1512

You can do something like this..

GridView.count(
  crossAxisCount: 2,
  children: List.generate(5,(i){
     return Text("hi");
   })
)

Upvotes: 4

Related Questions