fetch_alle_horecagelegenheden.dart 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. // Automatic FlutterFlow imports
  2. import '/backend/schema/structs/index.dart';
  3. import '/flutter_flow/flutter_flow_theme.dart';
  4. import '/flutter_flow/flutter_flow_util.dart';
  5. import 'index.dart'; // Imports other custom actions
  6. import '/flutter_flow/custom_functions.dart'; // Imports custom functions
  7. import 'package:flutter/material.dart';
  8. // Begin custom action code
  9. // DO NOT REMOVE OR MODIFY THE CODE ABOVE!
  10. import '/backend/api_requests/api_calls.dart';
  11. Future<List<dynamic>> fetchAlleHorecagelegenheden(
  12. String horcat,
  13. String townid,
  14. String displayId,
  15. ) async {
  16. final List<dynamic> alleItems = [];
  17. int page = 0;
  18. const int maxPaginas = 10; // veiligheidslimiet tegen een oneindige loop
  19. while (page < maxPaginas) {
  20. final response = await HorecagelegenheidoverzichtCall.call(
  21. horcat: horcat,
  22. townid: townid,
  23. displayId: displayId,
  24. page: page,
  25. );
  26. if (!response.succeeded) {
  27. break;
  28. }
  29. final items = response.jsonBody as List<dynamic>?;
  30. if (items == null || items.isEmpty) {
  31. break;
  32. }
  33. alleItems.addAll(items);
  34. if (items.length < 100) {
  35. break;
  36. }
  37. page++;
  38. }
  39. return alleItems;
  40. }