BankListModel.fromMap constructor
Factory to create BankListModel instance from map
.
Implementation
factory BankListModel.fromMap(Map<String, Object?> map) {
final rawBanks = map['records'] ?? [];
return BankListModel(
banks: rawBanks is Iterable
? rawBanks
.map((bank) => BankModel.fromMap(bank))
.toList(growable: false)
: [],
currentPage: map.getInt('current_page', defaultValue: 1),
recordRange: map.getList('record_range'),
totalPages: map.getInt('total_pages', defaultValue: 1),
totalRecords: map.getInt('total_records', defaultValue: 0),
next: map.getString('next'),
previous: map.getString('previous'),
);
}