byte_converter_intl library

Byte converter with full internationalization support.

This export includes everything from the main byte_converter library plus full localization support via the intl package.

Features:

  • Locale-aware number formatting (decimal separators, grouping)
  • Unit name localization (9 languages built-in)
  • Custom locale registration

Usage:

import 'package:byte_converter/byte_converter_intl.dart';

void main() {
  // Enable intl-based formatting
  enableByteConverterIntl();

  final size = ByteConverter.fromGigaBytes(1.5);
  print(size.display.auto(locale: 'de')); // "1,5 GB"
  print(size.display.auto(locale: 'fr')); // "1,5 Go"
}

For apps that don't need the intl dependency, use:

import 'package:byte_converter/byte_converter_lite.dart';

Classes

BandwidthAccumulator
Accumulates byte values over time for streaming scenarios.
BigBitOperations
Provides bit-level operations for BigByteConverter.
BigByteConverter
High-performance byte unit converter using BigInt for arbitrary precision.
BigDataRate
BigInt-precision data rate stored as bits per second.
BitOperations
Provides bit-level operations and conversions for byte values.
ByteAccessibility
Provides accessibility-friendly output formats for byte values.
ByteComparison
Provides comparison and relationship utilities for byte values.
ByteConstants
Named constants for common byte sizes.
ByteConverter
High-performance byte unit converter with caching.
ByteDelta
Represents a signed change in bytes with arbitrary precision.
ByteDisplayOptions
Provides alternative display formats for byte values.
ByteFormatOptions
Reusable formatter options for humanizing sizes and transfer rates.
ByteOrdinal
Ordinal number formatting utilities.
ByteOutputFormats
Provides structured output formats for programmatic use.
BytePluralization
Smart pluralization utilities for byte-related terms.
ByteRange
Inclusive-exclusive byte range [start, end) backed by BigInt.
ByteRounding
Extended rounding strategies for byte value formatting.
ByteValidation
Input validation utilities for byte values.
CompoundFormatOptions
Options controlling compound mixed-unit formatting, e.g. "1 GiB 234 MiB 12 KiB".
DataRate
Represents a network/data rate. Internally stored as bits per second.
NaturalTimeDelta
Human-friendly time descriptions for durations.
NegativeByteFormatter
Utilities for formatting negative byte values.
NegativeValueOptions
Configuration for negative value formatting.
NetworkRate
Network rate utilities providing bits/bytes per second conversions and transfer time calculations.
ParseError
Structured error information produced by parse helpers.
ParseResult<T>
Result wrapper for non-throwing parse helpers.
PluralizationOptions
Configuration for pluralization behavior.
RateWindow
Represents a window of rate over a time span, for planning variable schedules.
RelativeTime
Relative time formatting utilities.
RelativeTimeOptions
Configuration options for relative time formatting.
SINumber
SI (International System of Units) number formatting utilities.
SizeDelta
Represents a change in byte size with direction awareness.
StorageAlignment
Describes a single alignment class within a StorageProfile.
StorageNamespace
Storage alignment utilities providing sector, block, page, and word calculations along with rounding and alignment checks.
StorageProfile
Defines storage alignment preferences used by byte converters when rounding to device-specific bucket sizes such as sectors, blocks, or pages.
TransferPlan
Simple transfer planning model for estimating ETAs and progress.
ValidationResult
Result of a validation operation.

Enums

BigSizeUnit
Size units for BigByteConverter with support for larger SI magnitudes.
ByteRoundingMode
Rounding mode enumeration for byte formatting.
ByteStandard
Unit standards/prefix systems used for formatting and parsing.
DeltaDirection
Modes for byte delta direction.
NegativeDisplayMode
Modes for displaying negative byte values.
PluralizationRule
Pluralization rules for different locales.
RoundingMode
Rounding modes for converting fractional values to integers.
SizeUnit
Byte size units for standard precision conversions (up to PB).

Extensions

