update method

Future<List<QBCustomObject?>> update(
  1. String className, {
  2. String? id,
  3. Map<String, Object>? fields,
  4. List<Map<String, Object>?>? objects,
})

Implementation

Future<List<QBCustomObject?>> update(String className,
    {String? id, Map<String, Object>? fields, List<Map<String, Object>?>? objects}) async {
  Map<String, Object> data = Map();

  data["className"] = className;

  if (id != null) {
    data["id"] = id;
  }
  if (fields != null) {
    data["fields"] = fields;
  }
  if (objects != null) {
    data["objects"] = objects;
  }

  Object? result = await _customObjectsModule.invokeMethod(UPDATE_METHOD, data);

  List<QBCustomObject?> customObjects = [];

  if (result is LinkedHashMap) {
    QBCustomObject? customObject = QBCustomObjectMapper.mapToQBCustomObject(result);
    customObjects.add(customObject);
  }

  if (result is List) {
    for (final item in result) {
      QBCustomObject? customObject = QBCustomObjectMapper.mapToQBCustomObject(item as Map<dynamic, dynamic>);
      customObjects.add(customObject);
    }
  }

  return customObjects;
}