ScreenInfo.fromMap constructor

ScreenInfo.fromMap(
  1. Map<String, dynamic> map
)

Implementation

factory ScreenInfo.fromMap(Map<String, dynamic> map) {
  // Parse nested frame objects from native
  final frame = map['frame'] as Map<dynamic, dynamic>? ?? {};
  final visibleFrame = map['visibleFrame'] as Map<dynamic, dynamic>? ?? {};

  return ScreenInfo(
    index: (map['id'] as num?)?.toInt() ?? 0,
    bounds: Rect.fromLTWH(
      (frame['x'] as num?)?.toDouble() ?? 0,
      (frame['y'] as num?)?.toDouble() ?? 0,
      (frame['width'] as num?)?.toDouble() ?? 0,
      (frame['height'] as num?)?.toDouble() ?? 0,
    ),
    workArea: Rect.fromLTWH(
      (visibleFrame['x'] as num?)?.toDouble() ?? 0,
      (visibleFrame['y'] as num?)?.toDouble() ?? 0,
      (visibleFrame['width'] as num?)?.toDouble() ?? 0,
      (visibleFrame['height'] as num?)?.toDouble() ?? 0,
    ),
    scaleFactor: (map['scaleFactor'] as num?)?.toDouble() ?? 1.0,
    isPrimary: map['isPrimary'] as bool? ?? false,
  );
}