Flutter Gallery App is an app that you can use to search for images. All images you load will be cached so they can be displayed again later quicker.
Button
object does not really do anything special at this moment and will be more advanced in the future.Seeing as this application does not really have an API I will specify the ImageNotifier here which has the add/remove features of the images.
You can call these functions by watching or reading the imageProvidder.notifier
.
Function Name | Return DataType | Parameters | Description |
---|---|---|---|
fetchImages | Future |
Required: String searchTerm Optional: int pageNumber, int amountOfImagesPerPage |
Fetches the images with a predefined URL and the given parameters |
addImage | void | ImageModel image | Adds the image to the state. |
removeAllImages | Future |
None | Removes all images from the cache and the state. |
removeImage | Future |
String imageUrl | Removes the image with the given image URL from the cache and the state. |
bookmarkImage | void | String imageUrl | Bookmarks the image with the given URL in the state. |
Another idea I was thinking about was to cache the images myself without using a package, but I chose not to do that because I did not want to make a huge list of UInt8Lists with all of the other properties as well.
I could have also saved the images locally myself but then i would also have to make a database for the other properties of the image and as i have never done that I chose to go for the package.
Because I used a package for the caching it makes testing harder, and to do that I would have to use a mocking package to test it.
Another possibility to 'cache' the images would have been to make a Firebase Storage and put the images in there but that's not really caching them as then they are still a network image.
Because I was thinking about that first idea for some time without using packages it took me a bit longer to make this application than I wanted it to take.