journal function

  1. @Riverpod(keepAlive: true)
Journal journal(
  1. Ref<Object?> ref,
  2. String apiKey
)

Implementation

@Riverpod(keepAlive: true)
Journal journal(Ref ref, String apiKey) {
  final appState = ref.watch(appStateProvider);
  if (appState.isArchive) {
    if (appState.showAll) {
      return JournalArchiveAll(
          ref: ref, apiKey: apiKey, state: appState); // with date == null
    } else if (appState.atDate != null) {
      return JournalArchive(ref: ref, apiKey: apiKey, state: appState);
    } else {
      throw StateError('Impossible state of ArchiveStateProvider ');
    }
  } else {
    // not Archive
    return Journal(ref: ref, apiKey: apiKey, state: appState);
  }
}