notify method

Future notify(
  1. MethodCall call
)

Implementation

Future notify(MethodCall call) async {
  List<NotificationObject> notificationObjects(
      List? maps, NotificationType type) {
    if (maps == null) {
      return <NotificationObject>[];
    }
    return maps.map((m) {
      int? index = m.keys.first;
      Map? contentData = m[index];
      T? object;
      if (contentData != null) {
        object = _creator().fromJson(contentData) as T?;
      }

      NotificationObject notificationObject =
          new NotificationObject(object, index, type);
      return notificationObject;
    }).toList();
  }

  List<NotificationObject> objects = <NotificationObject>[];

  List? insertions = call.arguments["insertions"];
  List? deletions = call.arguments["deletions"];
  List? modifications = call.arguments["modifications"];

  objects.addAll(notificationObjects(insertions, NotificationType.insert));
  objects.addAll(notificationObjects(deletions, NotificationType.delete));
  objects.addAll(notificationObjects(modifications, NotificationType.modify));

  _streamController!.add(objects);
}