{"id":21116919,"url":"https://github.com/gilnobrega/proper_filesize","last_synced_at":"2025-04-13T06:14:56.338Z","repository":{"id":56837403,"uuid":"389523764","full_name":"gilnobrega/proper_filesize","owner":"gilnobrega","description":"A self-contained Dart library for seamlessly converting between bytes and human-readable file sizes.","archived":false,"fork":false,"pushed_at":"2025-02-09T21:59:46.000Z","size":25,"stargazers_count":3,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-13T06:14:42.965Z","etag":null,"topics":["dart","flutter","pubdev"],"latest_commit_sha":null,"homepage":"","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gilnobrega.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-07-26T05:58:28.000Z","updated_at":"2025-01-13T19:26:20.000Z","dependencies_parsed_at":"2022-09-09T17:22:18.928Z","dependency_job_id":null,"html_url":"https://github.com/gilnobrega/proper_filesize","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gilnobrega%2Fproper_filesize","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gilnobrega%2Fproper_filesize/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gilnobrega%2Fproper_filesize/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gilnobrega%2Fproper_filesize/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gilnobrega","download_url":"https://codeload.github.com/gilnobrega/proper_filesize/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248670435,"owners_count":21142904,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dart","flutter","pubdev"],"created_at":"2024-11-20T02:36:59.886Z","updated_at":"2025-04-13T06:14:56.314Z","avatar_url":"https://github.com/gilnobrega.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![pub package](https://img.shields.io/pub/v/proper_filesize.svg)](https://pub.dev/packages/proper_filesize)\n[![license](https://img.shields.io/github/license/gilnobrega/proper_filesize)](https://github.com/gilnobrega/proper_filesize/blob/main/LICENSE)\n[![code style: lints](https://img.shields.io/badge/style-%2F%2F%20lints-40c4ff.svg)](https://pub.dev/packages/lints)\n\n**A self-contained Dart library for seamlessly converting between bytes and human-readable file sizes.**\n\nEffortlessly convert raw byte values into human-readable file sizes like \"1.2 KB\" or \"3.5 MB\", and vice versa.\n\nThis is ideal for displaying file sizes in user interfaces, handling file uploads, processing data storage information, and more.\n\nSupports both binary (KiB, MiB, GiB) and metric (KB, MB, GB) units.\n\n## Features\n\n*   Converts bytes to human-readable strings (e.g., `1024 bytes` to `\"1 KiB\"`).\n*   Converts human-readable strings to bytes (e.g., `\"1.2 GB\"` to `1200000000 bytes`).\n*   Supports both binary and metric units (KB, KiB, MB, MiB, GB, GiB, TB, TiB, PB, PiB, EB, EiB, etc.).\n*   Customizable decimal precision.\n*   Supports short and long format types (e.g., \"KB\" vs \"kilobyte\").\n\n## Installation\n\nAdd `proper_filesize` as a dependency to your project. You can do this easily by running the following command in your terminal:\n\n```bash\ndart pub add proper_filesize\n```\n\nOr, manually add it to your project's `pubspec.yaml` file:\n\n```yaml\ndependencies:\n  proper_filesize: ^1.0.2\n```\n\nThen run:\n\n```bash\ndart pub get\n```\n\n## Usage\n\nFirst, import the library:\n\n```dart\nimport 'package:proper_filesize/proper_filesize.dart';\n```\n\n### Parsing File Size String to Numeric Value\n\nConverts a human-readable file size string (e.g., \"1.2 KB\", \"3.5 MB\", \"1.5 GiB\") to its corresponding byte value.\n\n```dart\nimport 'package:proper_filesize/proper_filesize.dart';\n\nString metricFilesize = \"1.2 EB\";\nint metricBytes = FileSize.parse(metricFilesize).size.toInt();\nprint(\"$metricFilesize is $metricBytes bytes\");\n// Output: 1.2 EB is 1200000000000000000 bytes\n\nString binaryFilesize = \"1.2 EiB\";\nint binaryBytes = FileSize.parse(binaryFilesize).size.toInt();\nprint(\"$binaryFilesize is $binaryBytes bytes\");\n// Output: 1.2 EiB is 1383505805528216320 bytes\n\nString longFormatFilesize = \"1.45 gibibytes\";\nint longFormatBytes = FileSize.parse(longFormatFilesize).size.toInt();\nprint(\"$longFormatFilesize is $longFormatBytes bytes\");\n// Output: 1.45 gibibytes is 1556488978432 bytes\n```\n\n### Converting Numeric Value to File Size String\n\nConverts a byte value to a human-readable file size string.\n\n```dart\nimport 'package:proper_filesize/proper_filesize.dart';\n\nint bytes = 1243560000;\n\n// Using metric units (KB, MB, GB)\nString metricFilesize = FileSize.fromBytes(bytes).toString(\n  unit: Unit.auto(size: bytes, baseType: BaseType.metric),\n);\nprint(\"$bytes bytes is $metricFilesize\"); \n// Output: 1243560000 bytes is 1.244 GB\n\n// Using binary units (KiB, MiB, GiB)\nString binaryFilesize = FileSize.fromBytes(bytes).toString();\nprint(\"$bytes bytes is $binaryFilesize\"); \n// Output: 1243560000 bytes is 1.158 GiB\n```\n\n### Further Examples\n\nFor more comprehensive examples, explore the following use cases in the [example.dart](https://pub.dev/packages/proper_filesize/example) file:\n\n  * Customizing Decimal Precision: Control the number of decimal places in the output.\n  * Using Long Format Types: Display units in their full form (e.g., \"kilobyte\" instead of \"KB\").\n  * Providing Explicit Units: Specify the desired output unit.\n  * Parsing Long-Format Strings: Parse strings with long-form units.\n  * Converting Units with Explicit Unit Conversion: Convert between different units directly.\n\n## API Documentation\n\nFor detailed information about all classes and methods, see the full [API documentation](https://pub.dev/documentation/proper_filesize/latest/).\n\n## Contributions\n\nWe welcome contributions\\! Whether you have a bug report, a feature request, or want to contribute code, please feel free to open an issue or submit a pull request on [GitHub](https://github.com/gilnobrega/proper_filesize).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgilnobrega%2Fproper_filesize","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgilnobrega%2Fproper_filesize","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgilnobrega%2Fproper_filesize/lists"}