Line data Source code
1 : typedef FcBuilderFunc<S> = S Function(); 2 : 3 : typedef FcBuilderFuncAsync<S> = Future<S> Function(); 4 : 5 : class FcBuilder<S> { 6 : bool isSingleton; 7 : FcBuilderFunc builderFunc; 8 : S dependency; 9 : bool permanent = false; 10 : 11 8 : FcBuilder(this.isSingleton, this.builderFunc, this.permanent); 12 : 13 8 : S getSependency() { 14 8 : if (isSingleton) { 15 8 : if (dependency == null) { 16 24 : dependency = builderFunc() as S; 17 : } 18 8 : return dependency; 19 : } else { 20 0 : return builderFunc() as S; 21 : } 22 : } 23 : }