How to dynamic list on Card in flutter?

2,019

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

Share:
2,019
Shruti Ramnandan Sharma
Author by

Shruti Ramnandan Sharma

I'm an Indian developer for building mobile applications with flutter. linkedin-profile

Updated on December 21, 2022

Comments

  • Shruti Ramnandan Sharma
    Shruti Ramnandan Sharma over 1 year

    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.

  • Shruti Ramnandan Sharma
    Shruti Ramnandan Sharma almost 4 years
    Oh nice, but one more thing that want to say, these cards are also as dynamic list. can you please set the cards in listviewBuilder.
  • Ketan Ramteke
    Ketan Ramteke almost 4 years
    Are you saying all the data shown in list should be in Card widget?
  • Shruti Ramnandan Sharma
    Shruti Ramnandan Sharma almost 4 years
    No, I mean, this is one card that you have built & that is perfect but, want to no of same cards in listview.
  • Shruti Ramnandan Sharma
    Shruti Ramnandan Sharma almost 4 years
    In simple word, wrap this card in ListView.Builder()
  • Ketan Ramteke
    Ketan Ramteke almost 4 years
  • Shruti Ramnandan Sharma
    Shruti Ramnandan Sharma almost 4 years
    Sure, But first i'll check.By the way thank you so much
  • Ketan Ramteke
    Ketan Ramteke almost 4 years
    Welcome. Happy Coding.
  • Ketan Ramteke
    Ketan Ramteke almost 4 years