getAssociationMethod method
String
getAssociationMethod(
- DartType argType, {
- bool forceNullable = false,
- required String query,
})
inherited
Implementation
String getAssociationMethod(
DartType argType, {
bool forceNullable = false,
required String query,
}) {
final isNullable = argType.nullabilitySuffix != NullabilitySuffix.none;
var repositoryOperator = isNullable ? '?' : '!';
if (repositoryHasBeenForceCast) repositoryOperator = '';
final thenStatement =
forceNullable || isNullable ? 'r?.isNotEmpty ?? false ? r!.first : null' : 'r!.first';
return '''repository
$repositoryOperator.getAssociation<${SharedChecker.withoutNullability(argType)}>($query)
.then((r) => $thenStatement)
''';
}