getTeamById method
Requests Team object from server.
Requires team identifier teamId
. Returns team object Team
in case of success or Null if team not found.
Throws DioError
in case of network connection problems.
Implementation
Future<Team?> getTeamById(String teamId) async {
final int id = teamId.parseIdOrThrow;
try {
final Response<dynamic> response =
await _dio.get('/teams.$extensionJson/$id');
return (response.data as List<dynamic>)
.map((dynamic e) => Team.fromMap(e))
.firstOrNull;
} on DioError catch (e) {
if (e.message.isNotFoundError) {
return null;
} else {
rethrow;
}
}
}