wallet_overview.dart 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import 'package:decimal/decimal.dart';
  2. /// 账户总览钱包项 - GET uc/asset/wallets
  3. /// walletType: SPOT=资金, SWAP=合约, FOLLOW=跟单, SPOT_TRADING=现货(虚拟,非服务端字段)
  4. class WalletOverview {
  5. final String walletType;
  6. final String name;
  7. final Decimal balance;
  8. const WalletOverview({
  9. required this.walletType,
  10. required this.name,
  11. required this.balance,
  12. });
  13. factory WalletOverview.fromJson(Map<String, dynamic> json) {
  14. return WalletOverview(
  15. walletType: json['walletType']?.toString() ?? '',
  16. name: json['name']?.toString() ?? '',
  17. balance:
  18. Decimal.tryParse(json['balance']?.toString() ?? '0') ?? Decimal.zero,
  19. );
  20. }
  21. /// 钱包类型显示名称
  22. String get displayName {
  23. switch (walletType) {
  24. case 'SPOT':
  25. return '资金账户';
  26. case 'SWAP':
  27. return '合约账户';
  28. case 'FOLLOW':
  29. return '跟单账户';
  30. case 'SPOT_TRADING':
  31. return '现货账户';
  32. default:
  33. return name;
  34. }
  35. }
  36. }