validate method

  1. @override
Future<ValidationCheck> validate(
  1. ReleaseContext context
)
override

Implementation

@override
Future<ValidationCheck> validate(ReleaseContext context) async {
  final projectDir = Directory(context.projectPath);
  if (!projectDir.existsSync()) {
    return ValidationCheck(
      name: name,
      status: CheckStatus.failed,
      message: 'Project directory "${context.projectPath}" does not exist.',
    );
  }

  final pubspecFile = File('${context.projectPath}/pubspec.yaml');
  if (!pubspecFile.existsSync()) {
    return ValidationCheck(
      name: name,
      status: CheckStatus.failed,
      message: 'No pubspec.yaml found in "${context.projectPath}".',
    );
  }

  final content = pubspecFile.readAsStringSync();
  if (!content.contains('flutter:')) {
    return ValidationCheck(
      name: name,
      status: CheckStatus.failed,
      message: 'pubspec.yaml does not contain a "flutter:" section.',
    );
  }

  return ValidationCheck(
    name: name,
    status: CheckStatus.passed,
    message: 'Valid Flutter project detected',
  );
}