I need to use Sprite Sheet in a project. I think the only way to use it in Flutter is by fragmenting it with the flame library, but I couldn't achieve the purpose I wanted.
• I need to pull the image over the internet. I'm going to split the image according to the json document I have and save it as List.
When I wanted to do it with Flame, I could only add images as assets and I can output the images as SpriteWidget after fragmenting them. This is not a game project, it is a normal project, I requested to use another way to the other side but they say we have to use this way.
The stage I can reach with the Flame library;
SpriteSheet? _spriteSheet;
_spriteSheet = SpriteSheet(
srcSize: Vector2(40,40), image: await Flame.images.load("spritesheet.png"),
);
String data = await DefaultAssetBundle.of(context).loadString("assets/spritesheet.json");
Map<String,dynamic> jsonResult = jsonDecode(data);
Map<String,dynamic> icon_data = jsonResult["frames"];
icon_data.forEach((key,value){
Map<String,dynamic> frame = value["frame"];
double x = (frame["x"]/40);
double y = (frame["y"]/40);
widget_list[key] = SpriteWidget(sprite: _spriteSheet!.getSprite(y.toInt(), x.toInt()));
});