allocateNewPage function

Future<void> allocateNewPage(
  1. bool sync,
  2. double newContextId,
  3. int syncBufferSize, {
  4. bool useLegacyUICommand = false,
  5. bool enableBlink = false,
})

Implementation

Future<void> allocateNewPage(bool sync, double newContextId, int syncBufferSize,
    {bool useLegacyUICommand = false, bool enableBlink = false}) async {
  await waitingSyncTaskComplete(newContextId);

  Map<String, ElementCreator> widgetElementCreators = getAllWidgetElements();
  Pointer<WidgetElementShape> shapes = createWidgetElementShape(widgetElementCreators);

  if (!sync) {
    Completer<void> completer = Completer();
    _AllocateNewPageContext context = _AllocateNewPageContext(completer, newContextId);
    Pointer<NativeFunction<HandleAllocateNewPageResult>> f = Pointer.fromFunction(_handleAllocateNewPageResult);
    _allocateNewPage(newContextId, syncBufferSize, useLegacyUICommand ? 1 : 0, enableBlink ? 1 : 0,
        dartContext!.pointer, shapes, widgetElementCreators.length, context, f);
    return completer.future;
  } else {
    Pointer<Void> page = _allocateNewPageSync(
        newContextId, dartContext!.pointer, shapes, widgetElementCreators.length, enableBlink ? 1 : 0);
    assert(!_allocatedPages.containsKey(newContextId));
    _allocatedPages[newContextId] = page;
  }
}