ensureFlutterProject static method

bool ensureFlutterProject({
  1. bool requireFlutterSdk = true,
})

Ensures current directory is a Flutter project. Prints error and returns false if not.

Implementation

static bool ensureFlutterProject({bool requireFlutterSdk = true}) {
  if (!hasPubspec) {
    ConsoleLog.error('No pubspec.yaml found. Run this command from your project root.');
    return false;
  }
  if (requireFlutterSdk && !hasFlutterSdk) {
    ConsoleLog.warning('pubspec.yaml does not depend on Flutter. Some generators expect a Flutter project.');
    // Still allow running; some commands (e.g. doctor) are fine
  }
  return true;
}