discoMonkey
discoMonkey

Reputation: 63

dart CLI command -why no lib/proj.dart file? dart ctreate <project_name>

whenever I used dart CLI command

dart create <project_name>

i used to get a nice project folder with a lib/project.dart file inside the file there would be a some nice peace of code like this:

int calculate() {
  return 6 * 8;
}

which you would import in the main file. a nice touch overall. but there is no lib folder or file, why??

i am using linux OS, dart version 2.3:

Dart SDK version: 2.13.4 (stable) (Unknown timestamp) on "linux_x64"

Upvotes: 1

Views: 78

Answers (1)

julemand101
julemand101

Reputation: 31299

If you run:

dart create --help

You get the following with Dart version 2.14.1 (properly also 2.13.x but I don't have that version):

Create a new Dart project.

Usage: dart create [arguments] <directory>
-h, --help        Print this usage information.
-t, --template    The project template to use.
                  [console-simple (default), console-full, package-simple, server-shelf, web-simple]
    --[no-]pub    Whether to run 'pub get' after the project has been created.
                  (defaults to on)
    --force       Force project generation, even if the target directory already exists.

Run "dart help" to see global options.

Available templates:
  console-simple: A simple command-line application. (default)
    console-full: A command-line application sample.
  package-simple: A starting point for Dart libraries or applications.
    server-shelf: A server app using `package:shelf`
      web-simple: A web app that uses only core Dart libraries.

So the default type of project is console-simple (I suppose that by "simple" it means we don't split the logic of our application into bin, lib and test) but we can change that by doing e.g.

dart create --template console-full hello_world

Which does contain the bin, lib and test folders:

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-----        12-09-2021     22:20                .dart_tool
d-----        12-09-2021     22:20                bin
d-----        12-09-2021     22:20                lib
d-----        12-09-2021     22:20                test
-a----        12-09-2021     22:20            113 .gitignore
-a----        12-09-2021     22:20           5328 .packages
-a----        12-09-2021     22:20           1038 analysis_options.yaml
-a----        12-09-2021     22:20             29 CHANGELOG.md
-a----        12-09-2021     22:20           7907 pubspec.lock
-a----        12-09-2021     22:20            242 pubspec.yaml
-a----        12-09-2021     22:20            122 README.md

Upvotes: 2

Related Questions