Line data Source code
1 : import 'package:class_fields/domain/class.dart'; 2 : 3 : ///{@template template} 4 : /// The interface for all templates 5 : /// {@endtemplate} 6 : abstract class Template { 7 : /// {@macro template} 8 1 : const Template(this.subject); 9 : 10 : /// the [Class] of the template to generate code for 11 : final Class subject; 12 : 13 : /// Add the template ([generate]) to the given [buffer] 14 1 : void addToBuffer(StringBuffer buffer) { 15 1 : generate(buffer); 16 : } 17 : 18 : /// Generate the template 19 : void generate(StringBuffer buffer); 20 : 21 0 : @override 22 : String toString() { 23 0 : final buffer = StringBuffer(); 24 0 : generate(buffer); 25 : 26 0 : return buffer.toString(); 27 : } 28 : }