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
71048065
Commit
71048065
authored
Aug 09, 2018
by
Harry Terkelsen
Committed by
Jonah Williams
Aug 09, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix bug in FadeInImage causing changes in placeholder to be missed (#20356)
parent
b7a6c169
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
1 deletion
+37
-1
fade_in_image.dart
packages/flutter/lib/src/widgets/fade_in_image.dart
+1
-1
fade_in_image_test.dart
packages/flutter/test/widgets/fade_in_image_test.dart
+36
-0
No files found.
packages/flutter/lib/src/widgets/fade_in_image.dart
View file @
71048065
...
...
@@ -393,7 +393,7 @@ class _FadeInImageState extends State<FadeInImage> with TickerProviderStateMixin
@override
void
didUpdateWidget
(
FadeInImage
oldWidget
)
{
super
.
didUpdateWidget
(
oldWidget
);
if
(
widget
.
image
!=
oldWidget
.
image
||
widget
.
placeholder
!=
w
idget
.
placeholder
)
if
(
widget
.
image
!=
oldWidget
.
image
||
widget
.
placeholder
!=
oldW
idget
.
placeholder
)
_resolveImage
();
}
...
...
packages/flutter/test/widgets/fade_in_image_test.dart
View file @
71048065
...
...
@@ -13,6 +13,7 @@ Future<Null> main() async {
// These must run outside test zone to complete
final
ui
.
Image
targetImage
=
await
createTestImage
();
final
ui
.
Image
placeholderImage
=
await
createTestImage
();
final
ui
.
Image
secondPlaceholderImage
=
await
createTestImage
();
group
(
'FadeInImage'
,
()
{
testWidgets
(
'animates uncached image and shows cached image immediately'
,
(
WidgetTester
tester
)
async
{
...
...
@@ -80,5 +81,40 @@ Future<Null> main() async {
expect
(
stateAfterRecreate
.
phase
,
FadeInImagePhase
.
completed
);
// completes immediately
expect
(
displayedImage
().
image
,
same
(
targetImage
));
});
testWidgets
(
'handles a updating the placeholder image'
,
(
WidgetTester
tester
)
async
{
RawImage
displayedImage
()
=>
tester
.
widget
(
find
.
byType
(
RawImage
));
// The placeholder is expected to be already loaded
final
TestImageProvider
placeholderProvider
=
new
TestImageProvider
(
placeholderImage
);
final
TestImageProvider
secondPlaceholderProvider
=
new
TestImageProvider
(
secondPlaceholderImage
);
// Test case: long loading image
final
TestImageProvider
imageProvider
=
new
TestImageProvider
(
targetImage
);
await
tester
.
pumpWidget
(
new
FadeInImage
(
placeholder:
placeholderProvider
,
image:
imageProvider
,
fadeOutDuration:
const
Duration
(
milliseconds:
50
),
fadeInDuration:
const
Duration
(
milliseconds:
50
),
));
placeholderProvider
.
complete
();
await
tester
.
pump
();
expect
(
displayedImage
().
image
,
same
(
placeholderImage
));
// placeholder completed
expect
(
displayedImage
().
image
,
isNot
(
same
(
secondPlaceholderImage
)));
await
tester
.
pumpWidget
(
new
FadeInImage
(
placeholder:
secondPlaceholderProvider
,
image:
imageProvider
,
fadeOutDuration:
const
Duration
(
milliseconds:
50
),
fadeInDuration:
const
Duration
(
milliseconds:
50
),
));
secondPlaceholderProvider
.
complete
();
await
tester
.
pump
();
expect
(
displayedImage
().
image
,
isNot
(
same
(
placeholderImage
)));
// placeholder replaced
expect
(
displayedImage
().
image
,
same
(
secondPlaceholderImage
));
});
});
}
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