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
c5edf629
Unverified
Commit
c5edf629
authored
Aug 24, 2022
by
FluentCoding
Committed by
GitHub
Aug 24, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support for FilterQuality in FadeInImage (#110096)
parent
d88376ae
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
58 additions
and
1 deletion
+58
-1
fade_in_image.dart
packages/flutter/lib/src/widgets/fade_in_image.dart
+24
-1
image.dart
packages/flutter/lib/src/widgets/image.dart
+2
-0
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 @
c5edf629
...
...
@@ -65,9 +65,12 @@ class FadeInImage extends StatefulWidget {
/// The [placeholder] and [image] may be composed in a [ResizeImage] to provide
/// a custom decode/cache size.
///
/// The [placeholder] and [image] may
be
have their own BoxFit settings via [fit]
/// The [placeholder] and [image] may have their own BoxFit settings via [fit]
/// and [placeholderFit].
///
/// The [placeholder] and [image] may have their own FilterQuality settings via [filterQuality]
/// and [placeholderFilterQuality].
///
/// The [placeholder], [image], [fadeOutDuration], [fadeOutCurve],
/// [fadeInDuration], [fadeInCurve], [alignment], [repeat], and
/// [matchTextDirection] arguments must not be null.
...
...
@@ -89,6 +92,8 @@ class FadeInImage extends StatefulWidget {
this
.
height
,
this
.
fit
,
this
.
placeholderFit
,
this
.
filterQuality
=
FilterQuality
.
low
,
this
.
placeholderFilterQuality
,
this
.
alignment
=
Alignment
.
center
,
this
.
repeat
=
ImageRepeat
.
noRepeat
,
this
.
matchTextDirection
=
false
,
...
...
@@ -148,6 +153,8 @@ class FadeInImage extends StatefulWidget {
this
.
height
,
this
.
fit
,
this
.
placeholderFit
,
this
.
filterQuality
=
FilterQuality
.
low
,
this
.
placeholderFilterQuality
,
this
.
alignment
=
Alignment
.
center
,
this
.
repeat
=
ImageRepeat
.
noRepeat
,
this
.
matchTextDirection
=
false
,
...
...
@@ -219,6 +226,8 @@ class FadeInImage extends StatefulWidget {
this
.
height
,
this
.
fit
,
this
.
placeholderFit
,
this
.
filterQuality
=
FilterQuality
.
low
,
this
.
placeholderFilterQuality
,
this
.
alignment
=
Alignment
.
center
,
this
.
repeat
=
ImageRepeat
.
noRepeat
,
this
.
matchTextDirection
=
false
,
...
...
@@ -301,6 +310,16 @@ class FadeInImage extends StatefulWidget {
/// If not value set, it will fallback to [fit].
final
BoxFit
?
placeholderFit
;
/// The rendering quality of the image.
///
/// {@macro flutter.widgets.image.filterQuality}
final
FilterQuality
filterQuality
;
/// The rendering quality of the placeholder image.
///
/// {@macro flutter.widgets.image.filterQuality}
final
FilterQuality
?
placeholderFilterQuality
;
/// How to align the image within its bounds.
///
/// The alignment aligns the given position in the image to the given position
...
...
@@ -379,6 +398,7 @@ class _FadeInImageState extends State<FadeInImage> {
ImageErrorWidgetBuilder
?
errorBuilder
,
ImageFrameBuilder
?
frameBuilder
,
BoxFit
?
fit
,
required
FilterQuality
filterQuality
,
required
Animation
<
double
>
opacity
,
})
{
assert
(
image
!=
null
);
...
...
@@ -390,6 +410,7 @@ class _FadeInImageState extends State<FadeInImage> {
width:
widget
.
width
,
height:
widget
.
height
,
fit:
fit
,
filterQuality:
filterQuality
,
alignment:
widget
.
alignment
,
repeat:
widget
.
repeat
,
matchTextDirection:
widget
.
matchTextDirection
,
...
...
@@ -405,6 +426,7 @@ class _FadeInImageState extends State<FadeInImage> {
errorBuilder:
widget
.
imageErrorBuilder
,
opacity:
_imageAnimation
,
fit:
widget
.
fit
,
filterQuality:
widget
.
filterQuality
,
frameBuilder:
(
BuildContext
context
,
Widget
child
,
int
?
frame
,
bool
wasSynchronouslyLoaded
)
{
if
(
wasSynchronouslyLoaded
||
frame
!=
null
)
{
targetLoaded
=
true
;
...
...
@@ -417,6 +439,7 @@ class _FadeInImageState extends State<FadeInImage> {
errorBuilder:
widget
.
placeholderErrorBuilder
,
opacity:
_placeholderAnimation
,
fit:
widget
.
placeholderFit
??
widget
.
fit
,
filterQuality:
widget
.
placeholderFilterQuality
??
widget
.
filterQuality
,
),
placeholderProxyAnimation:
_placeholderAnimation
,
isTargetLoaded:
targetLoaded
,
...
...
packages/flutter/lib/src/widgets/image.dart
View file @
c5edf629
...
...
@@ -870,6 +870,7 @@ class Image extends StatefulWidget {
/// The rendering quality of the image.
///
/// {@template flutter.widgets.image.filterQuality}
/// If the image is of a high quality and its pixels are perfectly aligned
/// with the physical screen pixels, extra quality enhancement may not be
/// necessary. If so, then [FilterQuality.none] would be the most efficient.
...
...
@@ -884,6 +885,7 @@ class Image extends StatefulWidget {
///
/// * [FilterQuality], the enum containing all possible filter quality
/// options.
/// {@endtemplate}
final
FilterQuality
filterQuality
;
/// Used to combine [color] with this image.
...
...
packages/flutter/test/widgets/fade_in_image_test.dart
View file @
c5edf629
...
...
@@ -52,6 +52,7 @@ class FadeInImageElements {
RawImage
get
rawImage
=>
rawImageElement
.
widget
as
RawImage
;
double
get
opacity
=>
rawImage
.
opacity
?.
value
??
1.0
;
BoxFit
?
get
fit
=>
rawImage
.
fit
;
FilterQuality
?
get
filterQuality
=>
rawImage
.
filterQuality
;
}
class
LoadTestImageProvider
extends
ImageProvider
<
Object
>
{
...
...
@@ -517,5 +518,36 @@ Future<void> main() async {
expect
(
findFadeInImage
(
tester
).
placeholder
!.
fit
,
equals
(
BoxFit
.
fill
));
});
});
group
(
"placeholder's FilterQuality"
,
()
{
testWidgets
(
"should be the image's FilterQuality when not set"
,
(
WidgetTester
tester
)
async
{
final
TestImageProvider
placeholderProvider
=
TestImageProvider
(
placeholderImage
);
final
TestImageProvider
imageProvider
=
TestImageProvider
(
targetImage
);
await
tester
.
pumpWidget
(
FadeInImage
(
placeholder:
placeholderProvider
,
image:
imageProvider
,
filterQuality:
FilterQuality
.
medium
,
));
expect
(
findFadeInImage
(
tester
).
placeholder
!.
filterQuality
,
equals
(
findFadeInImage
(
tester
).
target
.
filterQuality
));
expect
(
findFadeInImage
(
tester
).
placeholder
!.
filterQuality
,
equals
(
FilterQuality
.
medium
));
});
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
,
filterQuality:
FilterQuality
.
medium
,
placeholderFilterQuality:
FilterQuality
.
high
,
));
expect
(
findFadeInImage
(
tester
).
target
.
filterQuality
,
equals
(
FilterQuality
.
medium
));
expect
(
findFadeInImage
(
tester
).
placeholder
!.
filterQuality
,
equals
(
FilterQuality
.
high
));
});
});
});
}
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