readAtlasesBlock method
Implementation
Future<List<Uint8List>> readAtlasesBlock(
StreamReader block, dynamic context) {
// Determine whether or not the atlas is in or out of band.
bool isOOB = block.readBool('isOOB');
block.openArray('data');
int numAtlases = block.readUint16Length();
Future<List<Uint8List>> result;
if (isOOB) {
List<Future<Uint8List>> waitingFor = <Future<Uint8List>>[];
for (int i = 0; i < numAtlases; i++) {
waitingFor.add(readOutOfBandAsset(block.readString('data'), context));
}
result = Future.wait(waitingFor);
} else {
// This is sync.
List<Uint8List> inBandAssets = <Uint8List>[];
for (int i = 0; i < numAtlases; i++) {
inBandAssets.add(block.readAsset());
}
Completer<List<Uint8List>> completer = Completer<List<Uint8List>>();
completer.complete(inBandAssets);
result = completer.future;
}
block.closeArray();
return result;
}