Skip to content
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

Load a picture in case the given picture doesn't exists. #1044

Open
aggeloskoutanis opened this issue Feb 28, 2024 · 2 comments
Open

Load a picture in case the given picture doesn't exists. #1044

aggeloskoutanis opened this issue Feb 28, 2024 · 2 comments

Comments

@aggeloskoutanis
Copy link

Hello, first of all, thanks for this great package. Moving on, I would like to express a suggestion that might be handy in some situations.

I work on a project where I fetch some courier companies from the server and then I iterate them and create a list of couriers with the name and the picture of the courier company.

The courier images are stored in the assets folder and are rendered to the user using SvgPicture.asset() constructor.

The problem:

Sometimes, we introduce new couriers that the old mobile clients don't have the necessary data to display (i.ie.: the courier logo).

The solution:

Here, it would have been helpful if SvgPicture.asset() constructor had an errorBuilder that renders a default courier icon if the asset is not found.

@dev-aniketj
Copy link

dev-aniketj commented Mar 23, 2024

@aggeloskoutanis Consider using the null check operator or the if condition in your code to handle null values.

Developers should refrain from creating default icons since different developers require different icons to suit their needs.

@aggeloskoutanis
Copy link
Author

aggeloskoutanis commented Mar 26, 2024

I don't suggest putting a default icon but exporting an error builder, where every developer can insert their Widget, which I would use to display my Error icon.

Check for example Image.asset() from Flutter SDK.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants