creditsFile function

String? creditsFile(
  1. ModelProject project, {
  2. String? documentName,
})

The CREDITS.txt project needs, or null when it owes nothing.

Null rather than an empty file. A project built entirely from CC0 and from this application's own models owes nobody anything, and shipping an empty credits file beside it would suggest otherwise — which is exactly the confusion gal-01 sorts CC0 first to avoid.

Implementation

String? creditsFile(ModelProject project, {String? documentName}) {
  final List<ModelCredit> credits = creditsIn(project);
  if (credits.isEmpty) return null;
  final name = documentName == null ? '' : ' for $documentName';
  return <String>[
    'Credits$name',
    '',
    'This model includes work by others, under the licences named below.',
    '',
    for (final ModelCredit credit in credits) _line(credit),
    '',
  ].join('\n');
}