create method

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

Implementation

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

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

  Object? result = await _customObjectsModule.invokeMethod(CREATE_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;
}