constructSpecs method

String constructSpecs({
  1. required ScreenDimensions? screenDimensions,
})

Implementation

String constructSpecs({required ScreenDimensions? screenDimensions}) {
  final specs = <String>[
    'width=$width',
    'height=$height',
  ];

  if (shouldCenter == true && screenDimensions != null) {
    final leftOffset = (screenDimensions.width / 2 - width / 2) + (left ?? 0);
    final topOffset = (screenDimensions.height / 2 - height / 2) + (top ?? 0);

    specs.add('left=$leftOffset');
    specs.add('top=$topOffset');
  } else {
    if (left != null) {
      specs.add('left=${left!}');
    }

    if (top != null) {
      specs.add('top=${top!}');
    }
  }

  if (fullscreen != null) {
    specs.add('fullscreen=${_boolToString(fullscreen!)}');
  }
  if (location != null) {
    specs.add('location=${_boolToString(location!)}');
  }
  if (menubar != null) {
    specs.add('menubar=${_boolToString(menubar!)}');
  }
  if (resizable != null) {
    specs.add('resizable=${_boolToString(resizable!)}');
  }
  if (scrollbars != null) {
    specs.add('scrollbars=${_boolToString(scrollbars!)}');
  }
  if (status != null) {
    specs.add('status=${_boolToString(status!)}');
  }
  if (titlebar != null) {
    specs.add('titlebar=${_boolToString(titlebar!)}');
  }
  if (toolbar != null) {
    specs.add('toolbar=${_boolToString(toolbar!)}');
  }
  specs.addAll(additionalParams.entries.map((e) => '${e.key}=${e.value}'));

  return specs.join(',');
}