Shruti Ramnandan Sharma
Shruti Ramnandan Sharma

Reputation: 4555

How to dynamic list on Card in flutter?

How to show dynamic list on card widget like below image?

enter image description here

This dynamic list, want to show :

enter image description here

The piece of code:

Card(
  elevation: 5,
  child: Padding(
   padding: const EdgeInsets.only(top:8.0, left: 8,right:8),
    child: Column(
      mainAxisAlignment: MainAxisAlignment.start,
      crossAxisAlignment: CrossAxisAlignment.start,
      children: <Widget>[
       ......

         Flexible(
            child: ListView.builder(
              shrinkWrap: true,
              itemCount: sample.length,
              itemBuilder: (context, index){
                return Column(
                  mainAxisAlignment: MainAxisAlignment.start,
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: <Widget>[
                    //data
                    ......
                   Divider(color: Colors.black,),
                  ],
                );
              }
             ),
          )

      ],
    ),
  )
)

but showing blank with exception.

Upvotes: 2

Views: 3160

Answers (2)

Ketan Ramteke
Ketan Ramteke

Reputation: 10665

Code is a bit long so here is the GitHub repository:

https://github.com/TheKetan2/stackoverflow_answers/blob/master/lib/card_list_example.dart

Output:

enter image description here

Upvotes: 2

Yugene
Yugene

Reputation: 3232

With your example shows, I think the only problem is crossAxisAlignment.

Please have a test with CrossAxisAlignment.stretch.

Or please post your whole code or exception to find the exact cause.

Upvotes: 0

Related Questions