A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://pub.dev/documentation/github/latest/github/../github/parseFancyNumber.html below:

parseFancyNumber function - github library

parseFancyNumber function

Implementation
int parseFancyNumber(String input) {
  input = input.trim();
  if (input.contains(',')) {
    input = input.replaceAll(',', '');
  }

  const multipliers = {'h': 100, 'k': 1000, 'ht': 100000, 'm': 1000000};
  int value;

  if (!multipliers.keys.any((m) => input.endsWith(m))) {
    value = int.parse(input);
  } else {
    final m = multipliers.keys.firstWhere((m) => input.endsWith(m));
    input = input.substring(0, input.length - m.length);
    value = num.parse(input) * multipliers[m]! as int;
  }

  return value;
}

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4