每当我使用dart CLI命令时
dart create <project_name>我曾经得到一个很好的项目文件夹,里面有一个lib/project.dart文件,这样代码就会变得很简单:
int calculate() {
return 6 * 8;
}您将在主文件中导入它。总体来说,这是个不错的触感。但是没有lib文件夹或文件,为什么??
我使用的是linux OS,dart版本2.3:
Linux_x64上的Dart SDK版本: 2.13.4 (稳定)(未知时间戳)
发布于 2021-09-12 20:21:03
如果您运行以下命令:
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 (我认为“简单”的意思是我们不会将应用程序的逻辑拆分成bin、lib和test),但是我们可以通过这样做来改变这一点。
dart create --template console-full hello_world其中包含bin、lib和test文件夹:
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.mdhttps://stackoverflow.com/questions/69154853
复制相似问题