如何在带有列和 list.builder 的 singlechildscrollview 上方添加带有 textformfield 的行?
How to add a row with a textformfield above a singlechildscrollview with a column and a list.builder?
我想在 singleChildScrollView 上方添加一行带有 textformfield 的行,但一直出现呈现错误。请指教
Widget build(BuildContext context) {
return Scaffold(
body:
SingleChildScrollView(child:Column(
children: [
ListView.builder(
itemCount: lstNumber.length,
shrinkWrap: true,
padding: EdgeInsets.only(top: 10,bottom: 10),
itemBuilder: (context, index){
return
ListTile(
title: Text(lstNumber[index].toString(), style: TextStyle(color:Colors.red,fontSize: 15),),
);
}),
],
))
//],)
);
}
输入一个列,该列将包含行内的 TextFormfield 和用 Expanded 包裹的 SingleChildScrollView:
List<int>? lstNumber = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,16 ,17, 18 , 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30];
@override
Widget build(BuildContext context) {
return Scaffold(
body: Column(
children: [
Row(
children: [
Container(
width: 300,
child:const TextFormField(
decoration: const InputDecoration(
labelText:"Input",
enabledBorder: UnderlineInputBorder(borderSide:BorderSide(color:Colors.red),
borderRadius: BorderRadius.all(Radius.elliptical(5,10))
),
)))]),
Expanded(
child: SingleChildScrollView(
child: Column(
children: [
ListView.builder(
itemCount: lstNumber!.length,
shrinkWrap: true,
padding: EdgeInsets.only(top: 10, bottom: 10),
itemBuilder: (context, index) {
return ListTile(
title: Text(
lstNumber![index].toString(),
style: TextStyle(color: Colors.red, fontSize: 15),
),
);
}),
],
)),
),
],
)
);
}
我想在 singleChildScrollView 上方添加一行带有 textformfield 的行,但一直出现呈现错误。请指教
Widget build(BuildContext context) {
return Scaffold(
body:
SingleChildScrollView(child:Column(
children: [
ListView.builder(
itemCount: lstNumber.length,
shrinkWrap: true,
padding: EdgeInsets.only(top: 10,bottom: 10),
itemBuilder: (context, index){
return
ListTile(
title: Text(lstNumber[index].toString(), style: TextStyle(color:Colors.red,fontSize: 15),),
);
}),
],
))
//],)
);
}
输入一个列,该列将包含行内的 TextFormfield 和用 Expanded 包裹的 SingleChildScrollView:
List<int>? lstNumber = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,16 ,17, 18 , 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30];
@override
Widget build(BuildContext context) {
return Scaffold(
body: Column(
children: [
Row(
children: [
Container(
width: 300,
child:const TextFormField(
decoration: const InputDecoration(
labelText:"Input",
enabledBorder: UnderlineInputBorder(borderSide:BorderSide(color:Colors.red),
borderRadius: BorderRadius.all(Radius.elliptical(5,10))
),
)))]),
Expanded(
child: SingleChildScrollView(
child: Column(
children: [
ListView.builder(
itemCount: lstNumber!.length,
shrinkWrap: true,
padding: EdgeInsets.only(top: 10, bottom: 10),
itemBuilder: (context, index) {
return ListTile(
title: Text(
lstNumber![index].toString(),
style: TextStyle(color: Colors.red, fontSize: 15),
),
);
}),
],
)),
),
],
)
);
}