ImageUtils class
ImageUtils class to store image related methods Used to convert image to base64, base64 to image, image to file etc This class methods can be used to convert the images
Example:
ImageUtils.base64ImageToImageFile("base64String");
ImageUtils.getImageFileFromAssets("assets/image.png");
ImageUtils.networkImageToBase64("https://example.com/image.png");
ImageUtils.localImageToBase64("path/to/image.png");
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
base64ImageToImageFile(
String encodedData, [String extensionName = 'png']) → Future< String> - base64ImageToImageFile method to convert base64 image to image file This method takes base64 image string and extension name as input This method returns the image file path This method uses base64.decode method to decode the image This method uses getApplicationDocumentsDirectory to get the application directory This method uses File class to create the file This method uses writeAsBytes method to write the image This method is an async method This method is a static method
-
getImageFileFromAssets(
String path) → Future< File> - getImageFileFromAssets method to get image file from assets This method takes image path as input This method returns the image file This method uses rootBundle to load the image This method uses getTemporaryDirectory to get the temporary directory This method uses File class to create the file This method uses writeAsBytes method to write the image This method is an async method This method is a static method
-
localImageToBase64(
String imagePath) → String? - localImageToBase64 method to convert local image to base64 This method takes image path as input This method returns the base64 image string This method uses File class to read the image This method uses base64Encode method to encode the image This method returns null if image is not found This method returns base64 image string if image is found This method is a static method
-
networkImageToBase64(
String imageUrl) → Future< String?> - networkImageToBase64 method to convert network image to base64 This method takes image url as input This method returns the base64 image string This method uses http package to get the image This method uses base64Encode method to encode the image This method returns null if image is not found This method returns base64 image string if image is found This method is an async method This method is a static method