Line data Source code
1 : part of rx_bloc_generator; 2 : 3 : /// Generates the type class for the blocClass 4 : /// 5 : /// Example: 6 : /// abstract class {RxBlocName}BlocType extends RxBlocTypeBase { 7 : /// {RxBlocName}BlocEvents get events; 8 : /// {RxBlocName}BlocStates get states; 9 : /// } 10 : /// 11 : class _BlocTypeClass implements _BuilderContract { 12 1 : const _BlocTypeClass( 13 : this.className, 14 : this.eventClassName, 15 : this.stateClassName, 16 : ); 17 : 18 : final String className; 19 : 20 : final String eventClassName; 21 : 22 : final String stateClassName; 23 : 24 1 : @override 25 1 : Class build() => Class( 26 1 : (b) => b 27 3 : ..docs.addAll(<String>[ 28 : '/// Used as a contractor for the bloc, events and states classes', 29 : '/// {@nodoc}', 30 : ]) 31 1 : ..abstract = true 32 2 : ..name = className 33 3 : ..extend = refer((RxBlocTypeBase).toString()) 34 3 : ..methods.addAll(<Method>[ 35 1 : Method( 36 1 : (b) => b 37 1 : ..name = 'events' 38 3 : ..returns = refer(eventClassName) 39 1 : ..type = MethodType.getter, 40 : ), 41 1 : Method( 42 1 : (b) => b 43 1 : ..name = 'states' 44 3 : ..returns = refer(stateClassName) 45 1 : ..type = MethodType.getter, 46 : ), 47 : ]), 48 : ); 49 : }