Skip to content

Commit

Permalink
Use map() function
Browse files Browse the repository at this point in the history
  • Loading branch information
Simone Sestito committed Oct 29, 2018
1 parent 8088cc6 commit 990ad12
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions lib/service/RocketService.dart
Original file line number Diff line number Diff line change
Expand Up @@ -86,21 +86,18 @@ class RocketService {
.asMap()
.map((_, agency) => MapEntry(agency.id, agency));

final result = <RocketLaunch>[];
for (int i = 0; i < launchesContent.length; i++) {
final currentLaunch = launchesContent[i];
return launchesContent.map((currentLaunch) {
final requestedAgencyId = currentLaunch["lsp"];
final Agency resolvedAgency = resolvedAgenciesMap[requestedAgencyId];
result.add(RocketLaunch(

return RocketLaunch(
country: resolvedAgency.countryCode,
launchCompany: resolvedAgency,
name: currentLaunch["name"],
date: currentLaunch["windowstart"],
videoUrl: (currentLaunch["vidURLs"] ?? [null])[0],
));
}
return result;
);
});
}

static Future<Agency> getAgencyById(String id) async {
Expand All @@ -116,4 +113,4 @@ class RocketService {
countryCode: agency["countryCode"],
);
}
}
}

0 comments on commit 990ad12

Please sign in to comment.