← Code knowledge base
Reviewed Flutter implementation · 2026-10-27

card_top_up_balance.dart

mobile_flutter/lib/features/cards/domain/card_top_up_balance.dart

Immutable source snapshot based on revision de78e63ed65c. Original line numbers are retained. This is implementation evidence; check the public API catalogue before adapting it.

The mobile /api/v1/mobile routes belong to the example backend. Company credentials stay on that backend. Some sections outside the documented product scope may be omitted.

Lines 1–35

import '../../wallets/domain/wallet_models.dart'; const cardTopUpFundingCurrencies = {'USD', 'USDT', 'USDC'}; // Stablecoin funding is estimated at 1 USD per USDT/USDC. Work in eight// decimal places so binary floating-point tails cannot lose a cent on Max.BigInt _units(double amount) =>    BigInt.parse(amount.toStringAsFixed(8).replaceAll('.', '')); final _scale = BigInt.from(100000000); double cardTopUpAvailable(List<HoppaWalletAsset> balances) {  var total = BigInt.zero;  for (final balance in balances) {    if (cardTopUpFundingCurrencies            .contains(balance.symbol.trim().toUpperCase()) &&        balance.amount.isFinite &&        balance.amount > 0) {      total += _units(balance.amount);    }  }  return total.toDouble() / _scale.toDouble();} double cardBalanceQuickAmount(double available, double fraction,    {bool wholeDollarMax = false}) {  if (!available.isFinite || available <= 0) return 0;  final units = _units(available);  if (wholeDollarMax && fraction == 1) {    return (units ~/ _scale).toDouble();  }  final percent = BigInt.from((fraction * 100).round());  final cents = units * percent ~/ _scale;  return cents.toDouble() / 100;}
HOPPA DEVELOPER ASSISTANT

What are you building?

From a question to an implementation.

Get a step-by-step flow, example code and the docs behind it. Choose a starting point or describe your feature.

Answers use the public API guide and example app code. Check the linked reference before shipping. Explore code sources ↗

Your question and recent conversation are sent to our AI provider. Don’t include API keys, personal data or card details.