flutter_svg icon indicating copy to clipboard operation
flutter_svg copied to clipboard

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

Open aggeloskoutanis opened this issue 5 months ago • 2 comments

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.

aggeloskoutanis avatar Feb 28 '24 15:02 aggeloskoutanis

@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.

dev-aniketj avatar Mar 23 '24 20:03 dev-aniketj

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.

aggeloskoutanis avatar Mar 26 '24 15:03 aggeloskoutanis