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
50ead38f
Unverified
Commit
50ead38f
authored
Oct 27, 2021
by
Tuyen VU
Committed by
GitHub
Oct 27, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- add FadeInImage.placeholderFit (#90739)
parent
ebb48e16
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
1 deletion
+47
-1
fade_in_image.dart
packages/flutter/lib/src/widgets/fade_in_image.dart
+15
-1
fade_in_image_test.dart
packages/flutter/test/widgets/fade_in_image_test.dart
+32
-0
No files found.
packages/flutter/lib/src/widgets/fade_in_image.dart
View file @
50ead38f
...
@@ -67,6 +67,9 @@ class FadeInImage extends StatefulWidget {
...
@@ -67,6 +67,9 @@ class FadeInImage extends StatefulWidget {
/// The [placeholder] and [image] may be composed in a [ResizeImage] to provide
/// The [placeholder] and [image] may be composed in a [ResizeImage] to provide
/// a custom decode/cache size.
/// a custom decode/cache size.
///
///
/// The [placeholder] and [image] may be have their own BoxFit settings via [fit]
/// and [placeholderFit].
///
/// The [placeholder], [image], [fadeOutDuration], [fadeOutCurve],
/// The [placeholder], [image], [fadeOutDuration], [fadeOutCurve],
/// [fadeInDuration], [fadeInCurve], [alignment], [repeat], and
/// [fadeInDuration], [fadeInCurve], [alignment], [repeat], and
/// [matchTextDirection] arguments must not be null.
/// [matchTextDirection] arguments must not be null.
...
@@ -87,6 +90,7 @@ class FadeInImage extends StatefulWidget {
...
@@ -87,6 +90,7 @@ class FadeInImage extends StatefulWidget {
this
.
width
,
this
.
width
,
this
.
height
,
this
.
height
,
this
.
fit
,
this
.
fit
,
this
.
placeholderFit
,
this
.
alignment
=
Alignment
.
center
,
this
.
alignment
=
Alignment
.
center
,
this
.
repeat
=
ImageRepeat
.
noRepeat
,
this
.
repeat
=
ImageRepeat
.
noRepeat
,
this
.
matchTextDirection
=
false
,
this
.
matchTextDirection
=
false
,
...
@@ -146,6 +150,7 @@ class FadeInImage extends StatefulWidget {
...
@@ -146,6 +150,7 @@ class FadeInImage extends StatefulWidget {
this
.
width
,
this
.
width
,
this
.
height
,
this
.
height
,
this
.
fit
,
this
.
fit
,
this
.
placeholderFit
,
this
.
alignment
=
Alignment
.
center
,
this
.
alignment
=
Alignment
.
center
,
this
.
repeat
=
ImageRepeat
.
noRepeat
,
this
.
repeat
=
ImageRepeat
.
noRepeat
,
this
.
matchTextDirection
=
false
,
this
.
matchTextDirection
=
false
,
...
@@ -217,6 +222,7 @@ class FadeInImage extends StatefulWidget {
...
@@ -217,6 +222,7 @@ class FadeInImage extends StatefulWidget {
this
.
width
,
this
.
width
,
this
.
height
,
this
.
height
,
this
.
fit
,
this
.
fit
,
this
.
placeholderFit
,
this
.
alignment
=
Alignment
.
center
,
this
.
alignment
=
Alignment
.
center
,
this
.
repeat
=
ImageRepeat
.
noRepeat
,
this
.
repeat
=
ImageRepeat
.
noRepeat
,
this
.
matchTextDirection
=
false
,
this
.
matchTextDirection
=
false
,
...
@@ -295,6 +301,11 @@ class FadeInImage extends StatefulWidget {
...
@@ -295,6 +301,11 @@ class FadeInImage extends StatefulWidget {
/// [paintImage].
/// [paintImage].
final
BoxFit
?
fit
;
final
BoxFit
?
fit
;
/// How to inscribe the placeholder image into the space allocated during layout.
///
/// If not value set, it will fallback to [fit].
final
BoxFit
?
placeholderFit
;
/// How to align the image within its bounds.
/// How to align the image within its bounds.
///
///
/// The alignment aligns the given position in the image to the given position
/// The alignment aligns the given position in the image to the given position
...
@@ -376,6 +387,7 @@ class _FadeInImageState extends State<FadeInImage> {
...
@@ -376,6 +387,7 @@ class _FadeInImageState extends State<FadeInImage> {
required
ImageProvider
image
,
required
ImageProvider
image
,
ImageErrorWidgetBuilder
?
errorBuilder
,
ImageErrorWidgetBuilder
?
errorBuilder
,
ImageFrameBuilder
?
frameBuilder
,
ImageFrameBuilder
?
frameBuilder
,
BoxFit
?
fit
,
required
Animation
<
double
>
opacity
,
required
Animation
<
double
>
opacity
,
})
{
})
{
assert
(
image
!=
null
);
assert
(
image
!=
null
);
...
@@ -386,7 +398,7 @@ class _FadeInImageState extends State<FadeInImage> {
...
@@ -386,7 +398,7 @@ class _FadeInImageState extends State<FadeInImage> {
opacity:
opacity
,
opacity:
opacity
,
width:
widget
.
width
,
width:
widget
.
width
,
height:
widget
.
height
,
height:
widget
.
height
,
fit:
widget
.
fit
,
fit:
fit
,
alignment:
widget
.
alignment
,
alignment:
widget
.
alignment
,
repeat:
widget
.
repeat
,
repeat:
widget
.
repeat
,
matchTextDirection:
widget
.
matchTextDirection
,
matchTextDirection:
widget
.
matchTextDirection
,
...
@@ -401,6 +413,7 @@ class _FadeInImageState extends State<FadeInImage> {
...
@@ -401,6 +413,7 @@ class _FadeInImageState extends State<FadeInImage> {
image:
widget
.
image
,
image:
widget
.
image
,
errorBuilder:
widget
.
imageErrorBuilder
,
errorBuilder:
widget
.
imageErrorBuilder
,
opacity:
_imageAnimation
,
opacity:
_imageAnimation
,
fit:
widget
.
fit
,
frameBuilder:
(
BuildContext
context
,
Widget
child
,
int
?
frame
,
bool
wasSynchronouslyLoaded
)
{
frameBuilder:
(
BuildContext
context
,
Widget
child
,
int
?
frame
,
bool
wasSynchronouslyLoaded
)
{
if
(
wasSynchronouslyLoaded
)
{
if
(
wasSynchronouslyLoaded
)
{
_resetAnimations
();
_resetAnimations
();
...
@@ -413,6 +426,7 @@ class _FadeInImageState extends State<FadeInImage> {
...
@@ -413,6 +426,7 @@ class _FadeInImageState extends State<FadeInImage> {
image:
widget
.
placeholder
,
image:
widget
.
placeholder
,
errorBuilder:
widget
.
placeholderErrorBuilder
,
errorBuilder:
widget
.
placeholderErrorBuilder
,
opacity:
_placeholderAnimation
,
opacity:
_placeholderAnimation
,
fit:
widget
.
placeholderFit
??
widget
.
fit
,
),
),
placeholderProxyAnimation:
_placeholderAnimation
,
placeholderProxyAnimation:
_placeholderAnimation
,
isTargetLoaded:
frame
!=
null
,
isTargetLoaded:
frame
!=
null
,
...
...
packages/flutter/test/widgets/fade_in_image_test.dart
View file @
50ead38f
...
@@ -49,6 +49,7 @@ class FadeInImageElements {
...
@@ -49,6 +49,7 @@ class FadeInImageElements {
RawImage
get
rawImage
=>
rawImageElement
.
widget
as
RawImage
;
RawImage
get
rawImage
=>
rawImageElement
.
widget
as
RawImage
;
double
get
opacity
=>
rawImage
.
opacity
?.
value
??
1.0
;
double
get
opacity
=>
rawImage
.
opacity
?.
value
??
1.0
;
BoxFit
?
get
fit
=>
rawImage
.
fit
;
}
}
class
LoadTestImageProvider
extends
ImageProvider
<
Object
>
{
class
LoadTestImageProvider
extends
ImageProvider
<
Object
>
{
...
@@ -435,5 +436,36 @@ Future<void> main() async {
...
@@ -435,5 +436,36 @@ Future<void> main() async {
});
});
});
});
});
});
group
(
"placeholder's BoxFit"
,
()
{
testWidgets
(
"should be the image's BoxFit when not set"
,
(
WidgetTester
tester
)
async
{
final
TestImageProvider
placeholderProvider
=
TestImageProvider
(
placeholderImage
);
final
TestImageProvider
imageProvider
=
TestImageProvider
(
targetImage
);
await
tester
.
pumpWidget
(
FadeInImage
(
placeholder:
placeholderProvider
,
image:
imageProvider
,
fit:
BoxFit
.
cover
,
));
expect
(
findFadeInImage
(
tester
).
placeholder
!.
fit
,
equals
(
findFadeInImage
(
tester
).
target
.
fit
));
expect
(
findFadeInImage
(
tester
).
placeholder
!.
fit
,
equals
(
BoxFit
.
cover
));
});
testWidgets
(
'should be the given value when set'
,
(
WidgetTester
tester
)
async
{
final
TestImageProvider
placeholderProvider
=
TestImageProvider
(
placeholderImage
);
final
TestImageProvider
imageProvider
=
TestImageProvider
(
targetImage
);
await
tester
.
pumpWidget
(
FadeInImage
(
placeholder:
placeholderProvider
,
image:
imageProvider
,
fit:
BoxFit
.
cover
,
placeholderFit:
BoxFit
.
fill
,
));
expect
(
findFadeInImage
(
tester
).
target
.
fit
,
equals
(
BoxFit
.
cover
));
expect
(
findFadeInImage
(
tester
).
placeholder
!.
fit
,
equals
(
BoxFit
.
fill
));
});
});
});
});
}
}
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