DeviceFrame.custom constructor

DeviceFrame.custom(
  1. double width,
  2. double height, {
  3. String? id,
  4. String? label,
  5. double devicePixelRatio = 1.0,
  6. BezelConfig? bezel,
  7. EdgeInsets? safeArea,
})

Build a custom frame. label and id are derived from dimensions when the caller does not provide them, so typical embedded targets can pass just the two sizes.

Implementation

factory DeviceFrame.custom(
  double width,
  double height, {
  String? id,
  String? label,
  double devicePixelRatio = 1.0,
  BezelConfig? bezel,
  EdgeInsets? safeArea,
}) {
  final resolvedLabel =
      label ?? '${width.toStringAsFixed(0)}×${height.toStringAsFixed(0)}';
  final resolvedId =
      id ?? 'custom-${width.toStringAsFixed(0)}x${height.toStringAsFixed(0)}';
  return DeviceFrame(
    id: resolvedId,
    label: resolvedLabel,
    logicalSize: Size(width, height),
    devicePixelRatio: devicePixelRatio,
    bezel: bezel,
    safeArea: safeArea,
  );
}