pub struct TickerMode {
pub key: Option<KeyRef>,
pub enabled: bool,
pub force_frames: bool,
pub child: WidgetRef,
}Expand description
Enables or disables tickers (and thus animation controllers) in the widget subtree.
This only works if AnimationController objects are created using
widget-aware ticker providers. For example, using a
TickerProviderStateMixin or a SingleTickerProviderStateMixin.
Fields§
§key: Option<KeyRef>See Widget::key.
enabled: boolThe requested ticker mode for this subtree.
The effective ticker mode of this subtree may differ from this value
if there is an ancestor TickerMode with this field set to false.
If true and all ancestor TickerModes are also enabled, then tickers in
this subtree will tick.
If false, then tickers in this subtree will not tick regardless of any
ancestor TickerModes. Animations driven by such tickers are not paused,
they just don’t call their callbacks. Time still elapses.
force_frames: boolIf true, tickers in this subtree will force frames even if frames would normally not be scheduled (e.g. even if the device’s screen is turned off).
Use sparingly as this will cause significantly higher battery usage when the device should be idle.
child: WidgetRefThe widget below this widget in the tree.
Implementations§
Source§impl TickerMode
impl TickerMode
Sourcepub fn new<K>(enabled: bool, child: impl IntoWidget<K>) -> TickerMode
pub fn new<K>(enabled: bool, child: impl IntoWidget<K>) -> TickerMode
Creates a TickerMode; Dart’s optional named arguments are the setters.
Sourcepub fn key(self, key: KeyRef) -> TickerMode
pub fn key(self, key: KeyRef) -> TickerMode
Dart TickerMode(key:).
Sourcepub fn force_frames(self, force_frames: bool) -> TickerMode
pub fn force_frames(self, force_frames: bool) -> TickerMode
Dart TickerMode(force_frames:).
Sourcepub fn of(app: &mut App, context: BuildContext) -> bool
👎Deprecated: Use TickerMode::values_of to get both enabled and force_frames. This feature was deprecated after v3.35.0-0.0.pre.
pub fn of(app: &mut App, context: BuildContext) -> bool
Use TickerMode::values_of to get both enabled and force_frames. This feature was deprecated after v3.35.0-0.0.pre.
Whether tickers in the given subtree should be enabled or disabled.
This is used automatically by TickerProviderStateMixin and
SingleTickerProviderStateMixin to decide if their tickers should be
enabled or disabled.
In the absence of a TickerMode widget, this function defaults to true.
Typical usage is as follows:
let ticking_enabled = TickerMode::of(app, context);Sourcepub fn get_notifier(
app: &App,
context: BuildContext,
) -> Rc<dyn ValueListenable<bool>>
👎Deprecated: Use TickerMode::get_values_notifier to get both enabled and force_frames. This feature was deprecated after v3.35.0-0.0.pre.
pub fn get_notifier( app: &App, context: BuildContext, ) -> Rc<dyn ValueListenable<bool>>
Use TickerMode::get_values_notifier to get both enabled and force_frames. This feature was deprecated after v3.35.0-0.0.pre.
Obtains a ValueListenable from the TickerMode surrounding the context,
which indicates whether tickers are enabled in the given subtree.
When that TickerMode enables or disables tickers, the listenable notifies
its listeners.
While the ValueListenable is stable for the lifetime of the surrounding
TickerMode, calling this method does not establish a dependency between
the context and the TickerMode and the widget owning the context
does not rebuild when the ticker mode changes from true to false or vice
versa. This is preferable when the ticker mode does not impact what is
currently rendered on screen, e.g. because it is only used to mute/unmute a
Ticker. Since no dependency is established, the widget owning the
context is also not informed when it is moved to a new location in the
tree where it may have a different TickerMode ancestor. When this
happens, the widget must manually unsubscribe from the old listenable,
obtain a new one from the new ancestor TickerMode by calling this method
again, and re-subscribe to it. StatefulWidgets can, for example, do this
in State::activate, which is called after the widget has been moved to
a new location.
Alternatively, of can be used instead of this method to create a
dependency between the provided context and the ancestor TickerMode.
In this case, the widget automatically rebuilds when the ticker mode
changes or when it is moved to a new TickerMode ancestor, which
simplifies the management cost in the widget at the expense of some
potential unnecessary rebuilds.
In the absence of a TickerMode widget, this function returns a
ValueListenable, whose ValueListenable::value is always true.
Sourcepub fn values_of(app: &mut App, context: BuildContext) -> TickerModeData
pub fn values_of(app: &mut App, context: BuildContext) -> TickerModeData
Returns the requested ticker mode values for this subtree and establishes
a dependency on the ancestor TickerMode, if any.
This is used automatically by TickerProviderStateMixin and
SingleTickerProviderStateMixin to decide if their tickers should be
enabled or disabled.
In the absence of a TickerMode widget, this defaults to enabled
tickers that don’t force frames.
Typical usage is as follows:
let ticking_enabled = TickerMode::values_of(app, context).enabled;Sourcepub fn get_values_notifier(
app: &App,
context: BuildContext,
) -> Rc<dyn ValueListenable<TickerModeData>>
pub fn get_values_notifier( app: &App, context: BuildContext, ) -> Rc<dyn ValueListenable<TickerModeData>>
Obtains a ValueListenable from the TickerMode surrounding the context,
which indicates whether tickers are enabled in the given subtree.
When that TickerMode enabled or disabled tickers, the listenable notifies
its listeners.
While the ValueListenable is stable for the lifetime of the surrounding
TickerMode, calling this method does not establish a dependency between
the context and the TickerMode and the widget owning the context
does not rebuild when the ticker mode data changes. This is preferable
when the ticker mode does not impact what is currently rendered on screen,
e.g. because it is only used to mute/unmute a Ticker. Since no dependency
is established, the widget owning the context is also not informed when
it is moved to a new location in the tree where it may have a different
TickerMode ancestor. When this happens, the widget must manually
unsubscribe from the old listenable, obtain a new one from the new ancestor
TickerMode by calling this method again, and re-subscribe to it.
StatefulWidgets can, for example, do this in State::activate,
which is called after the widget has been moved to a new location.
Alternatively, of can be used instead of this method to create a
dependency between the provided context and the ancestor TickerMode.
In this case, the widget automatically rebuilds when the ticker mode
changes or when it is moved to a new TickerMode ancestor, which
simplifies the management cost in the widget at the expensive of some
potential unnecessary rebuilds.
In the absence of a TickerMode widget, this function returns a
ValueListenable, whose ValueListenable::value is
TickerModeData::FALLBACK.
Every call wraps the ancestor’s notifier anew: two results for the same
TickerMode are not Rc::ptr_eq, though they notify from the same object.
Trait Implementations§
Source§impl Debug for TickerMode
impl Debug for TickerMode
Source§impl StatefulWidget for TickerMode
impl StatefulWidget for TickerMode
Source§type State = TickerModeState
type State = TickerModeState
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 create_state(&self) -> TickerModeState
fn create_state(&self) -> TickerModeState
Source§fn as_preferred_size_widget(&self) -> Option<&dyn PreferredSizeWidget>
fn as_preferred_size_widget(&self) -> Option<&dyn PreferredSizeWidget>
Source§fn type_name(&self) -> &'static str
fn type_name(&self) -> &'static str
Widget::type_name. A stateful form another widget kind becomes (an animated or
status transition widget) names the widget it wraps.Auto Trait Implementations§
impl !RefUnwindSafe for TickerMode
impl !Send for TickerMode
impl !Sync for TickerMode
impl !UnwindSafe for TickerMode
impl Forget for TickerMode
impl Freeze for TickerMode
impl Move for TickerMode
impl Unpin for TickerMode
impl UnsafeUnpin for TickerModewhere
*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<StatefulKind> for Wwhere
W: StatefulWidget,
impl<W> IntoWidget<StatefulKind> for Wwhere
W: StatefulWidget,
Source§fn into_widget(self) -> Rc<dyn Widget>
fn into_widget(self) -> Rc<dyn Widget>
creation_location.