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
d6e949fb
Commit
d6e949fb
authored
Aug 27, 2015
by
Adam Barth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add logging to help diagnose image loading failures
For debugging #801
parent
d8fdccc5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
10 deletions
+22
-10
image_resource.dart
packages/flutter/lib/base/image_resource.dart
+18
-7
basic.dart
packages/flutter/lib/widgets/basic.dart
+4
-3
No files found.
packages/flutter/lib/base/image_resource.dart
View file @
d6e949fb
...
...
@@ -9,11 +9,7 @@ typedef void ImageListener(sky.Image image);
class
ImageResource
{
ImageResource
(
this
.
_futureImage
)
{
_futureImage
.
then
((
sky
.
Image
image
)
{
_image
=
image
;
_resolved
=
true
;
_notifyListeners
();
});
_futureImage
.
then
(
_handleImageLoaded
,
onError:
_handleImageError
);
}
bool
_resolved
=
false
;
...
...
@@ -33,10 +29,25 @@ class ImageResource {
_listeners
.
remove
(
listener
);
}
void
_handleImageLoaded
(
sky
.
Image
image
)
{
_image
=
image
;
_resolved
=
true
;
_notifyListeners
();
}
void
_handleImageError
(
e
,
stackTrace
)
{
print
(
'Failed to load image:
$e
\n
Stack trace:
$stackTrace
'
);
}
void
_notifyListeners
()
{
assert
(
_resolved
);
List
<
ImageListener
>
localListeners
=
new
List
<
ImageListener
>.
from
(
_listeners
);
for
(
ImageListener
listener
in
localListeners
)
listener
(
_image
);
for
(
ImageListener
listener
in
localListeners
)
{
try
{
listener
(
_image
);
}
catch
(
e
)
{
print
(
'Image listener had exception:
$e
'
);
}
}
}
}
packages/flutter/lib/widgets/basic.dart
View file @
d6e949fb
...
...
@@ -633,7 +633,9 @@ class ImageListener extends StatefulComponent {
this
.
colorFilter
,
this
.
fit
:
ImageFit
.
scaleDown
,
this
.
repeat
:
ImageRepeat
.
noRepeat
})
:
super
(
key:
key
);
})
:
super
(
key:
key
)
{
assert
(
image
!=
null
);
}
ImageResource
image
;
double
width
;
...
...
@@ -645,8 +647,7 @@ class ImageListener extends StatefulComponent {
sky
.
Image
_resolvedImage
;
void
_handleImageChanged
(
sky
.
Image
resolvedImage
)
{
if
(!
mounted
)
return
;
assert
(
mounted
);
setState
(()
{
_resolvedImage
=
resolvedImage
;
});
...
...
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