toMap method

Map<String, dynamic> toMap()

Generate a Map<String,dynamic> object for sensing the configuration via MethodChannel. Sending the configuration object through the MethodChannel, we have to use a Map object.

If you need to save the data into database, please set DatabaseType.DEFAULT to dbType. In the setting, iOS uses Realm, and Android uses Room database internally. In addition, If you do NOT want to save data into database, please set NONE as a dbType.

When you call -toMap(), the method converts the dbType element depends on the current platform.

Implementation

Map<String, dynamic> toMap() {
  var config = {
    "enabled": enabled,
    "debug": debug,
    "label": label,
    "deviceId": deviceId,
    "dbPath": dbPath
  };

  if (dbEncryptionKey != null) {
    config["dbEncryptionKey"] = dbEncryptionKey;
  }

  if (dbHost != null) {
    config["dbHost"] = dbHost;
  }

  // change dbType setting depends on the platform (iOS or Android)
  if (Platform.isIOS) {
    if (this.dbType == DatabaseType.NONE) {
      config["dbType"] = 0;
    } else if (this.dbType == DatabaseType.DEFAULT) {
      config["dbType"] = 1;
    }
  }

  return config;
}