【发布时间】:2020-10-01 03:56:46
【问题描述】:
运行此代码时出现错误:Multiple widgets used the same GlobalKey.
所以我可以解决这个问题。
如何将键动态传递给我的 listview.Builder。有可能通过吗?这是我的代码的简化版本:
GlobalKey<AutoCompleteTextFieldState<String>> key0 = new GlobalKey();
@override
Widget build(BuildContext context) {
return M Scaffold(
appBar: appBar,
body: SingleChildScrollView(
child: Container(
child: ListView.builder(
itemCount: 3,
itemBuilder: (context, index) {
return SimpleAutoCompleteTextField(
key: key0,
suggestions: suggestions,
textChanged: (text) => print(text),
clearOnSubmit: false,
textSubmitted: (text) => print(text)
),
}
),
),
),
);
}
【问题讨论】:
标签: flutter dart flutter-layout