我有 UrunModel 檔案。在模型檔案中,我有 urunFiyat 變數。
我有一個靜態串列 sepetList = [];
我想對這個串列中的 urunFiyat 求和并撰寫以下函式:
但是我找不到總和,這是什么原因,我該怎么辦?
Widget toplamSatiri() {
double toplam = 1;
if (Sepet.sepetList.isNotEmpty) {
Sepet.sepetList.map((e) => toplam = e.urunFiyat);
} else {
toplam = 0;
} //buras? ?al??m?yor
return Container(
height: 60,
decoration: boxesdecorations(Colors.black),
child: Padding(
padding: const EdgeInsets.all(10.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'TOPLAM',
style: Theme.of(context)
.textTheme
.headline5!
.copyWith(color: Colors.white),
),
Text(
'$toplam TL',
style: Theme.of(context)
.textTheme
.headline5!
.copyWith(color: Colors.white),
),
],
),
),
);
}
uj5u.com熱心網友回復:
改變這一行Sepet.sepetList.map((e) => toplam = e.urunFiyat);這樣的:Sepet.sepetList.map((e) { toplam = e.urunFiyat;}).toList();
編輯:我忘了加分號
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/386116.html
