Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jonaswanke/data_size
🔟 Customizable data size (bit & byte) formatting for interfacing with the user
https://github.com/jonaswanke/data_size
bit byte dart data-size formatting package
Last synced: 3 months ago
JSON representation
🔟 Customizable data size (bit & byte) formatting for interfacing with the user
- Host: GitHub
- URL: https://github.com/jonaswanke/data_size
- Owner: JonasWanke
- License: mit
- Created: 2020-05-28T05:59:57.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-04-29T12:55:53.000Z (9 months ago)
- Last Synced: 2024-05-02T01:57:29.865Z (8 months ago)
- Topics: bit, byte, dart, data-size, formatting, package
- Language: Dart
- Homepage: https://pub.dev/packages/data_size
- Size: 62.5 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
🔟 Customizable data size (bit & byte) formatting for interfacing with the user
![Build, Test & Lint](https://github.com/JonasWanke/data_size/workflows/Build,%20Test%20&%20Lint/badge.svg)
[![Coverage](https://codecov.io/gh/JonasWanke/data_size/branch/master/graph/badge.svg)](https://codecov.io/gh/JonasWanke/data_size)## Features
* format `DataUnit.bit` and `DataUnit.byte`
* select a prefix:
* `Prefix.decimal` (kB, MB, … with multiples of 1000)
* `Prefix.binary` (KiB, MiB, … with multiples of 1024)
* select a precision (number of decimal places)## Examples
```dart
final defaultString = 12345.formatByteSize(); // "12.35 kB"
final noDecimalPlaces = 12345.formatByteSize(precision: 0); // "12 kB"
final binaryPrefix = 12345.formatByteSize(prefix: Prefix.binary); // "12.06 KiB"
final bits = 12345.formatBitSize(); // "12.35 kb"
```