Created
April 4, 2018 23:23
-
-
Save georgelesica-wf/c8a3bf9cf57da376440d5e275a6f3e2e to your computer and use it in GitHub Desktop.
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
List<dynamic> _stuff = []; | |
void inject(dynamic thing) { | |
_stuff.add(thing); | |
} | |
T request<T>() => _stuff.firstWhere((thing) => thing is T, orElse: () => null); | |
class MyThing { | |
final String value = 'hello, world'; | |
} | |
void main() { | |
inject(new MyThing()); | |
var thing = request<MyThing>(); | |
print(thing.value); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment