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
e05ddcbd
Unverified
Commit
e05ddcbd
authored
Dec 07, 2021
by
Remi Rousselet
Committed by
GitHub
Dec 07, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Requiring data preserves the stackTrace (#93592)
parent
af9cf734
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
1 deletion
+15
-1
async.dart
packages/flutter/lib/src/widgets/async.dart
+1
-1
async_test.dart
packages/flutter/test/widgets/async_test.dart
+14
-0
No files found.
packages/flutter/lib/src/widgets/async.dart
View file @
e05ddcbd
...
...
@@ -249,7 +249,7 @@ class AsyncSnapshot<T> {
if
(
hasData
)
return
data
!;
if
(
hasError
)
throw
error
!;
// ignore: only_throw_errors, since we're just propagating an existing error
Error
.
throwWithStackTrace
(
error
!,
stackTrace
!);
throw
StateError
(
'Snapshot has neither data nor error'
);
}
...
...
packages/flutter/test/widgets/async_test.dart
View file @
e05ddcbd
...
...
@@ -12,6 +12,20 @@ void main() {
return
Text
(
snapshot
.
toString
(),
textDirection:
TextDirection
.
ltr
);
}
group
(
'AsyncSnapshot'
,
()
{
test
(
'requiring data preserves the stackTrace'
,
()
{
final
StackTrace
originalStackTrace
=
StackTrace
.
current
;
try
{
AsyncSnapshot
<
String
>.
withError
(
ConnectionState
.
done
,
Error
(),
originalStackTrace
,
).
requireData
;
fail
(
'requireData did not throw'
);
}
catch
(
error
,
stackTrace
)
{
expect
(
stackTrace
,
originalStackTrace
);
}
});
test
(
'requiring data succeeds if data is present'
,
()
{
expect
(
const
AsyncSnapshot
<
String
>.
withData
(
ConnectionState
.
done
,
'hello'
).
requireData
,
...
...
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