Skip to content

Instantly share code, notes, and snippets.

@montyr75
Created September 12, 2019 19:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save montyr75/99cc6f9ab454ca946f5ed5a010a2389d to your computer and use it in GitHub Desktop.
Save montyr75/99cc6f9ab454ca946f5ed5a010a2389d to your computer and use it in GitHub Desktop.
static object builder
void main() async {
final cache = await Cache.createCache();
}
class Cache {
static Db myDb;
static createCache() async {
if (myDb == null) {
myDb = await Future.delayed(Duration(seconds: 1));;
}
return Cache._internal();
}
Cache._internal() {
// this is a private constructor, so outside files can't use it
// use myDb in here
}
}
class Db {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment