MBProject.fromDictionary constructor

MBProject.fromDictionary(
  1. Map<String, dynamic> dictionary
)

Initializes a project with the dictionary returned by the MBurger APIs.

  • Parameters:
    • dictionary: The dictionary returned by the APIs.

Implementation

factory MBProject.fromDictionary(Map<String, dynamic> dictionary) {
  int id = dictionary['id'] as int;
  String name = dictionary['name'] as String;
  List<MBContract>? contracts;
  if (dictionary['contracts'] != null) {
    List<Map<String, dynamic>> contractsList =
        List<Map<String, dynamic>>.from(dictionary['contracts'] as List);
    contracts =
        contractsList.map((c) => MBContract.fromDictionary(c)).toList();
  }
  return MBProject(
    id: id,
    name: name,
    contracts: contracts,
  );
}