Created
September 12, 2019 19:16
-
-
Save montyr75/99cc6f9ab454ca946f5ed5a010a2389d to your computer and use it in GitHub Desktop.
static object builder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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