我能够通过将主列包装在 SingleChildScrollView 中来解决问题,然后将 ListView.builder 包装在 Container 中,为容器提供指定的高度,然后再次将该容器包装在 SingleChildScrollView 中。
我知道这很复杂,但它对我有用!
你可以通过代码有一个清晰的画面。
Scaffold(
appBar: AppBar(
centerTitle: true,
backgroundColor: Colors.black,
title: Text("Welcome, ${widget.myUser.name}"),
actions: [
InkWell(
child: Container(
alignment: Alignment.center,
padding: EdgeInsets.only(right: 20),
child: Icon(Icons.settings),
),
onTap: () {},
),
],
),
body: Padding(
padding: EdgeInsets.symmetric(horizontal: 20),
child: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.max,
children: [
_customerDetailsWidget(),
SizedBox(
height: 15,
),
Container(
child: Divider(
color: Colors.grey[500],
),
),
SizedBox(
height: 15,
),
_addProductText(),
SingleChildScrollView(
child: Container(
height: 500,
child: ListView.builder(
itemCount:1,
itemBuilder: (BuildContext context, int index) {
return Container(child: Text("HELLO WORLD"));
},
),
))
],
),
),
),
),