在 dart 中创建一个包

mc_*_*ish 3 dart dart-pub flutter flutter-packages dart-packages

如何在新的 Dart 编辑器中创建包?

没有“添加 Pub 支持”复选框?

另外如何使用新编辑器创建“包”?

是否有介绍新编辑器过程的教程?

小智 13

创建一个名为 mypackage 的包。

对于 Dart 包:

dart  create --template=package-simple  mypackage
Run Code Online (Sandbox Code Playgroud)

对于颤振包:

flutter create --template=package mypackage
Run Code Online (Sandbox Code Playgroud)


Rid*_*Sun 5

来自 Dart/Flutter 文档:

第 1 步:创建包要创建 Flutter 包,请在 flutter create 中使用 --template=package 标志:

flutter create --template=package hello

这将在 hello 文件夹中创建一个包含以下内容的包项目:

LICENSE
A (mostly) empty license text file.

test/hello_test.dart
The unit tests for the package.

hello.iml
A configuration file used by the IntelliJ IDEs.

.gitignore
A hidden file that tells Git which files or folders to ignore in a project.

.metadata
A hidden file used by IDEs to track the properties of the Flutter project.

pubspec.yaml
A yaml file containing metadata that specifies the package’s dependencies. Used by the pub tool.

README.md
A starter markdown file that briefly describes the package’s purpose.

lib/hello.dart
A starter app containing Dart code for the package.

.idea/modules.xml, .idea/modules.xml, .idea/workspace.xml**
A hidden folder containing configuration files for the IntelliJ IDEs.

CHANGELOG.md
A (mostly) empty markdown file for tracking version changes to the package.
Run Code Online (Sandbox Code Playgroud)


Ale*_*uin 3

目前 Dart 编辑器中还没有这样的可能性。要创建包,请按照下列步骤操作:

  • 创建一个没有示例内容的新应用程序 mylib
  • 添加一个pubspec.yaml文件
  • 添加lib文件夹
  • 创建一个mylib.dart包含您要打包的代码的

有关详细信息,请参阅包布局约定。