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
53727866
Commit
53727866
authored
Jan 03, 2019
by
TruongSinh Tran-Nguyen
Committed by
xster
Jan 03, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix #25143 Successive calls to `precacheImage()` throw an exception (#25159)
parent
85ded441
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
1 deletion
+25
-1
AUTHORS
AUTHORS
+1
-0
image.dart
packages/flutter/lib/src/widgets/image.dart
+2
-1
image_test.dart
packages/flutter/test/widgets/image_test.dart
+22
-0
No files found.
AUTHORS
View file @
53727866
...
...
@@ -32,3 +32,4 @@ Chema Molins <chemamolins@gmail.com>
Stefan Mitev <mr.mitew@gmail.com>
Jasper van Riet <jaspervanriet@gmail.com>
Mattijs Fuijkschot <mattijs.fuijkschot@gmail.com>
TruongSinh Tran-Nguyen <i@truongsinh.pro>
packages/flutter/lib/src/widgets/image.dart
View file @
53727866
...
...
@@ -83,9 +83,11 @@ Future<void> precacheImage(
final
ImageStream
stream
=
provider
.
resolve
(
config
);
void
listener
(
ImageInfo
image
,
bool
sync
)
{
completer
.
complete
();
stream
.
removeListener
(
listener
);
}
void
errorListener
(
dynamic
exception
,
StackTrace
stackTrace
)
{
completer
.
complete
();
stream
.
removeListener
(
listener
);
if
(
onError
!=
null
)
{
onError
(
exception
,
stackTrace
);
}
else
{
...
...
@@ -99,7 +101,6 @@ Future<void> precacheImage(
}
}
stream
.
addListener
(
listener
,
onError:
errorListener
);
completer
.
future
.
then
<
void
>((
void
value
)
{
stream
.
removeListener
(
listener
);
});
return
completer
.
future
;
}
...
...
packages/flutter/test/widgets/image_test.dart
View file @
53727866
...
...
@@ -621,6 +621,28 @@ void main() {
expect
(
isSync
,
isTrue
);
});
testWidgets
(
'Precache remove listeners immediately after future completes, does not crash on successive calls #25143'
,
(
WidgetTester
tester
)
async
{
final
TestImageStreamCompleter
imageStreamCompleter
=
TestImageStreamCompleter
();
final
TestImageProvider
provider
=
TestImageProvider
(
streamCompleter:
imageStreamCompleter
);
await
tester
.
pumpWidget
(
Builder
(
builder:
(
BuildContext
context
)
{
precacheImage
(
provider
,
context
);
return
Container
();
}
)
);
expect
(
imageStreamCompleter
.
listeners
.
length
,
2
);
imageStreamCompleter
.
listeners
.
keys
.
toList
()[
1
](
null
,
null
);
expect
(
imageStreamCompleter
.
listeners
.
length
,
1
);
imageStreamCompleter
.
listeners
.
keys
.
toList
()[
0
](
null
,
null
);
expect
(
imageStreamCompleter
.
listeners
.
length
,
0
);
});
testWidgets
(
'Precache completes with onError on error'
,
(
WidgetTester
tester
)
async
{
dynamic
capturedException
;
StackTrace
capturedStackTrace
;
...
...
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