Skip to content

Commit

Permalink
schedules: change scheduleProviderFamily to throw if a schedule does …
Browse files Browse the repository at this point in the history
…not exist (#133)
  • Loading branch information
wfleischer authored Nov 27, 2024
1 parent 44ec61b commit a810f9a
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions lib/src/schedules/entities/schedule.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,17 @@ import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:nwt_reading/src/schedules/entities/schedules.dart';

final scheduleProviderFamily = FutureProviderFamily<Schedule?, ScheduleKey>(
(ref, scheduleKey) async =>
(await ref.watch(schedulesProvider.future)).schedules[scheduleKey],
name: 'scheduleProviderFamily');
final scheduleProviderFamily =
FutureProviderFamily<Schedule?, ScheduleKey>((ref, scheduleKey) async {
final schedules = await ref.watch(schedulesProvider.future);
final schedule = schedules.schedules[scheduleKey];

if (schedule == null) {
throw Exception('Schedule does not exist');
}

return schedule;
}, name: 'scheduleProviderFamily');

enum ScheduleType {
chronological,
Expand Down

0 comments on commit a810f9a

Please sign in to comment.