utils library

Functions

areFSEntitiesExist(List<String> paths) String?
Check if given File or Directory exists at the given paths, if not returns the failed FileSystemEntity path
createDirIfNotExist(String dirPath) Future<Directory>
Creates Directory in the given dirPath if not exists
createFileIfNotExist(String filePath) Future<File>
Creates File in the given filePath if not exists
createResizedImage(int iconSize, Image image, {Color? backgroundColor}) → Image
decodeImageFile(String filePath) Future<Image>
Decodes an image file at filePath.
encodePngOptimized(Image image, {required bool optimize}) List<int>
PNG encoder honoring the optimize_png opt-in (upstream #139 / #199). When optimize is true, the image package's max-compression level (9) is used; otherwise its default (level 6) preserves the existing fast generate behavior. Lossless either way.
flavorConfigFile(String flavor) String
generateError(Exception e, String? error) String
imageHasAlphaPixel(Image image) bool
True if the decoded image has at least one non-opaque pixel. Short-circuits on the first match. Used by doctor / strict mode for the iOS App Store alpha-rejection rule (upstream #172).
isHexColorLiteral(String value) bool
True if the value is a hex color literal (any of the forms above).
isNonSquare(Image image) bool
True if image is not square (width != height). Used by doctor / strict mode to warn about non-square sources, which the resize step silently squishes today (upstream #214).
letterBoxToSquare(Image image, Color backgroundColor) → Image
Pads a non-square image onto a square canvas of side max(w, h) filled with backgroundColor and centers the source on it. Returns image unchanged when it is already square (idempotent — safe to call multiple times, e.g. by both a platform writer that pre-pads and a downstream createResizedImage call that also has a background color).
parseHexColor(String value) → ColorUint8
Parses a #RRGGBB or #RRGGBBAA (or unprefixed) hex string into a ColorUint8. Throws InvalidConfigException for malformed input.
prettifyJsonEncode(Object? map) String
Returns a prettified json string