flutterPubGet static method

Future<void> flutterPubGet(
  1. String projectPath
)

Runs flutter pub get for a specific project.

projectPath is the path to the project to get packages for.

If the command is successful, a success message is printed to the console. If the command fails, an error message is printed to the console.

Implementation

static Future<void> flutterPubGet(String projectPath) async {
  final pubGetProcess = await Process.run(
    'flutter',
    <String>['pub', 'get'],
    workingDirectory: projectPath,
    runInShell: true
  );

  if (pubGetProcess.exitCode != 0) {
    Console.writeLine(red('❌  Error running flutter pub get: ${pubGetProcess.stderr}'));
    exit(1);
  } else {
    Console.writeLine(green('✅  Successfully ran flutter pub get!'));
  }
}