如何通过构造函数在 flutter 中将数据传递到 Card 列表?我已经尝试过这些东西,结果和想要的是附加的

How to Pass Data to Card list in flutter through constructor ? I have Tried these things, result and want is attached

如何实现这种格式?我真的很困惑如何在 flutter 中做?

这是我目前取得的结果enter image description here。

这就是我真正想要的 enter image description here ,我可以在其中添加任意数量的值,但采用卡片视图格式。

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: ListView.builder(
          shrinkWrap: true,
          itemBuilder: (BuildContext context,int index) => Container(
            width: MediaQuery.of(context).size.width,
            padding: EdgeInsets.symmetric(horizontal: 10.0,vertical: 5.0),
            child: Card(
              elevation: 5.0,
              shape: RoundedRectangleBorder(
                borderRadius: BorderRadius.circular(0.0),
              ),
              child: Container(
                width: MediaQuery.of(context).size.width,
                padding: EdgeInsets.symmetric(horizontal: 10.0,vertical: 10.0),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: <Widget>[
                    Row(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: <Widget>[
                        Container(
                          width: 55.0,
                          height: 55.0,
                          child: CircleAvatar(
                          backgroundColor: Colors.green,
                            foregroundColor: Colors.red,
                            backgroundImage: NetworkImage("https://thechive.com/wp-content/uploads/2018/09/4a0dd2313a49cba8381ee0ba33008514.jpg?quality=85&strip=info&w=650"),
                          ),
                          ),
                        SizedBox(width: 10.0,),
                        customGroupText("abc", "10/10/2010"),
                      ],
                    ),
                    Container(
                      alignment: Alignment.center,
                      padding: EdgeInsets.symmetric(horizontal: 10.0,vertical: 10.0),
                      child: FlatButton(
                        onPressed: (){},
                        color: Colors.amber,
                        shape: RoundedRectangleBorder (
                          borderRadius: BorderRadius.circular(20.0),
                        ),
                        child: Text(
                          "Join Now", style: TextStyle(color: Colors.white),
                        ),
                      ),
                    ),
                  ],
                ),
              ),
            ),
          )
      ),
    );
  }
}

这是 class 我将创建构造函数的地方。

class customGroupText extends StatelessWidget {
  String names;
  String datess;
  customGroupText(this.names,this.datess);
  @override
  Widget build(BuildContext context) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: <Widget>[
        Text(
            names,
            style: TextStyle(color: Colors.black, fontSize: 18.0, fontWeight: FontWeight.bold)),
        Text(
            datess,
            style: TextStyle(color: Colors.grey,)),
      ],
    );
  }
}

这很容易通过 tile

Card(
  child: ListTile(
    leading: Icon(Icons.android),
    title: Text('My title'),
    subtitle: Text('my sub title'),
    trailing: IconButton(
      icon: Icon(Icons.print),
      onPressed: () {},
    ),
  ),
);

顺便说一句,感谢您将问题的答案标记为已回答!!!!