Services

Camera

Camera service

Create or retrieve this service with page.camera(**properties). Ruflet reuses the registered service unless you supply a different id.

Example

preview = page.camera(
  preview_enabled: true,
  expand: true,
  on_state_change: ->(event) { puts "Camera: #{event.data}" },
  on_error: ->(event) { puts "Camera error: #{event.data}" }
)
page.add(preview)

Page accessor

  • page.camera(**props)

Properties

  • align — Alignment of the control within its parent.
  • animate_align — Animates alignment changes.
  • animate_margin — Animates margin changes.
  • animate_offset — Animates offset changes.
  • animate_opacity — Animates opacity changes.
  • animate_position — Animates position changes.
  • animate_rotation — Animates rotation changes.
  • animate_scale — Animates scale changes.
  • animate_size — Animates size changes.
  • aspect_ratio — Width-to-height ratio to maintain.
  • badge — Badge drawn on the corner of the control.
  • bottom — Bottom offset when positioned inside a stack.
  • col — Responsive column span (1-12) per breakpoint.
  • content — The single child control rendered inside this control.
  • data — Arbitrary value you can attach to the control and read back in handlers.
  • disabled — Disables interaction when true.
  • expand — Fills the available space along the parent's main axis when true.
  • expand_loose — Like expand, but only grows up to the child's natural size.
  • height — Fixed height in logical pixels.
  • key — Stable identity used to preserve state across rebuilds.
  • left — Left offset when positioned inside a stack.
  • margin — Outer spacing around the control.
  • offset — Translation offset applied to the control.
  • opacity — Opacity from 0.0 (transparent) to 1.0 (opaque).
  • preview_enabled — Sets the preview enabled property.
  • right — Right offset when positioned inside a stack.
  • rotate — Rotation applied to the control.
  • rtl — Renders right-to-left when true.
  • scale — Scale transform applied to the control.
  • size_change_interval — Throttle interval for on_size_change, in ms.
  • tooltip — Text shown on hover/long-press.
  • top — Top offset when positioned inside a stack.
  • visible — Hides the control when false.
  • width — Fixed width in logical pixels.

Events

  • on_animation_end — Fired when an animation completes.
  • on_error — Fired when an error occurs.
  • on_size_change — Fired when the control's size changes.
  • on_state_change — Fired when the control's state changes.
  • on_stream_image — Fired on stream image.

Result and error handling

Client calls are asynchronous. When a method accepts on_result:, handle both callback values: |result, error|. Availability and returned data can vary by platform.

Common service API

The service also supports the common Ruflet control API: attach_handler(event_name, handler), children, emit(event_name, event), has_handler?(event_name), id, merge_props(values = ...), on(event_name, &block), props, runtime_page, runtime_page=, to_patch, type, wire_id, wire_id=.

Use the named methods above for application code; common control methods mainly support event registration, updates, and runtime integration.

Wire reference

  • Service helper: camera
  • Wire type: camera

Client extension setup

This service is implemented by the flet_camera Flet extension. Enable it in ruflet.yaml, then rebuild the client:

extensions:
  - camera

Application code uses page.camera; do not add the package directly to your app's Flutter dependencies.

Declare protected access in services.yaml:

services:
  - camera:
      description: Explain why your app needs camera access.