MethodChannelXCameraBackend class
Production XCameraBackend. Hand-rolled MethodChannel +
EventChannel — matches the rest of package:ux, no pigeon.
- Implemented types
Constructors
- MethodChannelXCameraBackend()
-
Creates a backend bound to the
ux/camerachannels.
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
-
audioPermissionGranted(
) → Future< bool> -
True iff the user has granted microphone access. Cheap; safe to
re-poll on app foregrounding to detect grants made via Settings.
override
-
availableCameras(
) → Future< List< XCameraDescription> > -
Enumerate camera devices. The result is stable for the lifetime
of the process.
override
-
cameraPermissionGranted(
) → Future< bool> -
Reads camera authorization without a session, prompt or microphone access.
override
-
create(
{required String cameraId, required bool enableAudio, required XResolutionPreset preset}) → Future< XCameraCreateResult> -
Allocate a native camera instance bound to
cameraId. Returns the handle (for subsequent calls), the FlutterTexture id (for the preview widget), and the sensor-natural-orientation preview size.override -
disposeInstance(
int handle) → Future< void> -
Tear down the session. Cancels any in-flight recording, releases
the camera device and the audio claim. Safe to call repeatedly;
no-op once disposed.
override
-
events(
int handle) → Stream< XCameraEvent> -
Live event stream for
handle: device-orientation changes, session errors, interrupted/resumed lifecycle pings. The controller subscribes during initialize and unsubscribes on disposeInstance.override -
initialize(
int handle) → Future< void> -
Start the session. Native side resolves camera + audio permissions
before the future completes. Throws
XCameraException("permission_denied") on denial.
override
-
lockCaptureOrientation(
int handle, DeviceOrientation orientation) → Future< void> -
Pin the preview's connection orientation. Used today only to lock
the preview to portrait so it never appears stretched/rotated.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
openSettings(
) → Future< void> -
Opens camera privacy Settings on macOS and app Settings on mobile.
Authorization changes require a foreground query.
override
-
requestAudioPermission(
) → Future< bool> -
Attempt to grant mic access. Shows the in-app system prompt when
the OS is willing to surface one (fresh install, or a first
denial that's still retryable on Android); on permanent denial,
deep-links into Settings and resolves to
false. Returns the post-call granted state. Avoids the fresh-install trap where the mic entry isn't in the Privacy pane untilrequestAccesshas fired at least once.override -
requestCameraPermission(
) → Future< bool> -
Requests camera access or opens Settings if another prompt is unavailable.
Returns current authorization; Settings changes require a foreground query.
override
-
setDescription(
int handle, String cameraId) → Future< ({int previewRotationQuarterTurns, Size previewSize})> -
Swap to a different camera mid-session. Resets the lock and clears
any pending recording. Returns the new preview size and rotation;
the size may again be
Size.zeroinitially on Android, with a follow-up XCameraPreviewSizeChanged event.override -
setFlashMode(
int handle, XFlashMode mode) → Future< void> -
Set the flash mode used for the next takePicture. On front cameras
without a screen-flash fallback the backend silently no-ops; the
caller is responsible for not offering flash UI there.
override
-
startVideoRecording(
int handle, DeviceOrientation snapshotOrientation) → Future< void> -
Begin recording video.
snapshotOrientationis baked into the writer track's transform — the file plays back rotated even if the device returns to portrait mid-recording.override -
stopVideoRecording(
int handle) → Future< XFile> -
Stop recording and return the resulting MP4 on disk.
override
-
takePicture(
int handle, DeviceOrientation snapshotOrientation) → Future< XFile> -
Take a still photo.
snapshotOrientationis applied to the photo connection just before capture so the file's EXIF orientation matches how the user was holding the device.override -
toString(
) → String -
A string representation of this object.
inherited
-
unlockCaptureOrientation(
int handle) → Future< void> -
Release the orientation lock — the preview falls back to following
physical device orientation. Unused by the chat composer; kept for
API symmetry.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited