我试图得到一个列内工作的列表视图。我得到了十亿个错误。我尝试使用Expanded()
,但似乎没有给出任何结果
代码如下:
Scaffold(
body: SafeArea(
child: Container(
color: const Color(0xFF242323),
child: Column(
children: [
Expanded(
child: Column(
children: [
Padding(
padding: const EdgeInsets.fromLTRB(27, 23, 27, 12),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: const [
GradientText(
"Skol",
gradient: LinearGradient(
colors: [
Color(0xFFf5ab16),
Color(0xFFe8a215),
Color(0xFFcf9013),
],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
),
style: TextStyle(
fontSize: 44,
fontFamily: "Informal",
fontWeight: FontWeight.bold,
),
),
// Skol title
CircleAvatar(
backgroundColor: Color(0xFFb77f11),
radius: 24,
child: CircleAvatar(
backgroundImage:
AssetImage("assets/images/user.png"),
backgroundColor: Color(0xFFfedc76),
radius: 22,
),
// Avatar
)
],
),
// navbar top area
),
// Skol Title and User Button
ListView()
],
),
),
],
))),
);
当我查的时候,他们说用shrinkwrap
或sizedbox
。
用Expanded widget包装ListView
Scaffold(
body: SafeArea(
child: Container(
color: const Color(0xFF242323),
child: Column(
children: [
Expanded(
child: Column(
children: [
Padding(
padding: const EdgeInsets.fromLTRB(27, 23, 27, 12),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: const [],
),
// navbar top area
),
// Skol Title and User Button
Expanded(child: ListView())
],
),
),
],
),
),
),
);