postFrameCallback method

void postFrameCallback(
  1. Duration timestamp
)

Implementation

void postFrameCallback(Duration timestamp) async {
  if (_record == false) {
    return;
  }
  if (skipped > 0) {
    // count down frames which should be skipped
    skipped = skipped - 1;
    // add a new PostFrameCallback to know about the next frame
    _binding.addPostFrameCallback(postFrameCallback);
    // but we do nothing, because we skip this frame
    return;
  }
  if (skipped == 0) {
    // reset skipped frame counter
    skipped = skipped + skipFramesBetweenCaptures;
  }
  try {
    final image = capture();
    if (image == null) {
      print('capture returned null');
      return;
    }
    exporter.onNewFrame(Frame(timestamp, image));
  } catch (e) {
    print(e.toString());
  }
  _binding.addPostFrameCallback(postFrameCallback);
}