buildCommandClassInsideParent method

String buildCommandClassInsideParent()

Builds the command class for commands inside parent

Implementation

String buildCommandClassInsideParent() {
  final argRecordType = _nonFamilyParams.isEmpty
      ? '()'
      : _nonFamilyParams.toRecordType();

  if (_hasFamily) {
    final familyRecordType = _familyParams.toRecordType();
    return '''
class $_parentCommandClassName extends CommandNotifier<${command.dataType}, $argRecordType> {
$_parentCommandClassName(this._instance, this._familyArg);
final ${parent!.name} _instance;
final $familyRecordType _familyArg;

@override
Future<${command.dataType}> action(Ref ref, $argRecordType arg) => ${_buildParentActionCall()};

@override
List<Ref> get refs => [_instance.ref];

@override
ActionStrategy get strategy => ${command.strategyType};
}''';
  }

  return '''
class $_parentCommandClassName extends CommandNotifier<${command.dataType}, $argRecordType> {
$_parentCommandClassName(this._instance);
final ${parent!.name} _instance;

@override
Future<${command.dataType}> action(Ref ref, $argRecordType arg) => ${_buildParentActionCall()};

@override
List<Ref> get refs => [_instance.ref];

@override
ActionStrategy get strategy => ${command.strategyType};
}''';
}