projectAssetChecks function

List<DoctorCheck> projectAssetChecks(
  1. Directory project
)

What doctor says about a project's models (decision 54): whether a hook is there to convert what is under assets_src/, and whether flutter: assets: names every directory the converted files land in.

Both fail nothing, which is why both are problems here. Without the hook nothing is converted, and Model3D finds no file; without a line for flutter3d_generated/models/ the build bundles the files directly in flutter3d_generated/ and none below it, since Flutter does not bundle a directory's subdirectories. A project with nothing under assets_src/ that converts gets no line.

Implementation

List<DoctorCheck> projectAssetChecks(Directory project) {
  final AssetLayout layout;
  try {
    layout = AssetLayout(projectRoot: project);
  } on ManifestFormatException catch (refused) {
    return <DoctorCheck>[
      DoctorCheck(
        'Asset lines',
        DoctorStatus.problem,
        'flutter3d_assets.yaml does not read: ${refused.message} '
            '(line ${refused.line})',
        fix: 'correct the manifest; the hook refuses it the same way',
      ),
    ];
  }
  if (layout.plan().isEmpty) return const <DoctorCheck>[];
  final unlisted = unlistedGeneratedAssets(layout);
  return <DoctorCheck>[
    if (_hooked(project))
      const DoctorCheck(
        'Asset hook',
        DoctorStatus.ok,
        'hook/build.dart converts assets_src/ on every build',
      )
    else
      const DoctorCheck(
        'Asset hook',
        DoctorStatus.problem,
        'no hook/build.dart calling buildAssets, so nothing under '
            'assets_src/ is converted and the application finds no model',
        fix:
            'run `flutter3d init`, which writes the hook, or add it by hand '
            '(see the quickstart)',
      ),
    if (unlisted.isEmpty)
      const DoctorCheck(
        'Asset lines',
        DoctorStatus.ok,
        'pubspec.yaml ships every directory the converted models land in',
      )
    else
      DoctorCheck(
        'Asset lines',
        DoctorStatus.problem,
        'pubspec.yaml does not list ${unlisted.join(', ')}, so the models '
            'converted there are not in the application',
        fix:
            'run `flutter3d init`, which adds them, or add '
            '${unlisted.map((String line) => '`- $line`').join(', ')} under '
            'flutter: assets: (Flutter does not bundle a directory\'s '
            'subdirectories)',
      ),
  ];
}