number_display 1.0.1 copy "number_display: ^1.0.1" to clipboard
number_display: ^1.0.1 copied to clipboard

outdated

To display data in a width-limited component, this function will smartly help you to convert number to a certain chart length. To be simple, plain, flexible and accurate.

example/main.dart

import 'package:number_display/number_display.dart';

main(List<String> args) {
  print(display(1234.123, 4));
  print(display(1.00, 8));
  print(display(1.12345678, 8));
  print(display(123, 8));
  print(display(1234, 8));
  print(display(123456789123, 8));
  print(display(12345.43212, 8));
  print(display(1.2345e+5, 8));
  print('---------------------------');
  print(display(-1, 8));
  print(display(-1.00, 8));
  print(display(-1.12345678, 8));
  print(display(-123, 8));
  print(display(-1234, 8));
  print(display(-123456789123, 8));
  print(display(-12345.43212, 8));
  print(display(-1.2345e+5, 8));
  print('---------------------------');
  print(display('-1234', 8));
  print(display('123456789123', 8));
  print(display('-1.2345e+5', 8));
  print('---------------------------');
  print(display(double.nan, 8));
  print(display(double.infinity, 8));
  print(display(double.negativeInfinity, 8));
  print(display(null, 8));
  print(display([], 8));
  print(display({}, 8));
  print(display(DateTime.now(), 8));
  print(display(DateTime.now().toString(), 8));
  print('---------------------------');
  print(display(1000000000, 4));
  print(display(1.00, 4));
  print(display(1.12345678, 4));
  print(display(123, 4));
  print(display(1234, 8));
  print(display(123456789123, 4));
  print(display(12345.43212, 4));
  print(display(1.2345e+5, 4));
  print('---------------------------');
  print(display(-1, 4));
  print(display(-1.00, 4));
  print(display(-1.12345678, 4));
  print(display(-123, 4));
  print(display(-1234, 4));
  print(display(-123456789123, 4));
  print(display(-12345.43212, 4));
  print(display(-1.2345e+5, 4));
  print('---------------------------');
  print(display(1.22, 8, maxAccuracy: 1));
  print(display('text', 8, allowText: false));
  print(display(12345678, 19, comma: true));
  print(display(12345678, 19, comma: false));
  print('---------------------------');
  print(display(1234567867, 8, units: ['w', 'y'], unitsInterval: 4));
  print(display(1234567867, 8, unitsMaxAccuracy: 2));
  print(display(12345, 4, units: ['t', 'h', 'k', 'tk'], unitsInterval: 1));
  print(display(123457777, 4, units: ['t', 'h', 'k', 'tk'], unitsInterval: 1));
}
76
likes
40
pub points
91%
popularity

Publisher

unverified uploader

To display data in a width-limited component, this function will smartly help you to convert number to a certain chart length. To be simple, plain, flexible and accurate.

Repository (GitHub)
View/report issues

License

MIT (license)

More

Packages that depend on number_display