Will Squire
Will Squire

Reputation: 6595

How to perform Pub Get programatically from a Dart program

I'm building a Dart framework called Modular for backend development and this framework has a installer for convenience. At the end of the installation, I'd like to install all dependancies in the generated pubspec.yaml file. How would I do this? Thank you

Upvotes: 2

Views: 101

Answers (1)

Günter Zöchbauer
Günter Zöchbauer

Reputation: 657466

import 'dart:io';
void main() {
  Process.run('pub', ['get'], 
      runInShell: true, 
      workingDirectory: 'dirWherePubspec.yaml_is')
  .then((ProcessResult results) {
    // ...
  });
}

or alternatively Process.start(...)

Upvotes: 3

Related Questions