Dart 如何使容器拉伸到与行相同的高度?

Dart 如何使容器拉伸到与行相同的高度?,dart,flutter,Dart,Flutter,我想实现以下目标 我能做到的 这是我的密码 return Card( shape: RoundedRectangleBorder( borderRadius: BorderRadius.all(Radius.circular(10))), child: Row( children: <Widget>[ Container( color: Colors.or

我想实现以下目标

我能做到的

这是我的密码

return Card(
        shape: RoundedRectangleBorder(
            borderRadius: BorderRadius.all(Radius.circular(10))),
        child: Row(
          children: <Widget>[
            Container(
              color: Colors.orange,
              width: 4,
            ),
            Expanded(
              child: Column(
                children: <Widget>[
                  Row(
                    children: <Widget>[
                      Icon(Icons.alarm),
                      SizedBox(
                        width: 2,
                      ),
                      Text(
                        "Starts",
                        style:
                            TextStyle(fontFamily: "BarlowMedium", fontSize: 12),
                      ),
                      SizedBox(
                        width: 4,
                      ),
                      Text(
                        studentClassesData.classStarttime,
                        style: TextStyle(fontFamily: "BarlowBold", fontSize: 12),
                      ),
                      SizedBox(
                        width: 4,
                      ),
                      Text(
                        "to",
                        style:
                            TextStyle(fontFamily: "BarlowMedium", fontSize: 12),
                      ),
                      SizedBox(
                        width: 4,
                      ),
                      Text(
                        studentClassesData.classEndtime,
                        style: TextStyle(fontFamily: "BarlowBold", fontSize: 12),
                      )
                    ],
                  ),
                  SizedBox(
                    height: 4,
                  ),
                  Align(
                    alignment: Alignment.centerLeft,
                    child: Text(
                      studentClassesData.subject,
                      style: TextStyle(
                          fontFamily: "BarlowBold", fontSize: 12, color: blue),
                    ),
                  ),
                  SizedBox(
                    height: 4,
                  ),
                  Row(
                    mainAxisAlignment: MainAxisAlignment.start,
                    children: <Widget>[
                      CircleAvatar(
                        backgroundImage:
                            NetworkImage(studentClassesData.facultyImage),
                        child: Image.asset("images/round_only.webp"),
                      ),
                      SizedBox(width: 5,),
                      Column(
                        mainAxisAlignment: MainAxisAlignment.start,
                        children: <Widget>[
                          Align(
                            alignment: Alignment.centerLeft,
                            child: Text(
                              "Faculty",
                              style: TextStyle(fontFamily: "KohinoorDemi"),
                            ),
                          ),
                          SizedBox(
                            height: 3,
                          ),
                          Text(
                            studentClassesData.faculty,
                            style: TextStyle(fontFamily: "BarlowBold"),
                          ),
                        ],
                      )
                    ],
                  ),
                  SizedBox(
                    height: 4,
                  ),
                  Row(
                    children: <Widget>[
                      Icon(Icons.business),
                      Column(
                        children: <Widget>[
                          Text(
                            "Floor/Room",
                            style: TextStyle(fontFamily: "KohinoorDemi"),
                          ),
                          SizedBox(
                            height: 3,
                          ),
                          Text(
                            "${studentClassesData.floor}/${studentClassesData.room}",
                            style: TextStyle(fontFamily: "BarlowBold"),
                          ),
                        ],
                      )
                    ],
                  ),
                ],
              ),
            )
          ],
        ));
退货卡(
形状:圆形矩形边框(
borderRadius:borderRadius.all(半径.圆形(10)),
孩子:排(
儿童:[
容器(
颜色:颜色。橙色,
宽度:4,
),
扩大(
子:列(
儿童:[
划船(
儿童:[
图标(图标。警报),
大小盒子(
宽度:2,
),
正文(
“开始”,
风格:
TextStyle(fontFamily:“BarlowMedium”,fontSize:12),
),
大小盒子(
宽度:4,
),
正文(
studentClassesData.classStarttime,
样式:TextStyle(fontFamily:“BarlowBold”,fontSize:12),
),
大小盒子(
宽度:4,
),
正文(
“至”,
风格:
TextStyle(fontFamily:“BarlowMedium”,fontSize:12),
),
大小盒子(
宽度:4,
),
正文(
studentClassesData.classEndtime,
样式:TextStyle(fontFamily:“BarlowBold”,fontSize:12),
)
],
),
大小盒子(
身高:4,
),
对齐(
对齐:alignment.centerLeft,
子:文本(
studentClassesData.subject,
样式:TextStyle(
fontFamily:“BarlowBold”,fontSize:12,颜色:蓝色),
),
),
大小盒子(
身高:4,
),
划船(
mainAxisAlignment:mainAxisAlignment.start,
儿童:[
圆形(
背景图片:
网络图像(studentClassesData.facultyImage),
子项:Image.asset(“images/round_only.webp”),
),
尺寸标注框(宽度:5,),
纵队(
mainAxisAlignment:mainAxisAlignment.start,
儿童:[
对齐(
对齐:alignment.centerLeft,
子:文本(
“教员”,
样式:TextStyle(fontFamily:“KohinoorDemi”),
),
),
大小盒子(
身高:3,
),
正文(
studentClassesData.faculty,
样式:TextStyle(fontFamily:“BarlowBold”),
),
],
)
],
),
大小盒子(
身高:4,
),
划船(
儿童:[
图标(图标。业务),
纵队(
儿童:[
正文(
“楼层/房间”,
样式:TextStyle(fontFamily:“KohinoorDemi”),
),
大小盒子(
身高:3,
),
正文(
“${studentClassesData.floor}/${studentClassesData.room}”,
样式:TextStyle(fontFamily:“BarlowBold”),
),
],
)
],
),
],
),
)
],
));

我无法看到一开始是淡黄色的景观,它占据了与这一排相同的高度。正如您在上面的代码中所看到的,我使用了一个
容器
,我知道我可以给容器指定一个高度,但我不想给容器指定一个固定高度,因为高度可能会根据来自api的数据而变化。

您需要使用-
IntrinsicHeight
来获得您想要的

工作代码(带有虚拟值):

卡(
形状:圆形矩形边框(
borderRadius:borderRadius.all(半径.圆形(10)),
clipBehavior:Clip.antiAlias,
孩子:内在的(
孩子:排(
crossAxisAlignment:crossAxisAlignment.stretch,
儿童:[
容器(
颜色:颜色。橙色,
宽度:4,
),
尺寸控制盒(宽度:5.0,),
纵队(
crossAxisAlignment:crossAxisAlignment.start,
儿童:[
划船(
儿童:[
图标(图标。警报),
大小盒子(
宽度:2,
),
正文(
“开始”,
样式:TextStyle(
fontFamily:“BarlowMedium”,fontSize:12),
),
大小盒子(
 Card(
            shape: RoundedRectangleBorder(
                borderRadius: BorderRadius.all(Radius.circular(10))),
            clipBehavior: Clip.antiAlias,
            child: IntrinsicHeight(
              child: Row(
                crossAxisAlignment: CrossAxisAlignment.stretch,
                children: <Widget>[
                  Container(
                    color: Colors.orange,
                    width: 4,
                  ),
                  SizedBox(width: 5.0,),
                  Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: <Widget>[
                      Row(
                        children: <Widget>[
                          Icon(Icons.alarm),
                          SizedBox(
                            width: 2,
                          ),
                          Text(
                            "Starts",
                            style: TextStyle(
                                fontFamily: "BarlowMedium", fontSize: 12),
                          ),
                          SizedBox(
                            width: 4,
                          ),
                          Text(
                            '11:30 AM',
                            style:
                                TextStyle(fontFamily: "BarlowBold", fontSize: 12),
                          ),
                          SizedBox(
                            width: 4,
                          ),
                          Text(
                            "to",
                            style: TextStyle(
                                fontFamily: "BarlowMedium", fontSize: 12),
                          ),
                          SizedBox(
                            width: 4,
                          ),
                          Text(
                            '1:30 PM',
                            style:
                                TextStyle(fontFamily: "BarlowBold", fontSize: 12),
                          )
                        ],
                      ),
                      SizedBox(
                        height: 4,
                      ),
                      Align(
                        alignment: Alignment.centerLeft,
                        child: Text(
                          'Design Studio 6 (Capstone)',
                          style: TextStyle(
                              fontFamily: "BarlowBold",
                              fontSize: 12,
                              color: Colors.blue),
                        ),
                      ),
                      SizedBox(
                        height: 4,
                      ),
                      Row(
                        mainAxisAlignment: MainAxisAlignment.start,
                        children: <Widget>[
                          CircleAvatar(
                            backgroundImage:
                                NetworkImage('https://placeimg.com/640/480/any'),
                            child: Image.asset("images/round_only.webp"),
                          ),
                          SizedBox(
                            width: 5,
                          ),
                          Column(
                            mainAxisAlignment: MainAxisAlignment.start,
                            children: <Widget>[
                              Align(
                                alignment: Alignment.centerLeft,
                                child: Text(
                                  "Faculty",
                                  style: TextStyle(fontFamily: "KohinoorDemi"),
                                ),
                              ),
                              SizedBox(
                                height: 3,
                              ),
                              Text(
                                'Meenal',
                                style: TextStyle(fontFamily: "BarlowBold"),
                              ),
                            ],
                          )
                        ],
                      ),
                      SizedBox(
                        height: 4,
                      ),
                      Row(
                        children: <Widget>[
                          Icon(Icons.business),
                          Text(
                            "Floor/Room",
                            style: TextStyle(fontFamily: "KohinoorDemi"),
                          ),
                          SizedBox(
                            height: 3,
                          ),
                          Text(
                            "6th Floor: North Wing / ISDI 606",
                            style: TextStyle(fontFamily: "BarlowBold"),
                          )
                        ],
                      ),
                    ],
                  )
                ],
              ),
            )),
SizedBox(
  height: 100,
  child: Card(
    color: Colors.green,
    child: Row(
      children: <Widget>[
        Container(
          color: Colors.blue,
          width: 100, // no need to set any height, it will automatically fill to match row
        )
      ],
    ),
  ),
);