getForms method

Stream<JotformForm> getForms({
  1. int offset = 0,
  2. int limit = 20,
  3. String? filter,
  4. JotformOrderBy? orderBy,
})

Implementation

Stream<JotformForm> getForms({
  int offset = 0,
  int limit = 20,
  String? filter,
  JotformOrderBy? orderBy,
}) async* {
  yield* await http
      .get(getUrl("user/forms", params: {
    "offset": offset.toString(),
    "limit": limit.toString(),
    if (filter != null) "filter": filter,
    if (orderBy != null) "orderBy": orderBy.name.replaceAll("_", "")
  }))
      .then((value) {
    Map<String, dynamic> body = jsonDecode(value.body);
    if (body["limit-left"] is int) {
      limitLeft = body["limit-left"];
    }
    return Stream.fromIterable((body["content"] as List<dynamic>)
        .whereType<Map<String, dynamic>>()
        .map((i) => JotformFormMapper.fromMap(i)));
  });
}