Class constructor

Class(
  1. String className, {
  2. bool? isAbstract,
  3. List<Constructor>? constructors,
  4. String? baseClass,
  5. List<String>? mixins,
  6. List<String>? interfaces,
  7. List<Attribute>? attributes,
  8. List<IExpression>? methods,
})

Example

Class(
 'Bird',
 baseClass: 'Animal',
 interfaces: ['Flyable', 'Crowable'],
 mixins: ['Feather', 'Walk'],
 attributes: <Attribute> [
   Attribute(modifiers: 'final', type: 'String', name: 'name'),
 ],
 constructors: <Constructor> [
   Constructor(
     className: 'Bird',
     constructorName: 'fromName',
     param: Parameter([ParameterItem('this.name', isRequired: true, isNamed: true)]),
       superArgument: Argument([ArgumentItem('name')])
   ),
 ],
 methods: [
   Method(
     name: 'onFly',
     returnType: 'double',
     param: Parameter([ParameterItem('double height')]),
     statements: [Return('height * 2')]
   ),
 ]
 );

Output

Implementation

//   class Bird extends Animal with Feather, Walk implements Flyable, Crowable {
//   final String name;

//   Bird.fromName({required this.name}) : super(name);

//   double onFly(double height) {
//     return height * 2;
//   }
// }
Class(this.className,
    {this.isAbstract,
    this.constructors,
    this.baseClass,
    this.mixins,
    this.interfaces,
    this.attributes,
    this.methods});