HatangAttachmentPicker class
Picks files for the chat and prepares them for upload.
Photos are converted to JPEG when the gateway could not show them (HEIC/HEIF, the iPhone camera default) and large ones are scaled to 2048 px, so a 12 MP photo leaves the phone at a few hundred KB instead of several MB. Where the platform cannot re-encode (Linux, Windows, the web) the original goes out as is.
Permissions stay with the host app: iOS needs NSPhotoLibraryUsageDescription
and NSCameraUsageDescription in Info.plist.
Constructors
- HatangAttachmentPicker({ImagePicker? imagePicker, HatangFilePick? pickFile})
-
Creates a picker.
pickFileenables "File"; without it the visitor can send photos only. The image picker is injectable for tests.
Properties
- canPickFile → bool
-
"File" can be offered (the app passed a file picker).
no setter
- 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
-
pick(
HatangAttachmentSource source) → Future< UploadSource?> -
Lets the visitor pick from
source; null when they cancel. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- cameraAvailable → bool
-
The camera can be offered here (phones).
no setter
Static Methods
-
prepare(
List< int> bytes, String name, String? mimeType) → Future<UploadSource> - Turns picked bytes into an UploadSource: resolves the MIME type from the name when missing, converts HEIC/HEIF to JPEG and shrinks big photos.
Constants
- jpegQuality → const int
- JPEG quality after preparation.
- maxImageSide → const int
- Longest side of a photo after preparation.
- recompressAbove → const int
- Photos above this size are re-encoded even when already JPEG.