BigBitOperationsExtension on BigByteConverter
Extension providing bit operations accessor for BigByteConverter.
BigByteConverterNamespaces on BigByteConverter
Extension providing namespace accessors for BigByteConverter.
BigDataRatePlanning on BigDataRate
Planning helpers for computing transferable bytes over a duration at a given BigDataRate. Methods avoid rounding drift by using integer math.
BigIntByteConverterExtension on BigInt
Extensions for BigInt to create BigByteConverter instances.
BitOperationsExtension on ByteConverter
Extension providing bit operations accessor for ByteConverter.
ByteConverterNamespaces on ByteConverter
Extension providing namespace accessors for ByteConverter.
ByteConverterTransfer on ByteConverter
ByteConverter helpers for transfer planning.
ByteRoundingExtension on double
Provides convenience methods for rounding byte values.
ByteValidationExtension on ByteConverter
Extension to add validation methods to ByteConverter.
DataRatePlanning on DataRate
DataRate helpers for planning.
DoubleByteConverterExtension on double
Extensions for double to create ByteConverter instances.
DoublePluralizationExtension on double
Extension on double for quick pluralization.
IntByteConverterExtension on int
Extensions for int to create ByteConverter instances.
IntPluralizationExtension on int
Extension on int for quick pluralization.
NaturalTimeDeltaExtension on Duration
Extension to add natural time formatting to Duration.
NegativeBigByteConverterExtension on BigByteConverter
Extension on BigByteConverter for negative value support.
NegativeByteConverterExtension on ByteConverter
Extension on ByteConverter for negative value support.
NegativeBytesDoubleExtension on double
Extension on double for negative byte formatting.
OrdinalExtension on int
Extension for ordinal formatting on integers.
RelativeDateTimeExtension on DateTime
Extension on DateTime for relative time formatting.
RelativeDurationExtension on Duration
Extension on Duration for relative time formatting.
SINumberExtension on num
Extension for SI number formatting on num types.
TransferPlanAdvanced on TransferPlan
Advanced controls: schedules, pause/resume, and throttling.

Functions

clearLocalizedSingularNames(String locale) → void
Clears previously registered localized singular-name overrides for locale.
clearLocalizedSynonyms(String locale) → void
Clears previously registered localized synonyms for locale.
clearLocalizedUnitNames(String locale) → void
Clears previously registered localized unit names for locale.
disableByteConverterIntl() → void
Disable the intl-backed number formatter and fall back to defaults.
disableDefaultLocalizedUnitNames() → void
Disable built-in default localized unit names to enable tree-shaking strategies. Disables the built-in default localized unit names to aid tree-shaking.
enableByteConverterIntl({NumberFormatFactory? numberFormatFactory}) → void
Enable number formatting for byte humanization using the intl package.
enableDefaultLocalizedUnitNames() → void
Re-enable built-in default localized unit names. Re-enables the built-in default localized unit names.
localizedUnitName(String symbol, {String? locale}) String?
Returns a localized full name for a canonical unit symbol for the given locale (base-locale fallback). Returns null when no mapping is found.
localizedUnitSingularName(String symbol, {String? locale, bool bits = false}) String?
Returns a singular name for the given unit symbol if available for the locale. Falls back to plural name when no singular registered. Returns the singular form for a unit symbol in locale when available. Falls back to plural when no singular is registered.
registerLocalizedSingularNames(String locale, Map<String, String> singular) → void
Register singular forms for full-form names per locale (optional). keys must be canonical plural names from localizedUnitName (e.g., 'kilobytes'), values singular (e.g., 'kilobyte'). Registers singular forms for full-form names per locale. Keys must be canonical plural names returned by localizedUnitName (e.g., 'kilobytes').
registerLocalizedSynonyms(String locale, Map<String, String> synonyms) → void
Register per-locale synonyms that map localized words back to canonical symbols. Example (fr): { 'octet': 'B', 'octets': 'B', 'kilooctets': 'KB', 'ko': 'KB' } Registers per-locale synonyms mapping localized words back to canonical symbols, used during parsing (e.g., 'octets' -> 'B'). Keys are matched case-insensitively.
registerLocalizedUnitNames(String locale, Map<String, String> names) → void
Registers custom localized full names for a locale. Keys must be canonical symbols (e.g., KB, MiB, kb).
resolveLocalizedUnitSymbol(String token, {String? locale}) String?
Resolve a localized token (possibly a full word or synonym) back to a canonical unit symbol. This is used by parseLocalized helpers. Returns null if no mapping is found. Resolves a localized token (full word or synonym) back to a canonical unit symbol. Returns null if no mapping is found.

Typedefs

NumberFormatFactory = NumberFormat Function(String locale)
Factory for constructing an NumberFormat given a locale string.