VPlatformFile class
VPlatformFileSource
is a class that helps to handle files in different ways.
It accepts a file from different sources, such as a user URL, a file path, or bytes, and provides various utility methods for handling these files.
This class requires some fields to be initialized:
Optional fields include:
userUrl
: URL for the file if it comes from a web sourcefilePath
: Path for the file if it is stored locally- bytes: Byte data for the file if it comes as byte array
- baseUrl: Base URL if the file is from a web source that requires a base URL
- mimeType: Mime type of the file
You can use one of the following constructors based on the source of the file:
VPlatformFileSource.fromBytes
: If you have a file in the form of bytesVPlatformFileSource.fromPath
: If you have a file pathVPlatformFileSource.fromUrl
: If you have a file URLVPlatformFileSource.fromAssets
: If you have a file in assets
This class also provides utility getters and methods like:
- getMimeType: To get the mime type of the file
- isFromPath: To check if the file comes from a path
- isFromAssets: To check if the file comes from assets
- isFromBytes: To check if the file comes from bytes
- isFromUrl: To check if the file comes from a URL
- isNotUrl: To check if the file does not come from a URL
- readableSize: To get the file size in a human-readable string
- getBytes: To get the bytes of the file
- uint8List: To get the Uint8List of the file bytes
- toMap: To get the map representation of the file
- toString: To get the string representation of the file
Constructors
- VPlatformFile.fromAssets({int fileSize = 0, required String assetsPath})
-
VPlatformFile.fromBytes({required String name, required List<
int> bytes}) -
VPlatformFile.fromMap(Map<
String, dynamic> map) -
factory
- VPlatformFile.fromPath({required String fileLocalPath})
- VPlatformFile.fromUrl({int fileSize = 0, required String url, String? baseUrl})
Properties
- assetsPath ↔ String?
-
getter/setter pair
- baseUrl ↔ String?
-
getter/setter pair
-
bytes
↔ List<
int> ? -
getter/setter pair
- extension → String
-
no setter
- fileHash ↔ String
-
getter/setter pair
- fileLocalPath ↔ String?
-
getter/setter pair
- fileSize ↔ int
-
getter/setter pair
-
getBytes
→ List<
int> -
no setter
- getMediaType → VSupportedFilesType
-
no setter
- getMimeType → String?
-
no setter
- getUrlPath → String
-
this used for cache key
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- isContentFile ↔ bool
-
getter/setter pair
- isContentImage ↔ bool
-
getter/setter pair
- isContentVideo ↔ bool
-
getter/setter pair
- isFromAssets → bool
-
no setter
- isFromBytes → bool
-
no setter
- isFromPath → bool
-
no setter
- isFromUrl → bool
-
no setter
- isNotUrl → bool
-
no setter
- mediaType ↔ VSupportedFilesType
-
getter/setter pair
- mimeType ↔ String?
-
getter/setter pair
- name ↔ String
-
getter/setter pair
- readableSize → String
-
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- uint8List → Uint8List
-
no setter
- url → String?
-
no setter
- urlPath ↔ String?
-
getter/setter pair
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toMap(
) → Map< String, dynamic> -
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited