toDictionary method

Map<String, dynamic> toDictionary()

Convert the options to a dictionary.

Implementation

Map<String, dynamic> toDictionary() {
  final val = <String, dynamic>{};

  void writePropertyIfNotNull(String key, dynamic value) {
    if (value != null) {
      val[key] = value;
    }
  }

  writePropertyIfNotNull('autoEnterEnabled', autoEnterEnabled);

  // only for android
  if (defaultTargetPlatform == TargetPlatform.android) {
    writePropertyIfNotNull('aspectRatioX', aspectRatioX);
    writePropertyIfNotNull('aspectRatioY', aspectRatioY);
    writePropertyIfNotNull('sourceRectHintLeft', sourceRectHintLeft);
    writePropertyIfNotNull('sourceRectHintTop', sourceRectHintTop);
    writePropertyIfNotNull('sourceRectHintRight', sourceRectHintRight);
    writePropertyIfNotNull('sourceRectHintBottom', sourceRectHintBottom);
    writePropertyIfNotNull('seamlessResizeEnabled', seamlessResizeEnabled);
    writePropertyIfNotNull(
        'useExternalStateMonitor', useExternalStateMonitor);
    writePropertyIfNotNull(
        'externalStateMonitorInterval', externalStateMonitorInterval);
  }

  // only for ios
  if (defaultTargetPlatform == TargetPlatform.iOS) {
    writePropertyIfNotNull('sourceContentView', sourceContentView);
    writePropertyIfNotNull('contentView', contentView);
    writePropertyIfNotNull('preferredContentWidth', preferredContentWidth);
    writePropertyIfNotNull('preferredContentHeight', preferredContentHeight);
    writePropertyIfNotNull('controlStyle', controlStyle);
  }
  return val;
}