包裹在 RefreshIndicator 中时无法向下滚动列表
Cannot scroll down list when wrapped inside RefreshIndicator
SingleChildScrollView(
child: Column(
children: [
Container(
padding: EdgeInsets.all(24),
child: Form(
key: _formSearcOrdershKey,
autovalidateMode: AutovalidateMode.onUserInteraction,
child: TextFormField(
decoration: InputDecoration(
border: UnderlineInputBorder(),
labelText: 'Enter Data',
),
onChanged: (value) => getData(value),
),
),
),
RefreshIndicator(
onRefresh: () => controller.callApi(0),
child: ListView.separated(
shrinkWrap: true,
physics: AlwaysScrollableScrollPhysics(),
itemCount: controller.workOrders.length,
separatorBuilder: (context, position) {
return Divider();
},
itemBuilder: (context, position) {
return ListTile(
isThreeLine: true,
title: Text(
'title',
maxLines: 1,
overflow: TextOverflow.ellipsis,
softWrap: false,
),
onTap: () => {print('tap')},
subtitle: Text(
'text',
maxLines: 1,
overflow: TextOverflow.ellipsis,
softWrap: false,
),
);
},
),
),
],
),
),
我很困惑为什么它不起作用。 AlwaysScrollableScrollPhysics 处于活动状态,但它仍然不起作用。我错过了什么?
尝试删除 SingleChildScrollView
.
然后把你的RefreshIndicator
改成这个。
@override
Widget build(BuildContext context) {
return Scaffold(
body: Column(
children: [
Container(
padding: EdgeInsets.all(24),
child: Form(
// key: _formSearcOrdershKey,
autovalidateMode: AutovalidateMode.onUserInteraction,
child: TextFormField(
decoration: const InputDecoration(
border: UnderlineInputBorder(),
labelText: 'Enter Data',
),
onChanged: (value) {},
),
),
),
Expanded(
child: RefreshIndicator(
onRefresh: () => callApi(),
child: ListView.separated(
shrinkWrap: true,
physics: AlwaysScrollableScrollPhysics(),
itemCount: 10,
separatorBuilder: (context, position) {
return Divider();
},
itemBuilder: (context, position) {
return ListTile(
isThreeLine: true,
title: Text(
'title',
maxLines: 1,
overflow: TextOverflow.ellipsis,
softWrap: false,
),
onTap: () => {print('tap')},
subtitle: Text(
'text',
maxLines: 1,
overflow: TextOverflow.ellipsis,
softWrap: false,
),
);
},
),
),
),
],
),
);
}
SingleChildScrollView(
child: Column(
children: [
Container(
padding: EdgeInsets.all(24),
child: Form(
key: _formSearcOrdershKey,
autovalidateMode: AutovalidateMode.onUserInteraction,
child: TextFormField(
decoration: InputDecoration(
border: UnderlineInputBorder(),
labelText: 'Enter Data',
),
onChanged: (value) => getData(value),
),
),
),
RefreshIndicator(
onRefresh: () => controller.callApi(0),
child: ListView.separated(
shrinkWrap: true,
physics: AlwaysScrollableScrollPhysics(),
itemCount: controller.workOrders.length,
separatorBuilder: (context, position) {
return Divider();
},
itemBuilder: (context, position) {
return ListTile(
isThreeLine: true,
title: Text(
'title',
maxLines: 1,
overflow: TextOverflow.ellipsis,
softWrap: false,
),
onTap: () => {print('tap')},
subtitle: Text(
'text',
maxLines: 1,
overflow: TextOverflow.ellipsis,
softWrap: false,
),
);
},
),
),
],
),
),
我很困惑为什么它不起作用。 AlwaysScrollableScrollPhysics 处于活动状态,但它仍然不起作用。我错过了什么?
尝试删除 SingleChildScrollView
.
然后把你的RefreshIndicator
改成这个。
@override
Widget build(BuildContext context) {
return Scaffold(
body: Column(
children: [
Container(
padding: EdgeInsets.all(24),
child: Form(
// key: _formSearcOrdershKey,
autovalidateMode: AutovalidateMode.onUserInteraction,
child: TextFormField(
decoration: const InputDecoration(
border: UnderlineInputBorder(),
labelText: 'Enter Data',
),
onChanged: (value) {},
),
),
),
Expanded(
child: RefreshIndicator(
onRefresh: () => callApi(),
child: ListView.separated(
shrinkWrap: true,
physics: AlwaysScrollableScrollPhysics(),
itemCount: 10,
separatorBuilder: (context, position) {
return Divider();
},
itemBuilder: (context, position) {
return ListTile(
isThreeLine: true,
title: Text(
'title',
maxLines: 1,
overflow: TextOverflow.ellipsis,
softWrap: false,
),
onTap: () => {print('tap')},
subtitle: Text(
'text',
maxLines: 1,
overflow: TextOverflow.ellipsis,
softWrap: false,
),
);
},
),
),
),
],
),
);
}