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: TextDirectionThe text direction for this subtree.
child: WidgetRefImplementations§
Source§impl Directionality
impl Directionality
Sourcepub fn new<K>(
text_direction: TextDirection,
child: impl IntoWidget<K>,
) -> Directionality
pub fn new<K>( text_direction: TextDirection, child: impl IntoWidget<K>, ) -> Directionality
Creates a Directionality; Dart’s optional named arguments are the setters.
Sourcepub fn key(self, key: KeyRef) -> Directionality
pub fn key(self, key: KeyRef) -> Directionality
Dart Directionality(key:).
Sourcepub fn of(app: &mut App, context: BuildContext) -> TextDirection
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:
maybe_of, which will returnNoneif noDirectionalityancestor widget is in the tree.
Sourcepub fn maybe_of(app: &mut App, context: BuildContext) -> Option<TextDirection>
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:
of, which will panic if noDirectionalityancestor widget is in the tree.
Trait Implementations§
Source§impl Debug for Directionality
impl Debug for Directionality
Source§impl InheritedWidget for Directionality
impl InheritedWidget for Directionality
Source§fn debug_fill_properties(
&self,
_app: &App,
properties: &mut DiagnosticPropertiesBuilder,
)
fn debug_fill_properties( &self, _app: &App, properties: &mut DiagnosticPropertiesBuilder, )
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 update_should_notify(&self, old_widget: &Directionality) -> bool
fn update_should_notify(&self, old_widget: &Directionality) -> bool
Source§fn as_inherited_theme(&self) -> Option<&dyn InheritedTheme>
fn as_inherited_theme(&self) -> Option<&dyn InheritedTheme>
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
impl Move for Directionality
impl Unpin for Directionality
impl UnsafeUnpin for Directionalitywhere
*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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<W> IntoWidget<InheritedKind> for Wwhere
W: InheritedWidget,
impl<W> IntoWidget<InheritedKind> for Wwhere
W: InheritedWidget,
Source§fn into_widget(self) -> Rc<dyn Widget>
fn into_widget(self) -> Rc<dyn Widget>
creation_location.