I'm busy with my first flutter app and have a question as to how set up the architecture to properly manage images/media within the application. I'm using the flutter bloc todos example as a starting point. My question is how do I mange images stored in firestore as entity and model attributes? I've broken my question into the following:
- In
TodoEntity
if I add an image (or list of images) as an attribute, what is the correct class to use (Image
)? Or should I just store the URL as aString
?
class TodoEntity extends Equatable {
final bool complete;
final String id;
final Image image; // this bit is where I'm lost
final String note;
final String task;
Then in my
Todo
class, how is this image stored? Again Image or URL? I assume thetoEntity()
andFromEntity()
methods is where the conversion would happen.In the case where I have a "parent" class, for example
ListOfTodos
which has aList<Todo> todos
attribute, how would that be managed in this context? Should the ListOfTodosEntity class store the IDs of the todos and collect them from the DB in thefromEntity()
method?
My idea is to store a URL in the Entity
class and convert it to an Image object in the Todo
class within the fromEntity
method? Is this the correct idea?
Any help is greatly appreciated. If you happen to have an example where this is done, please provide a link as I was unable to find one.