spawnTextureRegionsFromLine method Null safety

List<TextureRegion> spawnTextureRegionsFromLine(
  1. {required String fileName,
  2. required int tileSize,
  3. required int count}
)

Implementation

List<TextureRegion> spawnTextureRegionsFromLine(
    {required String fileName, required int tileSize, required int count}) {
  final regions = <TextureRegion>[];
  var image = systems.textureSystem.getImageFromCache(fileName);
  var left = 0;
  for (var i = 0; i < count; i++) {
    var rect = Rect.fromLTWH(left.toDouble(), 0, tileSize.toDouble(), tileSize.toDouble());
    left += tileSize;
    regions.add(TextureRegion.fromImage(image!, rect));
  }
  return regions;
}