xyz_utils_non_web
library
Classes
-
AnsiStyle
-
A class that provides a way to style strings with ANSI escape codes.
-
AnyPlatform
-
-
Callbacks<T1, T2 extends TCallback<T1>>
-
Provides a flexible and easy way to manage and execute a set of callbacks.
-
Debouncer
-
Usage Example:
-
DebugLog
-
A container for debug logs.
-
DisposableValue<T>
-
Manages disposal of DisposableValue instances by tracking values in a map,
with disposal and check methods.
-
DurationFormattedEnglish
-
A class that formats a Duration into a human-readable string.
-
FirestoreTimestamp
-
A Timestamp represents a point in time independent of any time zone or calendar,
represented as seconds and fractions of seconds at nanosecond resolution in UTC
Epoch time. It is encoded using the Proleptic Gregorian Calendar which extends
the Gregorian calendar backwards to year one. It is encoded assuming all minutes
are 60 seconds long, i.e. leap seconds are 'smeared' so that no leap second table
is needed for interpretation. Range is from 0001-01-01T00:00:00Z to
9999-12-31T23:59:59.999999999Z. By restricting to that range, we ensure that we
can convert to and from RFC 3339 date strings.
-
FunctionQueue
-
A queue that executes functions in order, one at a time.
-
Here
-
A method to log a message to the console with the file, scope, line and
column number passed in as context.
-
HttpService
-
A service for making HTTP requests.
-
LocationUtils
-
-
NotificationTopic
-
A method to help manage blocking and unblocking of notification topics for
Firebase Cloud Messaging or similar services.
-
ObjectPostDestructionChecker
-
Used to check when an object got destructed.
-
PostDestructionChecker
-
Used to check when an object got destructed.
-
Rec
-
A record of a location in the code.
-
RecOptions
-
-
ReplacePatternsSettings
-
-
ScreenCalculator
-
Calculates the size, orientation and aspect ratio of a screen.
-
ScreenSize
-
Represents the size of a screen.
-
Version
-
A version class that can be used to compare versions.
Extensions
-
BodyJsonOnResponseExtension
on Response
-
-
CalculateBestCentereOnLocationPackageExtension
on LocationUtils
-
-
CalculateGeometricCentereOnLocationPackageExtension
on LocationUtils
-
-
CalculateHavershire3DDistanceOnLocationPackageExtension
on LocationUtils
-
-
CalculateZoomToFitOnLocationPackageExtension
on LocationUtils
-
-
CalculatorOnScreenSizeExtension
on ScreenSize
-
-
ConvertOnStringCaseTypeExtension
on StringCaseType
-
-
FirstWhereOrNullOnIterableExtension
on Iterable<T>
-
-
FirstWhereOrNullOnListExtension
on List<T>
-
-
FirstWhereOrNullOnMapExtension
on Map<K, V>
-
-
FirstWhereOrNullOnSetExtension
on Set<T>
-
-
GenericTypeOnIterableExtension
on Iterable<T>
-
-
GenericTypeOnMapExtension
on Map<K, V>
-
-
JoinWithLastSeparatorOnIterableExtension
on Iterable
-
-
LNullIfEmptyOnListExtension
on List<T>
-
-
MapIOnIterableExtension
on Iterable<A>
-
-
MapIOnListExtension
on List<A>
-
-
MapIOnMapExtension
on Map<A1, A2>
-
-
MapIOnSetExtension
on Set<A>
-
-
MapKeysAndValyesOnMapExtension
on Map<K1, V1>
-
-
MapWithDefaultOnMapExtension
on Map<K, V>
-
-
MaybeAddToIterableExtension
on Iterable<T>
-
-
MaybeAddToListExtension
on List<T>
-
-
MaybeAddToMapExtension
on Map<T1, T2>
-
-
MaybeAddToSetExtension
on Set<T>
-
-
MiscOnStringExtension
on String
-
-
NonNullKeysOnMapExtension
on Map<K?, V>
-
-
NonNullsOnMapExtension
on Map<K?, V?>
-
-
NonNullValuesOnMapExtension
on Map<K, V?>
-
-
NullIfEmptyOnIterableExtension
on Iterable<T>
-
-
NullIfEmptyOnMapExtension
on Map<T1, T2>
-
-
NullIfEmptyOnQueueExtension
on Queue<T>
-
-
NullIfEmptyOnSetExtension
on Set<T>
-
-
NullIfEmptyOnStringExtension
on String
-
-
ParseDurationOnStringExtension
on String
-
-
ReplaceAllPatternsOnStringExtension
on String
-
-
ReplaceDataOnStringExtension
on String
-
-
ResponseHandleExceptionsOnFutureExtension
on Future<Response>
-
-
SecondToNinthElementOnIterableExtension
on Iterable<T>
-
-
SetNestedValueOnMapExtension
on Map
-
-
StringCaseConversionsOnStringExtension
on String
-
-
TakeLastOnIterableExtension
on Iterable<String>
-
-
ToFutureOnStreamExtension
on Stream<T>
-
-
ToMapOnIterableExtension
on Iterable<MapEntry<K, V>>
-
-
ToTrimmedOrNullOnObjectExtension
on Object
-
-
TryMergeOnIterableExtension
on Iterable<Iterable<T>?>
-
-
TryOrNullOnFunctionExtension
on Function
-
-
TryReduceOnIterableExtension
on Iterable<T>
-
-
UniqueOnMapEntryIterableExtension
on Iterable<MapEntry<K, V>>
-
-
UtilsOnDateTimeExtension
on DateTime
-
-
ValueOfOnEnumExtension
on Iterable<T>
-
-
WithAnsiStyleOnStringExtension
on String
-
Properties
-
let
→ T? Function<T>(dynamic input)
-
Alias for letOrNull.
final
-
letAs
→ T? Function<T>(dynamic input)
-
Alias for letAsOrNull.
final
-
letAsJMap
→ Map<String, dynamic>? Function(dynamic input)
-
Alias for letAsJMapOrNull.
final
-
letBool
→ bool? Function(dynamic input)
-
Alias for letBoolOrNull.
final
-
letDateTime
→ DateTime? Function(dynamic input)
-
Alias for letDateTimeOrNull.
final
-
letDouble
→ double? Function(dynamic input)
-
Alias for letDoubleOrNull.
final
-
letDuration
→ Duration? Function(dynamic input)
-
Alias for letDurationOrNull.
final
-
letFirestoreTimestamp
→ FirestoreTimestamp? Function(dynamic input)
-
Alias for letFirestoreTimestampOrNull.
final
-
letInt
→ int? Function(dynamic input)
-
Alias for letIntOrNull.
final
-
letIterable
→ Iterable<T>? Function<T>(dynamic input, {bool filterNulls = false, dynamic nullFallback})
-
Alias for letIterableOrNull.
final
-
letList
→ List<T>? Function<T>(dynamic input, {bool filterNulls = false, T? nullFallback})
-
Alias for letListOrNull.
final
-
letMap
→ Map<K, V>? Function<K, V>(dynamic input, {bool filterNulls = false, dynamic nullFallback})
-
Alias for letMapOrNull.
final
-
letNum
→ num? Function(dynamic input)
-
Alias for letNumOrNull.
final
-
letSet
→ Set<T>? Function<T>(dynamic input, {bool filterNulls = false, T? nullFallback})
-
Alias for letSetOrNull.
final
-
letUri
→ Uri? Function(dynamic input)
-
Alias for letUriOrNull.
final
-
minMobileAspectRatio
→ double
-
The smallest of the following common aspect ratios for mobile phones (4.0 / 3.0)
no setter
Functions
-
castAsOrNull<T>(dynamic input)
→ T?
-
Similar to letAsOrNull, but uses a try-catch block internally.
-
clearFile(String filePath)
→ Future<void>
-
Clears the contents of the file located at
filePath
.
-
combinedOrderedStringId(List<String> ids)
→ String
-
Generates an ordered ID from a list of unordered IDs, that can be
used to identify the list of IDs.
-
combinePathSets(List<Set<String>> pathSets)
→ Set<String>
-
Combines multiple
pathSets
into a single set, returning all possible
combinations.
-
convertToStringCaseType(String value, StringCaseType? stringCaseType)
→ String
-
Converts a string to a specific case type.
-
csvToMap(String input)
→ Map<int, List<String>>
-
Converts a CSV string to a map.
-
dayAgo(DateTime date, String tr(String), String locale)
→ String
-
Returns a string representing the day ago from the given date. Requires a
translation function
tr
to translate the string into the given locale
.
-
debugLog(dynamic message, [Symbol? group, Rec? rec])
→ void
-
⚪️ Logs a message to the console.
-
debugLogAlert(dynamic message, [Symbol? group, Rec? rec])
→ void
-
🟠 Logs an alert message to the console.
-
debugLogError(dynamic message, [Symbol? group, Rec? rec])
→ void
-
🔴 Logs an error message to the console.
-
debugLogIgnore(dynamic message, [Symbol? group, Rec? rec])
→ void
-
🟡 Logs an ignore message to the console.
-
debugLogInfo(dynamic message, [Symbol? group, Rec? rec])
→ void
-
🟣 Logs an info message to the console.
-
debugLogMessage(dynamic message, [Symbol? group, Rec? rec])
→ void
-
🟤 Logs a debug message to the console.
-
debugLogStart(dynamic message, [Symbol? group, Rec? rec])
→ void
-
🔵 Logs a start message to the console.
-
debugLogStop(dynamic message, [Symbol? group, Rec? rec])
→ void
-
⚫ Logs a stop message to the console.
-
debugLogSuccess(dynamic message, [Symbol? group, Rec? rec])
→ void
-
🟢 Logs a success message to the console.
-
deleteFile(String filePath)
→ Future<void>
-
Deletes the file located at
filePath
.
-
expandFlattenedJson(Map input, {String separator = '.'})
→ Map
-
Expands a flattened JSON map, e.g.
{'a.b': 1}
to {a.b: 1, b: 1}
.
-
expandJson(Map input, {String separator = '.'})
→ Map
-
Expands a Json map, e.g.
{'a': {'b': 1}}
to {a.b: 1, b: 1}
.
-
Extracts nested scopes from a
source
string based on opening
and
closing
delimiters.
-
fileExists(String filePath)
→ Future<bool>
-
Returns
true
if the file located at filePath
exists.
-
findFileByName(String fileName, String directoryPath)
→ Future<File?>
-
Finds a file with the given
fileName
in the directory located at
directoryPath
. Returns null
if the directory does not exist or if the
-
flattenJson(Map input, {String separator = '.'})
→ Map
-
Flattens a nested JSON object into a single-level map with string keys.
-
getBaseName(String path)
→ String
-
Returns the base name of a given file
path
.
-
getDesktopPath()
→ String
-
Gets the current Operating System's Desktop path.
-
getDirPath(String path)
→ String
-
Returns the directory path of a given file
path
.
-
getFileNameWithoutExtension(String filePath)
→ String
-
Converts the given
filePath
to a consistent, local path format.
-
getFirstDate(Iterable<DateTime>? dates)
→ DateTime?
-
Returns the first date in the list of dates.
-
getLastDate(Iterable<DateTime>? dates)
→ DateTime?
-
Returns the last date in the list of dates.
-
getPackageLibPath(String package)
→ Future<String?>
-
Returns the path of the
lib
directory of package
or null
if the
package is not found.
-
getSetDifference<T>(Set<T> before, Set<T> after)
→ Set<T>
-
Returns the difference between two sets.
-
isMatchingFileName(String filePath, String begType, String endType)
→ ({String fileName, bool status})
-
Checks if the file name extracted from
filePath
matches the specified
beginning type begType
and ending type endType
.
-
isNullable<T>()
→ bool
-
Returns true if
T
is nullable.
-
isPrivateFileName(String filePath)
→ bool
-
Checks if the provided
filePath
is a private file (starts with an
underscore).
-
isSameDay(DateTime date1, DateTime date2)
→ bool
-
Checks if two dates are on the same day.
-
isSameMonth(DateTime date1, DateTime date2)
→ bool
-
Checks if two dates are on the same month.
-
isSameWeek(DateTime date1, DateTime date2)
→ bool
-
Checks if two dates are on the same week.
-
letAsJMapOrNull(dynamic input)
→ Map<String, dynamic>?
-
Let's you cast
input
to a Map<String, dynamic> type if possible, or
returns null if the cast cannot be performed.
-
letAsOrNull<T>(dynamic input)
→ T?
-
Let's you cast
input
to a T
type if possible, or returns null if the
cast cannot be performed.
-
letBoolOrNull(dynamic input)
→ bool?
-
Let's you convert
input
to a bool type if possible, or returns null if
the conversion cannot be performed.
-
letDateTimeOrNull(dynamic input)
→ DateTime?
-
Let's you convert
input
to a DateTime type if possible, or returns null
if the conversion cannot be performed.
-
letDoubleOrNull(dynamic input)
→ double?
-
Let's you convert
input
to a double type if possible, or returns null if
the conversion cannot be performed.
-
letDurationOrNull(dynamic input)
→ Duration?
-
Let's you convert
input
to a Duration type if possible, or returns null
if the conversion cannot be performed.
-
letFirestoreTimestampOrNull(dynamic input)
→ FirestoreTimestamp?
-
Let's you convert
input
to a FirestoreTimestamp type if possible, or
returns null if the conversion cannot be performed.
-
letIntOrNull(dynamic input)
→ int?
-
Let's you convert
input
to an int type if possible, or returns null if
the conversion cannot be performed.
-
letIterableFromCommaSeparatedString(String input)
→ Iterable<String>
-
Let's you convert
input
to an Iterable of Strings if possible, or returns
null if the conversion cannot be performed.
-
letIterableOrNull<T>(dynamic input, {bool filterNulls = false, dynamic nullFallback})
→ Iterable<T>?
-
Let's you convert
input
to an Iterable type if possible, or returns null
if the conversion cannot be performed.
-
letListOrNull<T>(dynamic input, {bool filterNulls = false, T? nullFallback})
→ List<T>?
-
Let's you convert
input
to a List type if possible, or returns null if
the conversion cannot be performed.
-
letMapOrNull<K, V>(dynamic input, {bool filterNulls = false, dynamic nullFallback})
→ Map<K, V>?
-
Let's you convert
input
to a Map type if possible, or returns null if
the conversion cannot be performed.
-
letNumOrNull(dynamic input)
→ num?
-
Let's you convert
input
to a num type if possible, or returns null if the
conversion cannot be performed.
-
letOrNull<T>(dynamic input)
→ T?
-
Let's you convert
input
to a T
type if possible, or returns null if the
conversion cannot be performed.
-
letSetOrNull<T>(dynamic input, {bool filterNulls = false, T? nullFallback})
→ Set<T>?
-
Let's you convert
input
to a Set type if possible, or returns null if
the conversion cannot be performed.
-
letUriOrNull(dynamic input)
→ Uri?
-
Let's you convert
input
to a Uri type if possible, or returns null if
the conversion cannot be performed.
-
listFilePaths(String dirPath, {bool recursive = true})
→ Future<List<String>?>
-
Lists the file paths of the files in the directory located at
dirPath
.
Set recursive
to true
to list the file paths of the files in
the sub-directories as well.
-
mapToCsv(Map input)
→ String
-
Converts a map to a CSV string.
-
mapToJson<T1, T2>(Map<T1, T2> input, {Set<Type> typesAllowed = const {}, String? keyConverter(dynamic)?})
→ Json
-
Converts a map to a Json map by recursively converting its keys and values
to Json compatible types.
-
matchesAnyExtension(String filePath, Set<String> extensions, {bool caseSensitive = true})
→ bool
-
Checks if the provided
filePath
matches any of the specified extensions
.
-
matchesAnyPathPattern(String path, Set<String> pathPatterns)
→ bool
-
Checks if the provided
path
matches any of the specified pathPatterns
.
-
maybeAddToIterable<T>(Iterable<T>? source, Iterable<T>? add)
→ Iterable<T>?
-
Adds
add
to source
if both are not null.
-
maybeAddToList<T>(List<T>? source, List<T>? add)
→ List<T>?
-
Adds
add
to source
if both are not null.
-
maybeAddToMap<T1, T2>(Map<T1, T2>? source, Map<T1, T2>? add)
→ Map<T1, T2>?
-
Adds
add
to source
if both are not null.
-
maybeAddToSet<T>(Set<T>? source, Set<T>? add)
→ Set<T>?
-
Adds
add
to source
if both are not null.
-
mergeDataDeep(dynamic a, dynamic b, [dynamic elseFilter(dynamic)?])
→ dynamic
-
Merges two data structures deeply.
-
mergeDataDeepIncludeCallsToJson(dynamic a, dynamic b)
→ dynamic
-
Merges two data structures deeply and tries to perform toJson on objects.
-
mergeDataDeepIncludeCallsToMap(dynamic a, dynamic b)
→ dynamic
-
Merges two data structures deeply and tries to perform toMap on objects.
-
mergeIterables(dynamic a, dynamic b)
→ Iterable
-
Merges two iterables into one iterable.
-
mergeListsSetsOrQueues(Iterable a, Iterable b)
→ Iterable
-
Merges two Iterables into one. Supported Iterable types are List, Set, and
Queue.
-
mergeMapsDeep<K, V>(List<Map<K, V>> maps)
→ Map<K, V>
-
Merges all
maps
deeply.
-
nullFilteredList<T>(Iterable input)
→ List<T>
-
Converts
input
to a List with non-null elements if T
is non-null.
-
nullFilteredMap<K, V>(Map input)
→ Map<K, V>
-
Converts
input
to a Map with non-null keys and values if K
and V
are
non-null.
-
nullFilteredSet<T>(Iterable input)
→ Set<T>
-
Converts
input
to a Set with non-null elements if T
is non-null.
-
nullIfEmpty<T>(T value)
→ T?
-
Returns null if
value
is empty, otherwise returns value
.
-
pathContainsComponent(String path, Set<String> components)
→ bool
-
Checks if the provided
path
contains any of the specified components
.
This operation is case-insensitive.
-
pollingStream<T>(Future<T> callback(), Duration interval)
→ Stream<T>
-
Creates a Stream that polls a
callback
at a specified interval
.
-
printBlack(Object? message)
→ void
-
Prints the message in black using AnsiStyle.
-
printBlue(Object? message)
→ void
-
Prints the message in blue using AnsiStyle.
-
printCyan(Object? message)
→ void
-
Prints the message in cyan using AnsiStyle.
-
printGreen(Object? message)
→ void
-
Prints the message in green using AnsiStyle.
-
printLightBlack(Object? message)
→ void
-
Prints the message in light black using AnsiStyle.
-
printLightBlue(Object? message)
→ void
-
Prints the message in light blue using AnsiStyle.
-
printLightCyan(Object? message)
→ void
-
Prints the message in light cyan using AnsiStyle.
-
printLightGreen(Object? message)
→ void
-
Prints the message in light green using AnsiStyle.
-
printLightPurple(Object? message)
→ void
-
Prints the message in light purple using AnsiStyle.
-
printLightRed(Object? message)
→ void
-
Prints the message in light red using AnsiStyle.
-
printLightWhite(Object? message)
→ void
-
Prints the message in light white using AnsiStyle.
-
printLightYellow(Object? message)
→ void
-
Prints the message in light yellow using AnsiStyle.
-
printPurple(Object? message)
→ void
-
Prints the message in purple using AnsiStyle.
-
printRed(Object? message)
→ void
-
Prints the message in red using AnsiStyle.
-
printWhite(Object? message)
→ void
-
Prints the message in white using AnsiStyle.
-
printYellow(Object? message)
→ void
-
Prints the message in yellow using AnsiStyle.
-
readFile(String filePath)
→ Future<String?>
-
Reads the contents of the file located at
filePath
as a String.
-
readFileAsLines(String filePath)
→ Future<List<String>?>
-
Reads the contents of the file located at
filePath
as a list of lines.
-
recursiveReplace(Map input, {ReplacePatternsSettings settings = const ReplacePatternsSettings()})
→ Map
-
Performs recursive replacement of string values within a map using
placeholders defined by the map's own key-value pairs. It supports nested
structures (maps and lists) and replaces placeholders in strings with
corresponding values.
-
replaceData(String input, Map<Pattern, dynamic> data)
→ String
-
Replaces the keys of
data
in input
with the corresponding values.
-
replacePatterns(String input, Map data, {ReplacePatternsSettings settings = const ReplacePatternsSettings()})
→ String
-
Replaces placeholders in a string with corresponding values from a provided
map, supporting default values and custom delimiters.
-
sortDates(List<DateTime> dates)
→ List<DateTime>
-
Checks if two dates are on the same year.
-
streamToFuture<T>(Stream<T> stream)
→ Future<T>
-
Waits for the first value from the Stream and returns it as a Future.
-
timeAgo(DateTime date, String tr(String), String locale)
→ String
-
Returns a string representing the time ago from the given date. Requires a
translation function
tr
to translate the string into the given locale
.
-
toLocalSystemPathFormat(String path)
→ String
-
Replaces all forward slashes in
path
with the local path separator.
-
toUnixSystemPathFormat(String path)
→ String
-
Replaces all backslashes in
path
with forward slashes.
-
toWindowsSystemPathFormat(String path)
→ String
-
Replaces all forward slashes in
path
with backslashes.
-
trimmedOrNull(Object? input)
→ String?
-
Converts the input to a string if it's not null and trims it or returns
null
if the result is empty.
-
tryToJson(dynamic object)
→ dynamic
-
Tries to convert an object to a json map by calling its toJson method if it
exists.
-
tryToMap(dynamic object)
→ dynamic
-
Tries to convert an object to a map by calling its toMap method if it exists.
-
typeEquality<T1, T2>()
→ bool
-
Returns true if
T1
and T2
are the same type.
-
uniqueEntries<K, V>(Iterable<MapEntry<K, V>> entries)
→ List<MapEntry<K, V>>
-
-
uniqueKeys<K, V>(Iterable<MapEntry<K, V>> entries)
→ List<MapEntry<K, V>>
-
-
uniqueValues<K, V>(Iterable<MapEntry<K, V>> entries)
→ List<MapEntry<K, V>>
-
-
writeFile(String filePath, String content, {bool append = false})
→ Future<void>
-
Writes the given
content
to the file located at filePath
. Set append
to true
to append the content
to the file instead of overwriting it.