Skip to main content

WidgetStateTextStyle

Struct WidgetStateTextStyle 

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

Defines a TextStyle that is also a WidgetStateProperty.

This class exists to enable widgets with TextStyle valued properties to also accept WidgetStateProperty<TextStyle> values. A widget state text style property represents a text style which depends on a widget’s “interactive state”. This state is represented as a set of WidgetStates, like WidgetState::Pressed, WidgetState::Focused and WidgetState::Hovered.

WidgetStateTextStyle should only be used with widgets that document their support, like InputDecoration.labelStyle.

It is the TextStyle it is in Dart once erased with into_any (or .into()): an AnyTextStyle whose value is Dart’s super value, the empty TextStyle(), and whose extension is this object, recovered with style.extension::<WidgetStateTextStyle>().

Implementations§

Source§

impl WidgetStateTextStyle

Source

pub fn resolve_with( callback: impl Fn(&WidgetStates) -> TextStyle + 'static, ) -> WidgetStateTextStyle

Creates a WidgetStateTextStyle from a WidgetPropertyResolver<TextStyle> callback function.

If used as a regular text style, the style resolved in the default state (the empty set of states) will be used.

The given callback parameter must return a non-null text style in the default state.

Source

pub fn from_map(map: WidgetStateMap<TextStyle>) -> WidgetStateTextStyle

Creates a WidgetStateTextStyle from a WidgetStateMap<TextStyle>.

This constructor’s resolve method finds the first entry whose key is satisfied by the set of states, and returns its associated value.

Source

pub fn into_any(self) -> AnyTextStyle

The style as the TextStyle it is in Dart: the empty style, carrying this object as the extension.

Trait Implementations§

Source§

impl Debug for WidgetStateTextStyle

Source§

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

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

impl From<WidgetStateTextStyle> for AnyTextStyle

Source§

fn from(style: WidgetStateTextStyle) -> AnyTextStyle

Converts to this type from the input type.
Source§

impl TextStyleExtension for WidgetStateTextStyle

Source§

fn as_any(&self) -> &dyn Any

The extension as Any, for Dart’s is checks (AnyTextStyle::extension).
Source§

fn eq_extension(&self, other: &dyn TextStyleExtension) -> bool

Dart’s == override on the subclass, called once the values compared equal. other is the same runtime type when it downcasts; any other type is unequal, as Dart’s runtimeType check makes it.
Source§

impl WidgetStateProperty<TextStyle> for WidgetStateTextStyle

Source§

fn resolve(&self, states: &WidgetStates) -> TextStyle

Returns a value of type T that depends on states. Read more
Source§

fn as_any(&self) -> &dyn Any

Downcast support for Dart’s is checks in ==.
Source§

fn as_mapper(&self) -> Option<&WidgetStateMapper<TextStyle>>

Dart’s other is WidgetStateMapper<T>: the mapper this property is, if it is one, as the private mapper subclasses of WidgetStateColor and the rest are.
Source§

fn eq_property(&self, other: &dyn WidgetStateProperty<TextStyle>) -> bool

Dart’s ==. Identity unless a class overrides it, as WidgetStatePropertyAll and WidgetStateMapper do.
Source§

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

Dart’s WidgetStateProperty.debugFillProperties, from Diagnosticable: a property adds its own fields.

Auto Trait Implementations§

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<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>