I have a little doubt that maybe you can help me. The problem is the following: I'm creating an entity(Product) in Flutter with local data stored in a json.The entity has three images, which I converted from file to Base64 and put them in the json ... the json grew quite a lot for that reason, but I wanted to reproduce as best as possible the scenario where the application should react once I use a BD SQlite that contains images stored in Base64. As you can see in some examples it is better to declare the attributes where I will save the images as Uint8List and then with the method : Image.memory(product.mainImage) would get the image. But when I try to call the Base64 class I don't find it and when I put the import supposedly where the class is, the VSCode tells me that "import" is not used ... and suggests I remove it. Thank you for your attention and I hope you can help me.
My Json
{
"products" : [
{
"id" : 1,
"name":"Perfumes y aseo personal",
"description" : "Perfumes y aseo personal",
"mainImage": "/9j/4AAQSkZJRgABAQEAYABgAAD....",
"firstImage": "/9j/4AAQSkZJRgABAQAAAQABA...",
"secondImage": "/9j/4AAQSkZJRgABAQEAYABgA..."
},
.....
My Code
import 'dart:async';
import 'dart:typed_data';
class Product {
int id;
String name;
String description;
Uint8List mainImage;
Uint8List firstImage;
Uint8List secondImage;
Product({this.id,this.name,this.description,this.mainImage,this.firstImage,this.secondImage});
Product.fromMap(Map<String,dynamic> map)
:id = map["id"],
name = map["name"],
description = map["description"],
mainImage = No found -> Base64.decode(map["main_image"]),
firstImage = No found -> Base64.decode(map["first_image"]),
secondImage = No found -> Base64.decode(map["second_image"]);
}