我正在撰寫 ListView 的測驗代碼。雖然我明確指定了引數的名稱,但我收到了錯誤訊息“位置引數過多:預期為 0,但找到了 2”。有什么建議可以解決這個問題嗎?
提前致謝。
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('File Example'),
),
body: Center(
child: Column(
ListView.builder(
itemCount: (this.ideaCount == null) ? 0 : this.ideaCount,
itemBuilder: (BuildContext context, int position) {
return Card(
color: Colors.white,
elevation: 2.0,
child: ListTile(
title: Text(ideaList[position].name),
subtitle: Text(ideaList[position].memo),
)
);
}),
GestureDetector(
onLongPress: () async {
print("Long Press");
result = await record.hasPermission();
if (result) {
var dir = await getApplicationDocumentsDirectory();
print("############");
print(dir.path);
DateTime now = DateTime.now();
recordDate = '$now';
await record.start(
path: dir.path recordDate! '.aac',
encoder: AudioEncoder.AAC,
bitRate: 128000,
samplingRate: 44100,
);
} else {
print('##########Not Allowed!!!!!');
}
},
onLongPressUp: () async {
print("Long Press Stop");
record.stop();
Idea idea = Idea(1, recordDate!, 'test');
helper.insertIdea(idea);
setState(() {
showData();
});
},
child: ElevatedButton(
onPressed: () {}, child: Icon(Icons.mic))))));
}
uj5u.com熱心網友回復:
看來您將ListView.Builder()andGestureDetector()放入Column()小部件不正確。
這是一個正確的示例:
Column(
children:[
ListView.Builder(),
GestureDetector(),
],
)
添加值時Column(),Row()您需要將其添加到children:屬性中。
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/429930.html
