Skip to main content

BuildContext

Struct BuildContext 

Source
pub struct BuildContext { /* private fields */ }
Expand description

Framework-controlled build scope for declarative roots. It intentionally exposes no element IDs or scheduler handles. Signals use the runtime’s scoped collector while a builder executes; reads outside a build simply return the current value and create no dependency.

Implementations§

Source§

impl BuildContext

Source

pub fn spawn<F, T>(&self, future: F) -> Task<T>
where F: Future<Output = T> + Send + 'static, T: Send + 'static,

Spawns Tokio work owned by this declarative owner. Its output must be Send; use Self::spawn_into to update UI-local state on completion.

Source

pub fn spawn_in<F, T>(&self, scope: &TaskScope, future: F) -> Task<T>
where F: Future<Output = T> + Send + 'static, T: Send + 'static,

Source

pub fn spawn_into<F, T>( &self, future: F, complete: impl FnOnce(Result<T, TaskFailure>, &mut Runtime) + 'static, ) -> TaskHandle
where F: Future<Output = T> + Send + 'static, T: Send + 'static,

Starts owner-scoped Tokio work and handles the owned result on the UI thread. The callback may safely capture an Incular Signal.

Source

pub fn dispatch(&self, callback: impl FnOnce(&mut Runtime) + Send + 'static)

Queues a Send callback for the UI owner without granting any Tokio worker mutable access to the widget/runtime tree.

Source

pub fn spawn_blocking<T>( &self, work: impl FnOnce() -> T + Send + 'static, complete: impl FnOnce(Result<T, TaskFailure>, &mut Runtime) + 'static, ) -> TaskHandle
where T: Send + 'static,

Source

pub fn task_scope(&self) -> TaskScope

Source

pub fn watch_focus_scope(&self, scope: &FocusScopeNode)

Makes the current retained builder depend on a focus scope.

A scope is an application-owned handle rather than a signal, so this explicit watch registers a weak, owner-lifetime subscription in the runtime’s ordinary reactive queue. The initial root build records the scope and installs the subscription once its element identity exists.

Source

pub fn restoration_scope(&self) -> Option<RestorationScope>

Returns the stable restoration scope for this build when the owning application explicitly enabled restoration. Ordinary applications have no restoration scope and therefore no persistence side effects.

Source

pub fn restoration(&self) -> Option<RestorationHandle>

Returns a callback-safe capability for reset, flush, and diagnostics when restoration is enabled. It contains no widget tree or native filesystem handle.

Source

pub fn restorable<T>( &self, key: RestorationKey, default: T, ) -> Option<Restorable<T>>
where T: Clone + PartialEq + Serialize + DeserializeOwned + 'static,

Creates an opt-in reactive value under this build’s restoration scope. key must be stable across reordering and rebuilds; use a separate child scope for dynamic collections rather than an element position.

Source

pub fn restored_signal<T>( &self, key: RestorationKey, default: T, ) -> Option<Restorable<T>>
where T: Clone + PartialEq + Serialize + DeserializeOwned + 'static,

Alias matching the common cx.restored_signal("count", 0) pattern. The returned Restorable wraps a normal reactive signal; write via its set/update methods so a mutation is captured for persistence.

Source

pub fn open_window( &self, options: WindowOptions, root: Widget, ) -> Result<WindowHandle, WindowError>

Queues another retained root for native creation. Its state, focus, semantics, environment, compositor, and task scope are independent of this context’s window; shared Signals may still be captured by the supplied root and will subscribe each root independently.

Source

pub fn window_opener(&self) -> Option<WindowOpener>

Returns a retained UI capability that callbacks may use to open a window after this build has returned.

Source

pub fn window_handle(&self) -> Option<WindowHandle>

Returns a command handle for the native window owning this build. Standalone/headless runtimes without an application window return None.

Source

pub fn file_dialogs(&self) -> Option<FileDialogService>

Returns the native file-dialog service owned by the current window. Standalone/headless runtimes without an application window return None.

Source

pub fn global_shortcuts(&self) -> Option<GlobalShortcutService>

Returns the application-scoped native global-shortcut service. Unlike focused Shortcuts, registrations remain active while the application is in the background and are identified independently of any window.

Source

pub fn application_shell(&self) -> Option<ApplicationShellService>

Returns application-scoped tray/status, notification, and taskbar/Dock services. The service contains no native handles and is callback-safe.

Source

pub fn tokio_handle(&self) -> TokioHandle

Returns the Tokio handle for advanced integrations. Tasks spawned directly through it are not owner-scoped; prefer Self::spawn or Self::spawn_into for UI work.

Source

pub fn environment(&self) -> RuntimeEnvironment

Reads all environment fields. Prefer the typed accessors below when a build uses only one value, so unrelated changes do not rebuild it.

Source

pub fn viewport(&self) -> Size

Source

pub fn scale_factor(&self) -> f64

Source

pub fn text_scale(&self) -> f32

Source

pub fn safe_insets(&self) -> EdgeInsets

Source

pub fn view_insets(&self) -> EdgeInsets

Source

pub fn view_padding(&self) -> EdgeInsets

Persistent system-obstruction margin, independent of transient occlusion. Maintained SafeArea bottom edges read this alongside the safe margin.

Source

pub fn safe_area(&self, safe_area: SafeArea) -> Widget

Resolves SafeArea from the authoritative logical insets while recording only the dependencies it reads: the safe margin always, plus the persistent view padding when the descriptor maintains its bottom edge. This applies the same policy as retained construction; transient occlusion never participates.

Source

pub fn brightness(&self) -> Brightness

Source

pub fn locales(&self) -> Vec<Locale>

Source

pub fn resolve_locale(&self, supported: &[Locale]) -> Option<Locale>

Resolves a supported application locale while recording a locale-only dependency, so platform locale changes rebuild only consumers of it.

Source

pub fn text_direction(&self) -> TextDirection

Source

pub fn window_focused(&self) -> bool

Source

pub fn reduced_motion(&self) -> bool

Source

pub fn high_contrast(&self) -> bool

Source

pub fn input_capabilities(&self) -> InputCapabilities

Source

pub fn window_occluded(&self) -> bool

Source

pub fn system_gesture_insets(&self) -> EdgeInsets

Source

pub fn display_features(&self) -> Vec<DisplayFeature>

Flutter’s MediaQuery.displayFeaturesOf; changes with the viewport.

Source

pub fn always_use_24_hour_format(&self) -> bool

Source

pub fn accessible_navigation(&self) -> bool

Source

pub fn invert_colors(&self) -> bool

Source

pub fn on_off_switch_labels(&self) -> bool

Source

pub fn bold_text(&self) -> bool

Source

pub fn supports_announce(&self) -> bool

Source

pub fn navigation_mode(&self) -> NavigationMode

Source

pub fn supports_showing_system_context_menu(&self) -> bool

Source

pub fn line_height_scale_factor_override(&self) -> Option<f32>

Source

pub fn letter_spacing_override(&self) -> Option<f32>

Source

pub fn word_spacing_override(&self) -> Option<f32>

Source

pub fn paragraph_spacing_override(&self) -> Option<f32>

Source

pub fn disable_animations(&self) -> bool

Flutter’s MediaQueryData.disableAnimations, which Incular reads from the reduced-motion preference.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S
where T: Real + Zero + Arithmetics + Clone, Swp: WhitePoint<T>, Dwp: WhitePoint<T>, D: AdaptFrom<S, Swp, Dwp, T>,

Source§

fn adapt_into_using<M>(self, method: M) -> D
where M: TransformMatrix<T>,

👎Deprecated since 0.7.7:

replaced by palette::chromatic_adaptation::AdaptIntoUnclamped

Convert the source color to the destination color using the specified method.
Source§

fn adapt_into(self) -> D

👎Deprecated since 0.7.7:

replaced by palette::chromatic_adaptation::AdaptIntoUnclamped

Convert the source color to the destination color using the bradford method by default.
Source§

impl<T, C> AdaptIntoUnclamped<T> for C
where T: AdaptFromUnclamped<C>,

Source§

type Scalar = <T as AdaptFromUnclamped<C>>::Scalar

The number type that’s used as the color’s components.
Source§

fn adapt_into_unclamped_with<M>(self) -> T

Adapt a color of type Self into a color of type T, using the custom matrix M. Read more
Source§

fn adapt_into_unclamped(self) -> T
where Bradford: LmsToXyz<Self::Scalar> + XyzToLms<Self::Scalar>,

Adapt a color of type Self into a color of type T, using the Bradford matrix. Read more
Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T, C> ArraysFrom<C> for T
where C: IntoArrays<T>,

Source§

fn arrays_from(colors: C) -> T

Cast a collection of colors into a collection of arrays.
Source§

impl<T, C> ArraysInto<C> for T
where C: FromArrays<T>,

Source§

fn arrays_into(self) -> C

Cast this collection of arrays into a collection of colors.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for U
where T: FromCam16Unclamped<WpParam, U>,

Source§

type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar

The number type that’s used in parameters when converting.
Source§

fn cam16_into_unclamped( self, parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>, ) -> T

Converts self into C, using the provided parameters.
Source§

impl<T, C> ComponentsFrom<C> for T
where C: IntoComponents<T>,

Source§

fn components_from(colors: C) -> T

Cast a collection of colors into a collection of color components.
Source§

impl<T, C> ComponentsInto<C> for T

Source§

fn components_into(self) -> C

Cast this collection of color components into a collection of colors. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromAngle<T> for T

Source§

fn from_angle(angle: T) -> T

Performs a conversion from angle.
Source§

impl<T, U> FromStimulus<U> for T
where U: IntoStimulus<T>,

Source§

fn from_stimulus(other: U) -> T

Converts other into Self, while performing the appropriate scaling, rounding and clamping.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> IntoAngle<U> for T
where U: FromAngle<T>,

Source§

fn into_angle(self) -> U

Performs a conversion into T.
Source§

impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for U
where T: Cam16FromUnclamped<WpParam, U>,

Source§

type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar

The number type that’s used in parameters when converting.
Source§

fn into_cam16_unclamped( self, parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>, ) -> T

Converts self into C, using the provided parameters.
Source§

impl<T, U> IntoColor<U> for T
where U: FromColor<T>,

Source§

fn into_color(self) -> U

Convert into T with values clamped to the color defined bounds Read more
Source§

impl<T, U> IntoColorUnclamped<U> for T
where U: FromColorUnclamped<T>,

Source§

fn into_color_unclamped(self) -> U

Convert into T. The resulting color might be invalid in its color space Read more
Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> IntoStimulus<T> for T

Source§

fn into_stimulus(self) -> T

Converts self into T, while performing the appropriate scaling, rounding and clamping.
Source§

impl<T, C> TryComponentsInto<C> for T
where C: TryFromComponents<T>,

Source§

type Error = <C as TryFromComponents<T>>::Error

The error for when try_into_colors fails to cast.
Source§

fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>

Try to cast this collection of color components into a collection of colors. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T, U> TryIntoColor<U> for T
where U: TryFromColor<T>,

Source§

fn try_into_color(self) -> Result<U, OutOfBounds<U>>

Convert into T, returning ok if the color is inside of its defined range, otherwise an OutOfBounds error is returned which contains the unclamped color. Read more
Source§

impl<C, U> UintsFrom<C> for U
where C: IntoUints<U>,

Source§

fn uints_from(colors: C) -> U

Cast a collection of colors into a collection of unsigned integers.
Source§

impl<C, U> UintsInto<C> for U
where C: FromUints<U>,

Source§

fn uints_into(self) -> C

Cast this collection of unsigned integers into a collection of colors.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more