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
aae968cd
Unverified
Commit
aae968cd
authored
Nov 26, 2018
by
Ian Hickson
Committed by
GitHub
Nov 26, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve StreamBuilder documentation (#23713)
parent
06e4ccc9
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
22 deletions
+33
-22
async.dart
packages/flutter/lib/src/widgets/async.dart
+33
-22
No files found.
packages/flutter/lib/src/widgets/async.dart
View file @
aae968cd
...
...
@@ -36,13 +36,13 @@ import 'framework.dart';
/// termination by overriding [afterDone]. Finally, the summary may be updated
/// on change of stream by overriding [afterDisconnected] and [afterConnected].
///
///
[T]
is the type of stream events.
///
`T`
is the type of stream events.
///
///
[S]
is the type of interaction summary.
///
`S`
is the type of interaction summary.
///
/// See also:
///
/// * [StreamBuilder], which is specialized
to
the case where only the most
/// * [StreamBuilder], which is specialized
for
the case where only the most
/// recent interaction is needed for widget building.
abstract
class
StreamBuilderBase
<
T
,
S
>
extends
StatefulWidget
{
/// Creates a [StreamBuilderBase] connected to the specified [stream].
...
...
@@ -333,14 +333,9 @@ typedef AsyncWidgetBuilder<T> = Widget Function(BuildContext context, AsyncSnaps
/// state is `ConnectionState.active`.
///
/// The initial snapshot data can be controlled by specifying [initialData].
/// You would use this facility to ensure that if the [builder] is invoked
/// before the first event arrives on the stream, the snapshot carries data of
/// your choice rather than the default null value.
///
/// See also:
///
/// * [StreamBuilderBase], which supports widget building based on a computation
/// that spans all interactions made with the stream.
/// This should be used to ensure that the first frame has the expected value,
/// as the builder will always be called before the stream listener has a chance
/// to be processed.
///
/// {@tool sample}
///
...
...
@@ -365,25 +360,41 @@ typedef AsyncWidgetBuilder<T> = Widget Function(BuildContext context, AsyncSnaps
/// )
/// ```
/// {@end-tool}
// TODO(ianh): remove unreachable code above once https://github.com/dart-lang/linter/issues/1141 is fixed
///
/// See also:
///
/// * [ValueListenableBuilder], which wraps a [ValueListenable] instead of a
/// [Stream].
/// * [StreamBuilderBase], which supports widget building based on a computation
/// that spans all interactions made with the stream.
// TODO(ianh): remove unreachable code above once https://github.com/dart-lang/linter/issues/1139 is fixed
class
StreamBuilder
<
T
>
extends
StreamBuilderBase
<
T
,
AsyncSnapshot
<
T
>>
{
/// Creates a new [StreamBuilder] that builds itself based on the latest
/// snapshot of interaction with the specified [stream] and whose build
/// strategy is given by [builder]. The [initialData] is used to create the
/// initial snapshot. It is null by default.
/// strategy is given by [builder].
///
/// The [initialData] is used to create the initial snapshot.
///
/// The [builder] must not be null.
const
StreamBuilder
({
Key
key
,
this
.
initialData
,
Stream
<
T
>
stream
,
@required
this
.
builder
})
:
assert
(
builder
!=
null
),
})
:
assert
(
builder
!=
null
),
super
(
key:
key
,
stream:
stream
);
/// The build strategy currently used by this builder.
Cannot be null.
/// The build strategy currently used by this builder.
final
AsyncWidgetBuilder
<
T
>
builder
;
/// The data that will be used to create the initial snapshot. Null by default.
/// The data that will be used to create the initial snapshot.
///
/// Providing this value (presumably obtained sychronously somehow when the
/// [Stream] was created) ensures that the first frame will show useful data.
/// Otherwise, the first frame will be built with the value null, regardless
/// of whether a value is available on the stream: since streams are
/// asynchronous, no events from the stream can be obtained before the initial
/// build.
final
T
initialData
;
@override
...
...
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