formattedVotes property

String get formattedVotes

Implementation

String get formattedVotes {
  try {
    final votes = BigInt.parse(totalVotes);
    if (votes > BigInt.from(1000000000000)) {
      final trillions = votes ~/ BigInt.from(1000000000000);
      return '${trillions}T HP';
    } else if (votes > BigInt.from(1000000000)) {
      final billions = votes ~/ BigInt.from(1000000000);
      return '${billions}B HP';
    } else if (votes > BigInt.from(1000000)) {
      final millions = votes ~/ BigInt.from(1000000);
      return '${millions}M HP';
    } else if (votes > BigInt.from(1000)) {
      final thousands = votes ~/ BigInt.from(1000);
      return '${thousands}K HP';
    }
    return '$votes HP';
  } catch (e) {
    return '0 HP';
  }
}