I am working on a Dart CLI application. I've clonned Flutter project from git into a directory, now I want to get in this directory and run flutter pub get
in it. But I am having error. Btw I'm using dcli package.
Here is my method:
void _runFlutterPubGet(String path) {
'cd $path'.run;
'flutter pub get'.run;
}
Here is the error:
Unhandled exception:
cd C:\Users\baran\Software\Self\use_template\bin\trial_app
exit: 2
reason: Could not find cd on the path.
wait_for_ex.dart : waitForEx : 21
runnable_process.dart : RunnableProcess._waitForStart : 300
runnable_process.dart : RunnableProcess.start : 278
runnable_process.dart : RunnableProcess.run : 167
run.dart : start : 249
string_as_process.dart : StringAsProcess.run : 80
use_template_base.dart : UseTemplateBase._runFlutterPubGet : 281
use_template_base.dart : UseTemplateBase.exec : 235
use_template.dart : main : 45
isolate_patch.dart : _delayEntrypointInvocation.<anonymous closure> : 295
isolate_patch.dart : _RawReceivePortImpl._handleMessage : 192
CodePudding user response:
I've changed my code to this:
void _runFlutterPubGet(String path) {
run('flutter pub get', workingDirectory: path, runInShell: true);
}
As @julemand101 stated. Solved problem. Thanks for the answer.
CodePudding user response:
Just for information: cd is a internal command of the command shell interpreter cmd.exe. Therefore there is no cd.com/cd.exe, which you can call. When you start a shell like you do now (runInShell = true), you are able to submit the cd command as the shell interpreter takes over.