giffy_dialog icon indicating copy to clipboard operation
giffy_dialog copied to clipboard

AssetGiffyDialog and NetworkGiffyDialogg are the same

Open ArtemKolichenkov opened this issue 4 years ago • 2 comments

AssetGiffyDialog and NetworkGiffyDialog are exactly the same.
The only difference is that NetworkGiffyDialog accepts any Widget as image prop, while AssetGiffyDialog accepts only Image.
Perhaps it could be simplified somehow, e.g. one ImageGiffyDialog widget that can accept both Image.asset and Image.network. Actually, they return same type - Image, so it can be already done without any changes to logic.
One other option is make different constructors like ImageGiffyDialog.asset() and ImageGiffyDialog.network(). Although I don't think it is necessary at this point since Flutter's Image is handling all the asset vs network logic already.

ArtemKolichenkov avatar Nov 03 '19 12:11 ArtemKolichenkov

Fair point. Instead of having two different classes it is much better to have named constructors taking relevant input. IIRC Flutter's Image doesn't handle all the asset vs logic by itself, you need to pass the relevant ImageProvider to it, be it AssetImage or NetworkImage.

astralstriker avatar Nov 08 '19 19:11 astralstriker

@ArtemKolichenkov, @astralstriker yes, this can be resolved using factory constructors.

This is my view on the solution -> We can create an internal enum for all the dialog types which then can be set in factory constructor initialization. Then we can build that gif part of the widget on the basis of this enum.

xsahil03x avatar Nov 08 '19 20:11 xsahil03x

Fixed in https://github.com/xsahil03x/giffy_dialog/releases/tag/v2.0.0

xsahil03x avatar Jun 24 '23 16:06 xsahil03x