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
5161d120
Commit
5161d120
authored
Feb 01, 2016
by
Kris Giesing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Give scale parameter to ImageCache and NetworkImage
parent
d4cc315c
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
11 deletions
+25
-11
image.dart
packages/flutter/lib/src/rendering/image.dart
+1
-1
asset_bundle.dart
packages/flutter/lib/src/services/asset_bundle.dart
+2
-2
image_cache.dart
packages/flutter/lib/src/services/image_cache.dart
+14
-6
basic.dart
packages/flutter/lib/src/widgets/basic.dart
+8
-2
No files found.
packages/flutter/lib/src/rendering/image.dart
View file @
5161d120
...
...
@@ -78,7 +78,7 @@ class RenderImage extends RenderBox {
markNeedsLayout
();
}
///
If non-null, specify
the image's scale.
///
Specifies
the image's scale.
///
/// Used when determining the best display size for the image.
double
get
scale
=>
_scale
;
...
...
packages/flutter/lib/src/services/asset_bundle.dart
View file @
5161d120
...
...
@@ -43,9 +43,9 @@ class NetworkAssetBundle extends AssetBundle {
abstract
class
CachingAssetBundle
extends
AssetBundle
{
final
Map
<
String
,
ImageResource
>
imageResourceCache
=
new
Map
<
String
,
ImageResource
>()
;
<
String
,
ImageResource
>{}
;
final
Map
<
String
,
Future
<
String
>>
_stringCache
=
new
Map
<
String
,
Future
<
String
>>()
;
<
String
,
Future
<
String
>>{}
;
Future
<
ImageInfo
>
fetchImage
(
String
key
)
async
{
return
new
ImageInfo
(
image:
await
decodeImageFromDataPipe
(
await
load
(
key
)));
...
...
packages/flutter/lib/src/services/image_cache.dart
View file @
5161d120
...
...
@@ -3,6 +3,7 @@
// found in the LICENSE file.
import
'dart:async'
;
import
'dart:ui'
show
hashValues
;
import
'package:mojo/mojo/url_response.mojom.dart'
;
import
'package:quiver/collection.dart'
;
...
...
@@ -19,8 +20,9 @@ abstract class ImageProvider {
class
_UrlFetcher
implements
ImageProvider
{
final
String
_url
;
final
double
_scale
;
_UrlFetcher
(
this
.
_url
);
_UrlFetcher
(
this
.
_url
,
this
.
_scale
);
Future
<
ImageInfo
>
loadImage
()
async
{
UrlResponse
response
=
await
fetchUrl
(
_url
);
...
...
@@ -28,11 +30,17 @@ class _UrlFetcher implements ImageProvider {
print
(
"Failed (
${response.statusCode}
) to load image
$_url
"
);
return
null
;
}
return
new
ImageInfo
(
image:
await
decodeImageFromDataPipe
(
response
.
body
));
return
new
ImageInfo
(
image:
await
decodeImageFromDataPipe
(
response
.
body
),
scale:
_scale
);
}
bool
operator
==(
other
)
=>
other
is
_UrlFetcher
&&
_url
==
other
.
_url
;
int
get
hashCode
=>
_url
.
hashCode
;
bool
operator
==(
other
)
{
return
other
is
_UrlFetcher
&&
_url
==
other
.
_url
&&
_scale
==
other
.
_scale
;
}
int
get
hashCode
=>
hashValues
(
_url
,
_scale
);
}
const
int
_kDefaultSize
=
1000
;
...
...
@@ -52,8 +60,8 @@ class _ImageCache {
});
}
ImageResource
load
(
String
url
)
{
return
loadProvider
(
new
_UrlFetcher
(
url
));
ImageResource
load
(
String
url
,
{
double
scale:
1.0
}
)
{
return
loadProvider
(
new
_UrlFetcher
(
url
,
scale
));
}
}
...
...
packages/flutter/lib/src/widgets/basic.dart
View file @
5161d120
...
...
@@ -1531,7 +1531,7 @@ class RawImage extends LeafRenderObjectWidget {
/// aspect ratio.
final
double
height
;
///
If non-null, specify
the image's scale.
///
Specifies
the image's scale.
///
/// Used when determining the best display size for the image.
final
double
scale
;
...
...
@@ -1700,6 +1700,7 @@ class NetworkImage extends StatelessComponent {
this
.
src
,
this
.
width
,
this
.
height
,
this
.
scale
:
1.0
,
this
.
color
,
this
.
fit
,
this
.
alignment
,
...
...
@@ -1722,6 +1723,11 @@ class NetworkImage extends StatelessComponent {
/// aspect ratio.
final
double
height
;
/// Specifies the image's scale.
///
/// Used when determining the best display size for the image.
final
double
scale
;
/// If non-null, apply this color filter to the image before painting.
final
Color
color
;
...
...
@@ -1749,7 +1755,7 @@ class NetworkImage extends StatelessComponent {
Widget
build
(
BuildContext
context
)
{
return
new
RawImageResource
(
image:
imageCache
.
load
(
src
),
image:
imageCache
.
load
(
src
,
scale:
scale
),
width:
width
,
height:
height
,
color:
color
,
...
...
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