calendarFormatProvider top-level property

StateProvider<CalendarFormat> calendarFormatProvider
final

Implementation

final calendarFormatProvider = StateProvider<CalendarFormat>((ref) {
  final prefs = ref.watch(sharedPreferencesProvider);
  final calendarFormat = prefs.getString('calendarFormat');
  ref.listenSelf(
    (previous, next) {
      prefs.setString('calendarFormat', next.name);
    },
  );
  // Default to month if no value is found
  return calendarFormat == 'twoWeeks'
      ? CalendarFormat.twoWeeks
      : calendarFormat == 'week'
          ? CalendarFormat.week
          : CalendarFormat.month;
});