human_readable_formats library
Main entry point for the human_readable_formats library.
Classes
- HumanFormatter
- Fluent builder for configuring and formatting human-readable values.
Enums
- DurationTextStyle
- Defines the text style for the formatted duration.
- FileSizeStandard
- The standard for calculating file sizes.
Functions
-
humanizeAddress(
{String? street, String? city, String? state, String? postalCode, String? country}) → String - Formats address components.
-
humanizeAge(
DateTime birthDate, {DateTime? now}) → String - Formats age from birth date.
-
humanizeArea(
double squareMeters, {bool metric = true}) → String - Formats area in human-readable units.
-
humanizeAtomicMass(
double atomicMassUnits) → String - Formats atomic mass in appropriate units.
-
humanizeBandwidth(
num bitsPerSecond, {bool binary = false}) → String - Network and technical formatting utilities. Formats bandwidth in human-readable format (e.g., 1.5 Mbps).
-
humanizeBearing(
double degrees) → String - Formats bearing/direction.
-
humanizeBinary(
int number) → String - Formats a number as a binary string (e.g., 1010).
-
humanizeBoolean(
bool? value, {String positive = 'Yes', String negative = 'No', String? nullValue}) → String - Formats a boolean value into a human-readable string. Examples: 'Yes', 'No', 'Active', 'Inactive', 'Enabled', 'Disabled'
-
humanizeBoundingBox(
double north, double south, double east, double west) → String - Formats geographic bounding box.
-
humanizeCapacitance(
double farads) → String - Formats capacitance in appropriate units.
-
humanizeCertificateValidity(
DateTime notBefore, DateTime notAfter, {DateTime? now}) → String - Formats SSL/TLS certificate validity.
-
humanizeChemicalFormula(
String formula) → String - Formats chemical formulas with proper subscripts.
-
humanizeCompactNumber(
num number, {String? locale}) → String - Formats a number into a compact string (e.g., 1.2M, 5.6K).
-
humanizeCoordinates(
double latitude, double longitude, {int precision = 6}) → String - Geographic and location formatting utilities. Formats coordinates in decimal degrees.
-
humanizeCoordinatesDMS(
double latitude, double longitude) → String - Formats coordinates in degrees, minutes, seconds (DMS).
-
humanizeCountdown(
Duration duration) → String - Formats a duration as a countdown timer (HH:MM:SS).
-
humanizeCSV(
List< List< data, {String separator = ',', bool alignColumns = true}) → StringString> > - Formats CSV data with proper alignment.
-
humanizeCurrency(
num amount, {String symbol = '₹', String? locale}) → String - Formats a number as a currency string (e.g., ₹99).
-
humanizeCurrent(
double amperes) → String - Formats electric current in appropriate units.
-
humanizeDataRate(
num bytesPerSecond, {bool binary = false}) → String - Formats data transfer rate.
-
humanizeDateRange(
DateTime start, DateTime end) → String - Formats a date range in a human-readable way.
-
humanizeDecimal(
num number, {int decimalPlaces = 2}) → String - Formats a number with a specific number of decimal places.
-
humanizeDistance(
double lat1, double lon1, double lat2, double lon2, {bool metric = true}) → String - Calculates and formats distance between two coordinates.
-
humanizeDNSRecord(
String type, String value) → String - Formats DNS record type.
-
humanizeDuration(
Duration duration, {DurationTextStyle style = DurationTextStyle.short, int? maxUnits, String conjunction = ', ', String? locale}) → String - Formats a Duration into a human-readable string.
-
humanizeElevation(
double meters, {bool metric = true}) → String - Formats elevation/altitude.
-
humanizeEnergy(
double joules) → String - Formats energy in appropriate units.
-
humanizeEngineeringNotation(
double value, {int precision = 2}) → String - Formats engineering notation (exponents in multiples of 3).
-
humanizeFileSize(
int bytes, {int? decimalPlaces, FileSizeStandard? standard, String? locale}) → String - Formats a number of bytes into a human-readable file size string.
-
humanizeFraction(
double number, {int maxDenominator = 100}) → String - Formats a number as a fraction string (e.g., 3/4).
-
humanizeFrequency(
num hertz) → String - Formats frequency in human-readable format (e.g., 2.4 GHz).
-
humanizeFriendlyDate(
DateTime date, {DateTime? now, bool includeTime = false, String? locale}) → String - Formats a DateTime into a friendly, human-readable date and time string.
-
humanizeGeographicFeature(
String type, String name, {double? elevation}) → String - Formats geographic feature type.
-
humanizeGPSAccuracy(
double accuracyMeters) → String - Formats GPS accuracy.
-
humanizeHex(
int number, {bool uppercase = true}) → String - Formats a number as a hexadecimal string (e.g., FF).
-
humanizeHierarchy(
List< Map< items, {String idKey = 'id', String parentKey = 'parent', String nameKey = 'name', String indent = ' '}) → StringString, dynamic> > - Formats a list as a hierarchical structure.
-
humanizeHTTPStatus(
int statusCode) → String - Formats HTTP status code with description.
-
humanizeInductance(
double henries) → String - Formats inductance in appropriate units.
-
humanizeIPWithSubnet(
String ipAddress, int subnetMask) → String - Formats IP address with subnet mask.
-
humanizeJSON(
dynamic data, {int indent = 2, bool colorize = false}) → String - Formats JSON data with proper indentation and syntax highlighting.
-
humanizeKeyValuePairs(
Map< String, dynamic> data, {String separator = ': ', bool alignValues = true, int maxKeyWidth = 0}) → String - Formats key-value pairs with proper alignment.
-
humanizeLatency(
num milliseconds) → String - Formats latency/ping in human-readable format.
-
humanizeList(
List< String> items, {String conjunction = 'and', bool oxfordComma = true}) → String - Formats a list of items into a human-readable enumeration string. Examples: 'apples, bananas, and oranges', 'red and blue', 'just one'
-
humanizeListStructure(
List items, {String style = 'bullet', String indent = ' ', bool allowNesting = false}) → String - Formats a list with bullets or numbers.
-
humanizeMACAddress(
String macAddress) → String - Formats MAC address in standard format.
-
humanizeMagneticDeclination(
double declination) → String - Formats magnetic declination.
-
humanizeMagnitude(
num number, {int precision = 1}) → String - Formats a number with appropriate magnitude suffix (B, M, K, etc.).
-
humanizeMapScale(
double scale) → String - Formats map scale.
-
humanizeMathExpression(
String expression) → String - Formats mathematical expressions with proper superscripts and subscripts.
-
humanizeMatrix(
List< List> matrix, {bool showIndices = false, String numberFormat = 'auto', int precision = 2}) → String - Formats a matrix or 2D array.
-
humanizeMetric(
num number, {String unit = '', int precision = 2}) → String - Formats a number with appropriate unit prefix (metric).
-
humanizeNetworkInterface(
String name, bool isUp, {String? ipAddress}) → String - Formats network interface status.
-
humanizeNumber(
num number, {String separator = ','}) → String - Formats a number with thousands separators (e.g., 1,234,567).
-
humanizeOctal(
int number) → String - Formats a number as an octal string (e.g., 777).
-
humanizeOrdinal(
int number) → String - Formats an integer as an ordinal (e.g., 1st, 2nd, 3rd).
-
humanizePacketLoss(
double lossPercentage) → String - Formats packet loss percentage.
-
humanizePercentage(
num value, {bool isFraction = true, int? decimalPlaces, String? locale}) → String - Formats a number as a percentage string (e.g., '98.5%').
-
humanizePhysicalConstant(
String constantName, double value, String unit, {int precision = 6}) → String - Formats physical constants with proper units and precision.
-
humanizePopulationDensity(
int population, double areaKm2) → String - Formats population density.
-
humanizePort(
int port, {String? protocol}) → String - Formats port number with protocol.
-
humanizePower(
double watts) → String - Formats power in appropriate units.
-
humanizePreciseDuration(
Duration duration, {int maxUnits = 2}) → String - Formats a duration in a more precise way with multiple units.
-
humanizePressure(
double pascals) → String - Formats pressure in appropriate units.
-
humanizeProtocolVersion(
String protocol, String version) → String - Formats network protocol version.
-
humanizeRadioactivity(
double becquerels) → String - Formats radioactivity in appropriate units.
-
humanizeRatio(
num part, num total, {String? locale}) → String - Formats a ratio of two numbers into a human-readable string (e.g., '3 out of 4').
-
humanizeRegion(
String continent, String country, {String? state, String? city}) → String - Formats geographic region.
-
humanizeRelativeTime(
DateTime dateTime, {DateTime? now}) → String - Formats a DateTime into a relative time string (e.g., '5 minutes ago').
-
humanizeResistance(
double ohms) → String - Formats resistance in appropriate units.
-
humanizeRoman(
int number) → String - Formats a number as a Roman numeral (1-3999).
-
humanizeScientific(
num number, {int precision = 2}) → String - Formats a number as a scientific notation string (e.g., 1.23e+6).
-
humanizeScientificNotation(
double value, {int precision = 2, bool useUnicode = true}) → String - Formats scientific notation with proper exponent formatting.
-
humanizeSignalStrength(
int dbm) → String - Formats signal strength (dBm).
-
humanizeSpeed(
double metersPerSecond, {bool metric = true}) → String - Formats speed in various units.
-
humanizeSpeedTest(
{required num downloadSpeed, required num uploadSpeed, required num ping, bool binary = false}) → String - Formats network speed test results.
-
humanizeStopwatch(
Duration duration) → String - Formats a duration as a stopwatch timer (MM:SS.mmm).
-
humanizeTable(
List< String> headers, List<List< rows, {String borderStyle = 'ascii', bool showIndex = false}) → StringString> > - Formats a table with headers and data.
-
humanizeTemperature(
double kelvin, {String scale = 'auto'}) → String - Formats temperature in various scales.
-
humanizeTime12Hour(
DateTime dateTime) → String - Formats time in 12-hour format with AM/PM.
-
humanizeTime24Hour(
DateTime dateTime) → String - Formats time in 24-hour format.
-
humanizeTimeAgo(
DateTime dateTime, {DateTime? now}) → String - Formats a timestamp as time ago with more precision.
-
humanizeTimeUntil(
DateTime dateTime, {DateTime? now}) → String - Formats a timestamp as time until with more precision.
-
humanizeTimezone(
Duration offset) → String - Formats a timezone offset.
-
humanizeTimezoneFromCoordinates(
double longitude) → String - Formats timezone from coordinates (simplified).
-
humanizeTree(
Map< String, dynamic> tree, {String indent = ' ', String branchChar = '├── ', String lastBranchChar = '└── ', String verticalChar = '│ ', String spaceChar = ' '}) → String - Formats a tree structure.
-
humanizeUptime(
Duration uptime) → String - Formats uptime duration.
-
humanizeURL(
String url) → String - Formats URL with protocol highlighting.
-
humanizeUTM(
int zone, String band, double easting, double northing) → String - Formats UTM coordinates.
-
humanizeVoltage(
double volts) → String - Formats voltage in appropriate units.
-
humanizeWavelength(
double meters) → String - Formats wavelength with appropriate units.
-
humanizeWhat3Words(
String word1, String word2, String word3) → String - Formats what3words-style location (placeholder).
-
humanizeWiFiChannel(
int channel, double frequency) → String - Formats WiFi channel information.
-
humanizeXML(
String xml, {int indent = 2}) → String - Formats XML data with proper indentation.
-
isDateInRange(
DateTime date, DateTime start, DateTime end) → bool - Validates if a date is within a specific range.
-
isNumberInRange(
num value, num min, num max) → bool - Validates if a number is within a specific range.
-
isStringLengthInRange(
String value, int min, int max) → bool - Validates if a string length is within a specific range.
-
isValidBinary(
String input) → bool - Validates if a string represents a valid binary number.
-
isValidCanadianPostalCode(
String input) → bool - Validates if a string represents a valid Canadian postal code.
-
isValidColorHex(
String input) → bool - Validates if a string represents a valid color hex code.
-
isValidColorHSL(
String input) → bool - Validates if a string represents a valid HSL color.
-
isValidColorRGB(
String input) → bool - Validates if a string represents a valid RGB color.
-
isValidColorRGBA(
String input) → bool - Validates if a string represents a valid RGBA color.
-
isValidCompactNumber(
String input) → bool - Validates if a string represents a valid compact number format.
-
isValidCreditCard(
String input) → bool - Validates if a string represents a valid credit card number (Luhn algorithm).
-
isValidCurrency(
String input) → bool - Validates if a string represents a valid currency format.
-
isValidDuration(
String input) → bool - Validates if a string represents a valid duration format.
-
isValidEmail(
String input) → bool - Validates if a string represents a valid email address.
-
isValidFileSize(
String input) → bool - Validation utilities for human-readable formats. Validates if a string represents a valid file size format.
-
isValidFraction(
String input) → bool - Validates if a string represents a valid fraction.
-
isValidHex(
String input) → bool - Validates if a string represents a valid hexadecimal number.
-
isValidIPv4(
String input) → bool - Validates if a string represents a valid IP address (IPv4).
-
isValidIPv6(
String input) → bool - Validates if a string represents a valid IP address (IPv6).
-
isValidMACAddress(
String input) → bool - Validates if a string represents a valid MAC address.
-
isValidOctal(
String input) → bool - Validates if a string represents a valid octal number.
-
isValidPercentage(
String input) → bool - Validates if a string represents a valid percentage format.
-
isValidPhoneNumber(
String input) → bool - Validates if a string represents a valid phone number (basic format).
-
isValidRatio(
String input) → bool - Validates if a string represents a valid ratio format.
-
isValidRoman(
String input) → bool - Validates if a string represents a valid Roman numeral.
-
isValidScientific(
String input) → bool - Validates if a string represents a valid scientific notation.
-
isValidTime12Hour(
String input) → bool - Validates if a string represents a valid time format (12-hour).
-
isValidTime24Hour(
String input) → bool - Validates if a string represents a valid time format (24-hour).
-
isValidTimezone(
String input) → bool - Validates if a string represents a valid timezone offset.
-
isValidUKPostalCode(
String input) → bool - Validates if a string represents a valid postal code (UK).
-
isValidURL(
String input) → bool - Validates if a string represents a valid URL.
-
isValidUSZipCode(
String input) → bool - Validates if a string represents a valid postal code (US ZIP).
-
parseDuration(
String input) → Duration - Parses a human-readable duration string (e.g., '1h 30m', '2 days', '45s') into a Dart Duration. Supports both short (h, m, s) and long (hours, minutes, seconds, etc.) unit forms. Throws FormatException for invalid input.
-
parseHumanSize(
String input) → int - Parses a human-readable file size string (e.g., '1.5 GiB', '2 MB', '500 B') into bytes (int). Supports both SI (KB, MB, ...) and IEC (KiB, MiB, ...) units. Throws FormatException for invalid input.