popArray method

Future<List<int>> popArray(
  1. int size
)

Implementation

Future<List<int>> popArray(int size) async {
  if (_currentList.isEmpty || _currentList.length < size && !closed) {
    // wait until data is available (busy waiting... how sad...)
    while (await Future<bool>.delayed(const Duration(milliseconds: 100),
            () => _currentList.length < size) &&
        !closed) {}
  }
  List<int> ret = _currentList.sublist(0, size);
  _currentList.removeRange(0, size);
  return ret;
}