load method

Future<FlumpLibrary> load (
  1. String url
)

Implementation

static Future<FlumpLibrary> load(String url)  async {

  var jsonString = await HttpRequest.getString(url);
  var jsonFlump = json.decode(jsonString);
  var textureGroupLoaders = List<Future<_FlumpTextureGroup>>();
  var flumpLibrary = FlumpLibrary();

  flumpLibrary._url = _ensureString(url);
  flumpLibrary._md5 = _ensureString(jsonFlump["md5"]);
  flumpLibrary._frameRate = _ensureInt(jsonFlump["frameRate"]);

  for(var jsonMovie in jsonFlump["movies"] as List) {
    var flumpMovieData = _FlumpMovieData(flumpLibrary, jsonMovie);
    flumpLibrary._movieDatas.add(flumpMovieData);
  }

  for(var jsonTextureGroup in jsonFlump["textureGroups"] as List) {
    var future = _FlumpTextureGroup.load(flumpLibrary, jsonTextureGroup);
    textureGroupLoaders.add(future);
  }

  List<_FlumpTextureGroup> textureGroups = await Future.wait(textureGroupLoaders);
  flumpLibrary._textureGroups.addAll(textureGroups);
  return flumpLibrary;
}