TwkFile class

Represents a file (image, video, document) from the Tawakkalna SDK.

This model handles both base64-encoded file data and its binary representation. Files can be obtained from camera, gallery, or file picker methods.

Example:

final photo = await twk.getCameraPhoto();
if (photo != null) {
  print('File: ${photo.fileName}');
  print('Type: ${photo.mimeType}');
  // Use photo.binary for raw bytes
  // Use photo.data for base64 string
}

Properties

binary → Uint8List
Binary representation of the file
final
data → String
TODO:(TWK-team): as per as support team, data here is not Base64-encoded Base64-encoded file data (without data URI prefix)
final
fileName → String
The file name
final
hashCode → int
The hash code for this object.
no setterinherited
mimeType → String
MIME type (e.g., "image/jpeg", "video/mp4", "application/pdf")
final
props → List<Object?>
The list of properties that will be used to determine whether two instances are equal.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
stringify → bool?
If set to true, the toString method will be overridden to output this instance's props.
no setterinherited
type → String
The file type (e.g., "image", "video", "document")
final

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

fromBase64String({required String type, required String mimeType, required String base64String, required String fileName}) → Future<TwkFile>
Creates a TwkFile from a base64-encoded string.
fromJson(Map<String, dynamic> map) → Future<TwkFile>
Creates a TwkFile from a JSON map.