toMap method

Map<String, Object> toMap()

Converts this display information to a map using the native field names.

Implementation

Map<String, Object> toMap() {
  final Map<String, Object> map = <String, Object>{
    'widthPixels': widthPixels,
    'heightPixels': heightPixels,
    'density': density,
    'densityDpi': densityDpi,
    'refreshRate': refreshRate,
    'supportedRefreshRates': supportedRefreshRates,
    'isHdrSupported': isHdrSupported,
    'supportedHdrTypes': supportedHdrTypes,
    'isIosNative': isIosNative,
  };

  void addOptional(String key, Object? value) {
    if (value != null) {
      map[key] = value;
    }
  }

  addOptional('widthPoints', widthPoints);
  addOptional('heightPoints', heightPoints);
  addOptional('nativeScale', nativeScale);
  addOptional('nativeWidthPixels', nativeWidthPixels);
  addOptional('nativeHeightPixels', nativeHeightPixels);
  addOptional('brightness', brightness);

  return map;
}