camera library

Camera session, preview and effects.

Classes

MethodChannelXCameraBackend
Production XCameraBackend. Hand-rolled MethodChannel + EventChannel — matches the rest of package:ux, no pigeon.
MethodChannelXCameraEffectsBackend
Production XCameraEffectsBackend: ux/camera_effects for commands, ux/camera_effects/events for status.
XCameraBackend
Backend contract that XCameraController dispatches into. The default implementation calls into native code via the ux/camera / ux/camera/events channels; tests substitute their own (see package:ux/testing.dart's FakeXCameraBackend).
XCameraController
Owns one native camera session. Mirrors the surface package:camera's CameraController exposes today — every method signature the chat composer touches has a 1:1 here, plus the orientation snapshot is passed explicitly on capture calls.
XCameraCreateResult
The tuple returned by XCameraBackend.create — everything the controller needs to start serving the preview widget and routing subsequent calls.
XCameraDescription
Describes a camera device on the system. Returned by uxAvailableCameras; passed to XCameraController to bind a specific lens.
XCameraDeviceOrientationChanged
Fired when the device's physical orientation changes.
XCameraDiagnostic
Free-text diagnostic message from the native recorder. Routed by the controller to Log.tag('camera').i(...) so it lands in the log_server pipeline (~/banlu/tools/log_server/data/banlu.jsonl).
XCameraEffectsBackend
None / Blur / Dim on the outgoing camera track, applied natively on the frames the call already publishes.
XCameraEffectStatus
The effect on the track and the phase it is in.
XCameraEvent
Events pushed by the native side over ux/camera/events. Sealed — new variants land here as the contract grows.
XCameraPreview
Renders the live preview for controller into a Texture. Sizes itself to the parent — wrap in AspectRatio / FittedBox / Hero to control framing.
XCameraPreviewSizeChanged
Fired when the native side learns or revises the preview's pixel dimensions. Android emits this after CameraX's first SurfaceRequest resolves (the size isn't known at create time); iOS doesn't emit it (the size lands in the create result synchronously from device.activeFormat).
XCameraSessionError
Fired when the native session fails.
XCameraSessionInterrupted
Fired when the OS takes the camera away — a call, another app, or a system alert.
XCameraSessionResumed
Fired when the session gets the camera back after an interruption.
XCameraValue
Immutable snapshot of a XCameraController's state, broadcast to listeners. Updated on lifecycle transitions and on device- orientation events from the native side.

Enums

XCameraEffect
What the outgoing camera track carries behind the person.
XCameraEffectPhase
How far an effect has got.
XCameraLens
Which way a camera faces.
XFlashMode
Flash mode applied to the next still capture. Only the two values the chat composer actually uses today.
XResolutionPreset
Resolution preset for both photo and video. Single value today (high); the enum exists so future presets can land without breaking call sites.

Functions

uxAvailableCameras() → Future<List<XCameraDescription>>
Enumerate the cameras the platform exposes. Stable for the lifetime of the process; safe to cache the result.

Exceptions / Errors

XCameraEffectsException
Thrown by XCameraEffectsBackend when a command cannot be served.
XCameraException
Throws when a XCameraController call fails on the platform side. Maps from native FlutterError codes; see the table in ~/banlu/plans/ux_camera.md §error-model for the full set.