onCreateWindow method

Future<bool?> onCreateWindow(
  1. int windowId,
  2. String url,
  3. String? target,
  4. String? windowFeatures,
)

Implementation

Future<bool?> onCreateWindow(
    int windowId, String url, String? target, String? windowFeatures) async {
  Map<String, dynamic> windowFeaturesMap = {};
  List<String> features = windowFeatures?.split(",") ?? [];
  for (var feature in features) {
    var keyValue = feature.trim().split("=");
    if (keyValue.length == 2) {
      var key = keyValue[0].trim();
      var value = keyValue[1].trim();
      if (['height', 'width', 'x', 'y'].contains(key)) {
        windowFeaturesMap[key] = double.parse(value);
      } else {
        windowFeaturesMap[key] = value;
      }
    }
  }

  var obj = {
    "windowId": windowId,
    "isForMainFrame": true,
    "request": {"url": url, "method": "GET"},
    "windowFeatures": windowFeaturesMap
  };
  return await _channel?.invokeMethod("onCreateWindow", obj);
}