getAllMedia method

Future<List<MBMedia>> getAllMedia()

Retrieve all the media of the project.

  • Returns a Future that completes with the all the MBMedia saved in the media center of the project.

Implementation

Future<List<MBMedia>> getAllMedia() async {
  Map<String, String> apiParameters = {};
  String apiName = 'api/media';

  apiParameters.addAll(await defaultParameters());

  var uri = Uri.https(endpoint, apiName, apiParameters);
  var response = await http.get(uri, headers: await headers());
  List<dynamic>? body =
      MBManager.checkResponseForType<List<dynamic>>(response.body);
  List<Map<String, dynamic>> bodyArray =
      List.castFrom<dynamic, Map<String, dynamic>>(body);
  return bodyArray.map((d) => MBMedia(dictionary: d)).toList();
}