我使用一个函数在颤振中创建了两个文本字段,但我想为每个字段使用两个不同的 TextEditingController。如何将 TextEditingController 作为参数传递给函数?
Widget fieldmaker(String title) {
return Container(
width: double.infinity,
height: 50,
padding: EdgeInsets.symmetric(
horizontal: 10,
),
child: TextField(
controller: ,
decoration: InputDecoration(
hintText: title,
hintStyle: TextStyle(
fontSize: 20,
),
contentPadding: EdgeInsets.all(2),
),
),
);
}
final amountcontroller=TextEditingController();
final titlecontroller=TextEditingController();
Widget build(BuildContext context) {
return Column(
children: [
fieldmaker('Title'),
fieldmaker('Amount'),
],
);
}