SecureStorage service
Create or retrieve this service with page.secure_storage(**properties). Ruflet reuses the registered service unless you supply a different id.
Example
status = text(value: "Saving token…")
page.add(status)
storage = page.secure_storage
storage.set("access_token", token, on_result: ->(_saved, save_error) {
next page.update(status, value: save_error.to_s) if save_error
storage.get("access_token", on_result: ->(value, read_error) {
page.update(status, value: read_error ? read_error.to_s : "Token loaded: #{value}")
})
})
Page accessor
page.secure_storage(**props)
Properties
android_options— Sets the android options property.data— Arbitrary value you can attach to the control and read back in handlers.ios_options— Sets the ios options property.key— Stable identity used to preserve state across rebuilds.macos_options— Sets the macos options property.web_options— Sets the web options property.windows_options— Sets the windows options property.
Events
on_change— Fired when the value changes.
Service methods
clear(**options)contains_key(key, **options)get(key, **options)get_all(**options)get_availability(timeout: ..., on_result: ...)remove(key, **options)set(key, value, **options)
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:
secure_storage - Wire type:
securestorage - Aliases:
securestorage
Client extension setup
This service is implemented by the flet_secure_storage Flet extension. Enable it in ruflet.yaml, then rebuild the client:
extensions:
- secure_storage
Application code uses page.secure_storage; do not add the package directly to your app's Flutter dependencies.