Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
93b90362
Commit
93b90362
authored
Apr 06, 2017
by
Adam Barth
Committed by
GitHub
Apr 06, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add more breadcrumbs in Notification docs (#9245)
Fixes #7519
parent
2144a896
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
1 deletion
+24
-1
notification_listener.dart
packages/flutter/lib/src/widgets/notification_listener.dart
+24
-1
No files found.
packages/flutter/lib/src/widgets/notification_listener.dart
View file @
93b90362
...
...
@@ -15,6 +15,16 @@ import 'framework.dart';
typedef
bool
NotificationListenerCallback
<
T
extends
Notification
>(
T
notification
);
/// A notification that can bubble up the widget tree.
///
/// You can determine the type of a notification using the `is` operator to
/// check the [runtimeType] of the notification.
///
/// To listen for notifications in a subtree, use a [NotificationListener].
///
/// To send a notification, call [dispatch] on the notification you wish to
/// send. The notification will be delivered to any [NotificationListener]
/// widgets with the appropriate type parameters that are ancestors of the given
/// [BuildContext].
abstract
class
Notification
{
/// Applied to each ancestor of the [dispatch] target.
///
...
...
@@ -39,7 +49,9 @@ abstract class Notification {
/// Start bubbling this notification at the given build context.
///
/// To receive notifications, use a [NotificationListener].
/// The notification will be delivered to any [NotificationListener] widgets
/// with the appropriate type parameters that are ancestors of the given
/// [BuildContext].
void
dispatch
(
BuildContext
target
)
{
assert
(
target
!=
null
);
// Only call dispatch if the widget's State is still mounted.
target
.
visitAncestorElements
(
visitAncestor
);
...
...
@@ -68,6 +80,9 @@ abstract class Notification {
/// A widget that listens for [Notification]s bubbling up the tree.
///
/// Notifications will trigger the [onNotification] callback only if their
/// [runtimeType] is a subtype of `T`.
///
/// To dispatch notifications, use the [Notification.dispatch] method.
class
NotificationListener
<
T
extends
Notification
>
extends
StatelessWidget
{
/// Creates a widget that listens for notifications.
...
...
@@ -122,6 +137,14 @@ class NotificationListener<T extends Notification> extends StatelessWidget {
///
/// Useful if, for instance, you're trying to align multiple descendants.
///
/// To listen for notifications in a subtree, use a
/// [NotificationListener<LayoutChangedNotification>].
///
/// To send a notification, call [dispatch] on the notification you wish to
/// send. The notification will be delivered to any [NotificationListener]
/// widgets with the appropriate type parameters that are ancestors of the given
/// [BuildContext].
///
/// In the widgets library, only the [SizeChangedLayoutNotifier] class and
/// [Scrollable] classes dispatch this notification (specifically, they dispatch
/// [SizeChangedLayoutNotification]s and [ScrollNotification]s respectively).
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment