Skip to content
This repository was archived by the owner on Dec 31, 2022. It is now read-only.

cedvdb/data_state

Repository files navigation

DataState is a micro library to statically type dynamic data, usually data coming from an external data source like a remote server. The use case is to make a standard representation of incoming data.

It contains the following classes:

  • DataState (abstract)
    • DataUnset
    • DataLoading
    • DataLoaded (abstract)
      • DateExists
      • DateNotExist

Usage:

void main() {
  const loading = DataLoading();
  print(loading);
  final loaded = DataState.loaded(3);
  if (loaded is DataExists) {
    print(loaded.data); // 3
  }
  final notExist = DataState.loaded(null);
  final notExistList = DataState.loaded([]);
  print(notExist is DataNotExists);
  print(notExistList is DataNotExists);
}

About

classes representing async state

Resources

License

Stars

2 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages