【问题标题】:dart CLI command -why no lib/proj.dart file? dart ctreate <project_name>dart CLI 命令 - 为什么没有 lib/proj.dart 文件? dart ctreate <项目名称>
【发布时间】:2021-09-12 20:08:06
【问题描述】:

每当我使用 dart CLI 命令时

dart create <project_name>

我曾经获得一个不错的项目文件夹,其中包含一个 lib/project.dart 文件,文件内会有一些不错的代码,如下所示:

int calculate() {
  return 6 * 8;
}

您将在主文件中导入。整体感觉不错。但是没有lib文件夹或文件,为什么??

我使用的是 linux 操作系统,dart 版本 2.3:

Dart SDK 版本:“linux_x64”上的 2.13.4(稳定)(未知时间戳)

【问题讨论】:

    标签: dart command-line-interface


    【解决方案1】:

    如果你运行:

    dart create --help
    

    使用 Dart 版本 2.14.1(当然也是 2.13.x,但我没有那个版本)您会得到以下内容:

    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.
    

    所以项目的默认类型是console-simple(我想“简单”意味着我们不会将应用程序的逻辑拆分为binlibtest)但我们可以更改通过这样做,例如

    dart create --template console-full hello_world
    

    其中包含binlibtest 文件夹:

    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
    

    【讨论】:

      猜你喜欢
      • 2014-01-10
      • 2013-03-21
      • 2020-09-11
      • 1970-01-01
      • 2019-03-30
      • 2019-06-09
      • 1970-01-01
      • 2014-08-18
      • 2023-03-11
      相关资源
      最近更新 更多