internalCreateWindow method

Future<Window?> internalCreateWindow(
  1. String? id,
  2. WindowConfig config, {
  3. bool start = false,
  4. Window? window,
  5. required MethodChannel channel,
  6. String name = "plugin.create_window",
})

Implementation

Future<Window?> internalCreateWindow(
  String? id,
  WindowConfig config, {
  bool start = false, // start immediately if true
  Window? window,
  required MethodChannel channel,
  String name = "plugin.create_window",
}) async {
  // check permission first
  if (!await checkPermission()) {
    throw Exception("no permission to create window");
  }

  // store the window first
  // window.id can't be updated
  // for main engine use
  // if (window != null) _windows[window.id] = window;
  var updates = await channel.invokeMapMethod(name, {
    "id": id,
    "config": config.toMap(),
    "start": start,
  });
  // if window is not created, new one
  return updates == null ? null : (window ?? Window()).applyMap(updates);
}