-
Notifications
You must be signed in to change notification settings - Fork 337
avatar: Show placeholder on image load error #1882
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
avatar: Show placeholder on image load error #1882
Conversation
60b16e2
to
97f92e7
Compare
Thanks for the PR! Please post before/after screenshots of the change. Please also change the commit sequence so the tests are added in the same commit that adds the behavior being tested. |
97f92e7
to
3f69209
Compare
Hi chrisbobbe! Thanks a lot for the detailed feedback. I'm currently working on your suggestions. I've gathered the before/after screenshots and am now in the process of squashing the commits and fixing the test suite to make the PR perfect. I'll push the updated changes shortly! 😊 |
3f69209
to
0b69fea
Compare
0b69fea
to
aa123be
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Small comments below.
class MockHttpClient extends Fake implements HttpClient { | ||
@override | ||
Future<HttpClientRequest> getUrl(Uri url) async { | ||
throw const SocketException('test error'); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like the kind of thing that FakeImageHttpClient
is for, in test/test_images.dart. Can we use that?
Oh! Or maybe add a boolean success
param to prepareBoringImageHttpClient
in that file (defaulting to true
), and pass false
in this case to make it prepare an HttpStats.notFound
response?
await tester.pump(); // Image fails to load | ||
expect(find.byIcon(ZulipIcons.person), findsOneWidget); | ||
|
||
expect(find.byType(DecoratedBox), findsOneWidget); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like it could easily find a DecoratedBox
that's not related to the behavior we're testing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about checking the icon in this way:
check(find.descendant(
of: find.byType(AvatarImage),
matching: find.byIcon(ZulipIcons.person),
)).findsOne();
(adding the import 'package:flutter_checks/flutter_checks.dart';
at the top as needed)
Also please update the commit message to mention the issue being fixed, according to our style. |
Co-authored-by: Chris Bobbe <[email protected]>
Co-authored-by: Chris Bobbe <[email protected]>
This change improves the user experience by displaying a consistent placeholder when an avatar image fails to load from its URL.
Adds an
errorBuilder
to theAvatarImage
widget and includes a test case to verify the new behavior.Fixes #1558.