getAllSubs function Null safety

Future<List<Plan>> getAllSubs(
  1. String username,
  2. String password,
  3. {ScHttpClient? http,
  4. String endpoint = Session.defaultEndpoint,
  5. String previewEndpoint = Session.defaultPreviewEndpoint,
  6. bool downloadPreviews = false,
  7. PlanParser parser = Substitution.fromUntis}
)

Implementation

Future<List<Plan>> getAllSubs(
  String username,
  String password, {
  ScHttpClient? http,
  String endpoint = Session.defaultEndpoint,
  String previewEndpoint = Session.defaultPreviewEndpoint,
  bool downloadPreviews = false,
  PlanParser parser = Substitution.fromUntis,
}) async {
  final session = await Session.login(username, password,
      endpoint: endpoint,
      previewEndpoint: previewEndpoint,
      http: http ?? ScHttpClient());
  final dp = session.downloadPlans(await session.getTimetableJson(),
      downloadPreviews: downloadPreviews);
  final plans = <Plan>[];
  for (final p in parsePlans(dp, parser: parser)) {
    final plan = await p;
    if (plan != null) plans.add(plan);
  }
  return plans;
}