QueryState<T> constructor

QueryState<T>({
  1. required Future<T> query(),
  2. required RetryPolicy retryPolicy,
  3. Duration revalidate = const Duration(seconds: 60),
  4. bool cache = true,
  5. bool fetchOnInit = true,
  6. Duration? refresh,
})

Implementation

QueryState({
  required this.query,
  required this.retryPolicy,
  this.revalidate = const Duration(seconds: 60),
  this.cache = true,
  bool fetchOnInit = true,
  Duration? refresh,
}) {
  snapshot = AsyncSnapshot<T>.nothing();
  expires = DateTime.now().add(revalidate);

  if (refresh != null) {
    setRefresh(refresh);
  }

  if (fetchOnInit) {
    fetch();
  }
}