代碼:
import 'package:flutter/material.dart';
class sonIslemlerUygulamasi extends StatelessWidget {
const sonIslemlerUygulamasi({Key? key}) : super(key: key);
get islemler => islemler;
@override
Widget build(BuildContext context) {
List <sonIslemler> islemler = [sonIslemler("10 Kas?m", "Send money", "500 USD", "Bor?"), sonIslemler("11 Kas?m", "Withdraw money", "50 TL", "Yok")];
return Scaffold(
appBar: AppBar(
title: Text("Son i?lemler"),
backgroundColor: Colors.red[500],
),
body: Center(
child: Column(
children: [
Text("\nSon i?lemler", style: TextStyle(fontSize: 25, fontWeight: FontWeight.bold),),
Text("Son i?lemler uygulamas?na ho? geldiniz.\n", style: TextStyle(fontSize: 20), textAlign: TextAlign.center,),
Expanded(
child: ListView.builder(
itemCount: islemler.length,
itemBuilder: (BuildContext context, int index) {
return Card(
child: ListTile(
leading: processIcon(),
title: Text(islemler[index].islemTuru, style: TextStyle(fontSize: 20)),
subtitle: Text(islemler[index].islemTarihi,),
trailing: Text(islemler[index].islemMiktari, style: TextStyle(fontSize: 20)),
),
);
},
),
),
],
),
),
);
}
}
processIcon() {
// Process icon codes
}
class sonIslemler {
String islemTarihi;
String islemTuru;
String islemMiktari;
String islemAciklamasi;
sonIslemler(this.islemTarihi, this.islemTuru, this.islemMiktari, this.islemAciklamasi);
}
我的目標是制作一個顯示最近金融交易的應用程式。如果匯款,我想顯示不同的圖示,如果提款,我想顯示不同的圖示,以及每筆交易的單獨圖示。
我將在中顯示圖示leading。
交易在交易串列中。
如何根據流程顯示不同的圖示?
uj5u.com熱心網友回復:
import 'package:flutter/material.dart';
class sonIslemlerUygulamasi extends StatelessWidget {
const sonIslemlerUygulamasi({Key? key}) : super(key: key);
get islemler => islemler;
@override
Widget build(BuildContext context) {
List <sonIslemler> islemler = [sonIslemler("10 Kas?m", "Send money", "500 USD", "Bor?"), sonIslemler("11 Kas?m", "Withdraw money", "50 TL", "Yok")];
return Scaffold(
appBar: AppBar(
title: Text("Son i?lemler"),
backgroundColor: Colors.red[500],
),
body: Center(
child: Column(
children: [
Text("\nSon i?lemler", style: TextStyle(fontSize: 25, fontWeight: FontWeight.bold),),
Text("Son i?lemler uygulamas?na ho? geldiniz.\n", style: TextStyle(fontSize: 20), textAlign: TextAlign.center,),
Expanded(
child: ListView.builder(
itemCount: islemler.length,
itemBuilder: (BuildContext context, int index) {
return Card(
child: ListTile(
leading: processIcon(transactionType),
title: Text(islemler[index].islemTuru, style: TextStyle(fontSize: 20)),
subtitle: Text(islemler[index].islemTarihi,),
trailing: Text(islemler[index].islemMiktari, style: TextStyle(fontSize: 20)),
),
);
},
),
),
],
),
),
);
}
}
Widget processIcon(String transactionType) {
switch transactionType{
case "sent":
return Icon(); // Put the icon for 'sent' here
case "withdrawn":
return Icon(); // Put the icon for 'withdrawn' here
case "transaction1":
return Icon(); // Put the icon for 'transaction1' here
case "transaction2":
return Icon(); // Put the icon for 'transaction2' here
default:
return Icon(); // Put a default icon in case transactionType variable is not one of the above.
}
}
class sonIslemler {
String islemTarihi;
String islemTuru;
String islemMiktari;
String islemAciklamasi;
sonIslemler(this.islemTarihi, this.islemTuru, this.islemMiktari, this.islemAciklamasi);
}
我不確定您的交易型別是什么。您應該能夠將它傳遞給函式并從那里處理它。
uj5u.com熱心網友回復:
只需檢查是否匯款,然后回傳不同的圖示
if (isSent()){
return Icon(...)
}
else{
return Icon(...)
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/427316.html
