getCurrentCourses method Null safety

Future<List<Course>> getCurrentCourses()

Retrieves courses where the student is currently enrolled in.

Implementation

Future<List<Course>> getCurrentCourses() async {
  final response = await _provider.requestCurrentSubjects();
  if (response.statusCode != 200) {
    throw Exception(response.reasonPhrase);
  }

  final json = jsonDecode(response.body) as Map<String, dynamic>;
  final subjects = json['subjects'] as List<dynamic>;
  return subjects.map<Course>(Course.fromJson).toList();
}