getTeamById method

Future<Team> getTeamById(
  1. int teamId
)

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 or ErrorResponse in case of parsable error

Implementation

Future<Team> getTeamById(int teamId) async {
  try {
    final Response<String> response = await _dio.get('/teams/$teamId');
    return Team.fromRawJson(response.data!);
  } on DioError catch (e) {
    try {
      throw ErrorResponse.fromRawJson(e.response?.data);
    } on TypeError catch (_) {
      throw e;
    }
  }
}