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
a49ba95a
Unverified
Commit
a49ba95a
authored
Aug 10, 2020
by
Ian Hickson
Committed by
GitHub
Aug 10, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Some minor improvements to the AsyncSnapshot API (#63347)
parent
65d9faa1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
0 deletions
+19
-0
async.dart
packages/flutter/lib/src/widgets/async.dart
+11
-0
async_test.dart
packages/flutter/test/widgets/async_test.dart
+8
-0
No files found.
packages/flutter/lib/src/widgets/async.dart
View file @
a49ba95a
...
...
@@ -163,6 +163,14 @@ class _StreamBuilderBaseState<T, S> extends State<StreamBuilderBase<T, S>> {
/// The state of connection to an asynchronous computation.
///
/// The usual flow of state is as follows:
///
/// 1. [none], maybe with some initial data.
/// 2. [waiting], indicating that the asynchronous operation has begun,
/// typically with the data being null.
/// 3. [active], with data being non-null, and possible changing over time.
/// 4. [done], with data being non-null.
///
/// See also:
///
/// * [AsyncSnapshot], which augments a connection state with information
...
...
@@ -206,6 +214,9 @@ class AsyncSnapshot<T> {
/// Creates an [AsyncSnapshot] in [ConnectionState.none] with null data and error.
const
AsyncSnapshot
.
nothing
()
:
this
.
_
(
ConnectionState
.
none
,
null
,
null
);
/// Creates an [AsyncSnapshot] in [ConnectionState.waiting] with null data and error.
const
AsyncSnapshot
.
waiting
()
:
this
.
_
(
ConnectionState
.
waiting
,
null
,
null
);
/// Creates an [AsyncSnapshot] in the specified [state] and with the specified [data].
const
AsyncSnapshot
.
withData
(
ConnectionState
state
,
T
data
)
:
this
.
_
(
state
,
data
,
null
);
...
...
packages/flutter/test/widgets/async_test.dart
View file @
a49ba95a
...
...
@@ -32,6 +32,14 @@ void main() {
throwsStateError
,
);
});
test
(
'AsyncSnapshot basic constructors'
,
()
{
expect
(
const
AsyncSnapshot
<
int
>.
nothing
().
connectionState
,
ConnectionState
.
none
);
expect
(
const
AsyncSnapshot
<
int
>.
nothing
().
data
,
isNull
);
expect
(
const
AsyncSnapshot
<
int
>.
nothing
().
error
,
isNull
);
expect
(
const
AsyncSnapshot
<
int
>.
waiting
().
connectionState
,
ConnectionState
.
waiting
);
expect
(
const
AsyncSnapshot
<
int
>.
waiting
().
data
,
isNull
);
expect
(
const
AsyncSnapshot
<
int
>.
waiting
().
error
,
isNull
);
});
});
group
(
'Async smoke tests'
,
()
{
testWidgets
(
'FutureBuilder'
,
(
WidgetTester
tester
)
async
{
...
...
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