Skip to main content

Directionality

Struct Directionality 

Source
pub struct Directionality {
    pub key: Option<KeyRef>,
    pub text_direction: TextDirection,
    pub child: WidgetRef,
}
Expand description

A widget that determines the ambient directionality of text and text-direction-sensitive render objects.

For example, Padding depends on the Directionality to resolve EdgeInsetsDirectional objects into absolute EdgeInsets objects.

This example uses a right-to-left TextDirection and draws a blue box with a right margin of 8 pixels.

Directionality {
  text_direction: TextDirection::Rtl,
  child: Container(margin: EdgeInsetsGeometry::directional(8.0, 0.0, 0.0, 0.0), color: blue),
}

Flutter’s _UbiquitousInheritedWidget / _UbiquitousInheritedElement is an optimisation that skips per-dependent bookkeeping and notifies by walking the subtree; this is a plain InheritedWidget with the same observable behaviour.

Fields§

§key: Option<KeyRef>§text_direction: TextDirection

The text direction for this subtree.

§child: WidgetRef

Implementations§

Source§

impl Directionality

Source

pub fn new<K>( text_direction: TextDirection, child: impl IntoWidget<K>, ) -> Directionality

Creates a Directionality; Dart’s optional named arguments are the setters.

Source

pub fn key(self, key: KeyRef) -> Directionality

Dart Directionality(key:).

Source

pub fn of(app: &mut App, context: BuildContext) -> TextDirection

The text direction from the closest instance of this class that encloses the given context.

If there is no Directionality ancestor widget in the tree at the given context, then this will panic with a descriptive message.

Typical usage is as follows:

let text_direction = Directionality::of(app, context);

See also:

Source

pub fn maybe_of(app: &mut App, context: BuildContext) -> Option<TextDirection>

The text direction from the closest instance of this class that encloses the given context.

If there is no Directionality ancestor widget in the tree at the given context, then this will return None.

Typical usage is as follows:

let text_direction: Option<TextDirection> = Directionality::maybe_of(app, context);

See also:

Trait Implementations§

Source§

impl Debug for Directionality

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl InheritedWidget for Directionality

Source§

fn key(&self) -> Option<&KeyRef>

Source§

fn debug_fill_properties( &self, _app: &App, properties: &mut DiagnosticPropertiesBuilder, )

Dart’s debugFillProperties: the properties a dump shows for this widget, in Dart’s order. Dart’s Widget base only sets the dense tree style, which the framework does.
Source§

fn child(&self) -> &WidgetRef

The widget below this widget in the tree.
Source§

fn update_should_notify(&self, old_widget: &Directionality) -> bool

Whether the framework should notify widgets that inherit from this widget. Read more
Source§

fn debug_check_constructor(&self)

Source§

fn as_inherited_theme(&self) -> Option<&dyn InheritedTheme>

Dart’s this is InheritedTheme: an inherited widget that is an InheritedTheme answers with itself, which is what InheritedTheme::capture collects.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Directionality

§

impl !Send for Directionality

§

impl !Sync for Directionality

§

impl !UnwindSafe for Directionality

§

impl Forget for Directionality

§

impl Freeze for Directionality
where *const RcInner<dyn Key> is !null: Freeze, PhantomData<RcInner<dyn Key>>: Freeze, *const RcInner<dyn Widget> is !null: Freeze, PhantomData<RcInner<dyn Widget>>: Freeze,

§

impl Move for Directionality

§

impl Unpin for Directionality
where Rc<dyn Key>: Unpin, Rc<dyn Widget>: Unpin,

§

impl UnsafeUnpin for Directionality
where *const RcInner<dyn Key> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Key>>: UnsafeUnpin, *const RcInner<dyn Widget> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Widget>>: UnsafeUnpin,

Blanket Implementations§

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> 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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<W> IntoWidget<InheritedKind> for W
where W: InheritedWidget,

Source§

fn into_widget(self) -> Rc<dyn Widget>

The widget as a tree node, made where this is called: its creation_location.
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>