pub struct NotificationListener<T: ?Sized + NotificationTarget> {
pub key: Option<KeyRef>,
pub child: WidgetRef,
pub on_notification: Option<NotificationListenerCallback<T>>,
/* private fields */
}Expand description
A widget that listens for Notifications bubbling up the tree.
Notifications will trigger the on_notification callback only if
their runtimeType is a subtype of T: a concrete notification type, or a family such
as dyn ScrollNotification (see NotificationTarget).
To dispatch notifications, use the Notification::dispatch method.
Fields§
§key: Option<KeyRef>§child: WidgetRefThe widget below this widget in the tree.
on_notification: Option<NotificationListenerCallback<T>>Called when a notification of the appropriate type arrives at this location in the tree.
Return true to cancel the notification bubbling. Return false to allow the notification to continue to be dispatched to further ancestors.
Notifications vary in terms of when they are dispatched. There are two main possibilities: dispatch between frames, and dispatch during layout.
For notifications that dispatch during layout, such as those that inherit from
LayoutChangedNotification, it is too late to call State::set_state in response
to the notification (as layout is currently happening in a descendant, by definition,
since notifications bubble up the tree). For widgets that depend on layout, consider
a LayoutBuilder instead.
Implementations§
Source§impl<T: ?Sized + NotificationTarget> NotificationListener<T>
impl<T: ?Sized + NotificationTarget> NotificationListener<T>
Sourcepub fn new<K>(child: impl IntoWidget<K>) -> NotificationListener<T>
pub fn new<K>(child: impl IntoWidget<K>) -> NotificationListener<T>
Creates a widget that listens for notifications.
Sourcepub fn key(self, key: KeyRef) -> NotificationListener<T>
pub fn key(self, key: KeyRef) -> NotificationListener<T>
Dart NotificationListener(key:).
Sourcepub fn on_notification(
self,
on_notification: impl Fn(&mut App, &T) -> bool + 'static,
) -> NotificationListener<T>
pub fn on_notification( self, on_notification: impl Fn(&mut App, &T) -> bool + 'static, ) -> NotificationListener<T>
Dart NotificationListener(onNotification:).
Sourcepub fn into_widget(self) -> WidgetRef
pub fn into_widget(self) -> WidgetRef
The tree node: a NotificationListener is its own tree node, which IntoWidget
converts.
Trait Implementations§
Source§impl<T: ?Sized + NotificationTarget> Debug for NotificationListener<T>
impl<T: ?Sized + NotificationTarget> Debug for NotificationListener<T>
Source§impl<T: ?Sized + NotificationTarget> Widget for NotificationListener<T>
impl<T: ?Sized + NotificationTarget> Widget for NotificationListener<T>
Source§fn key(&self) -> Option<&KeyRef>
fn key(&self) -> Option<&KeyRef>
Source§fn creation_location(&self) -> Option<&'static Location<'static>>
fn creation_location(&self) -> Option<&'static Location<'static>>
Source§fn record_creation_location(&mut self, location: CreationLocation)
fn record_creation_location(&mut self, location: CreationLocation)
creation_location to
answer: what into_widget calls on a widget that is its own tree node, which has no
wrapper to keep it in. Such a widget keeps it in a field
(created: Option<CreationLocation>); the default keeps nothing.Source§fn create_element(&self, app: &mut App, this: WidgetRef) -> AnyElement
fn create_element(&self, app: &mut App, this: WidgetRef) -> AnyElement
this is this widget’s shared
reference, which the element keeps.Source§fn widget_type(&self) -> TypeId
fn widget_type(&self) -> TypeId
runtimeType.Source§fn kind(&self) -> WidgetKind
fn kind(&self) -> WidgetKind
Element.updateChild’s superclass
check.Source§fn to_string_short(&self) -> String
fn to_string_short(&self) -> String
toStringShort: the type, then the key when there is one, as
Text-[<'title'>].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
[to_diagnostics_node](Source§fn type_name(&self) -> &'static str
fn type_name(&self) -> &'static str
runtimeType prints in a message: the
type’s own name without its module path. Read moreSource§fn as_inherited_theme(&self) -> Option<&dyn InheritedTheme>
fn as_inherited_theme(&self) -> Option<&dyn InheritedTheme>
Source§fn as_render_object(&self) -> Option<&dyn AnyRenderObjectWidget>
fn as_render_object(&self) -> Option<&dyn AnyRenderObjectWidget>
RenderObjectWidget, when it is one of the three kinds the framework
makes elements for (leaf, single-child, multi-child): what those elements create and
update their render object through, so they are not copied per widget type.Source§fn as_single_child_render_object(
&self,
) -> Option<&dyn AnySingleChildRenderObjectWidget>
fn as_single_child_render_object( &self, ) -> Option<&dyn AnySingleChildRenderObjectWidget>
SingleChildRenderObjectWidget, when it is one.Source§fn as_multi_child_render_object(
&self,
) -> Option<&dyn AnyMultiChildRenderObjectWidget>
fn as_multi_child_render_object( &self, ) -> Option<&dyn AnyMultiChildRenderObjectWidget>
MultiChildRenderObjectWidget, when it is one.Source§fn as_parent_data(&self) -> Option<&dyn AnyParentDataWidget>
fn as_parent_data(&self) -> Option<&dyn AnyParentDataWidget>
ParentDataWidget, when it is one: what the one
ParentDataElement reads, so that element is not copied per widget type.Source§fn as_stateful(&self) -> Option<&dyn AnyStatefulWidget>
fn as_stateful(&self) -> Option<&dyn AnyStatefulWidget>
StatefulWidget, when it is one: what the one StatefulElement
creates its state through, so that element is not copied per widget type.Source§fn as_inherited(&self) -> Option<&dyn AnyInheritedWidget>
fn as_inherited(&self) -> Option<&dyn AnyInheritedWidget>
InheritedWidget, when it is one: what the one
InheritedElement reads, so that element is not copied per widget type.Source§fn as_stateless(&self) -> Option<&dyn StatelessWidget>
fn as_stateless(&self) -> Option<&dyn StatelessWidget>
StatelessWidget, when it is one: what the one
StatelessElement builds from, so that element is not copied per widget type.Source§fn as_preferred_size_widget(&self) -> Option<&dyn PreferredSizeWidget>
fn as_preferred_size_widget(&self) -> Option<&dyn PreferredSizeWidget>
widget is PreferredSizeWidget: this widget as a PreferredSizeWidget, when
it is one. Read moreAuto Trait Implementations§
impl<T> !RefUnwindSafe for NotificationListener<T>
impl<T> !Send for NotificationListener<T>
impl<T> !Sync for NotificationListener<T>
impl<T> !UnwindSafe for NotificationListener<T>
impl<T> Forget for NotificationListener<T>where
T: ?Sized,
impl<T> Freeze for NotificationListener<T>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,
*const RcInner<dyn Fn(&mut App, &T) -> bool> is !null: Freeze,
PhantomData<RcInner<dyn Fn(&mut App, &T) -> bool>>: Freeze,
&'static Location<'static>: Freeze,
T: ?Sized,
impl<T> Move for NotificationListener<T>where
T: ?Sized,
impl<T> Unpin for NotificationListener<T>
impl<T> UnsafeUnpin for NotificationListener<T>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,
*const RcInner<dyn Fn(&mut App, &T) -> bool> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Fn(&mut App, &T) -> bool>>: UnsafeUnpin,
&'static Location<'static>: UnsafeUnpin,
T: ?Sized,
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<TreeNodeKind> for Wwhere
W: Widget,
impl<W> IntoWidget<TreeNodeKind> for Wwhere
W: Widget,
Source§fn into_widget(self) -> Rc<dyn Widget>
fn into_widget(self) -> Rc<dyn Widget>
creation_location.