您现在的位置是:首页 > 文章详情

Flutter误删除android/ios目录怎么办?

日期:2018-09-26点击:510

最近有朋友遇到了这样的一个问题:在Flutter开发中误删android/ios该如何挽救?。很多朋友会尝试从回收站中恢复,但如果无法从回收站中恢复怎么办?还有办法拯救一下自己吗。答案是肯定的。我们可以通过flutter create命令拯救自己。看一下flutter create:

flutter help create Create a new Flutter project. If run on a project that already exists, this will repair the project, recreating any files that are missing. Usage: flutter create <output directory> -h, --help Print this usage information. --[no-]pub Whether to run "flutter packages get" after the project has been created. (defaults to on) --[no-]offline When "flutter packages get" is run by the create command, this indicates whether to run it in offline mode or not. In offline mode, it will need to have all dependencies already available in the pub cache to succeed. --[no-]with-driver-test Also add a flutter_driver dependency and generate a sample 'flutter drive' test. -t, --template=<type> Specify the type of project to create. [app] (default) (default) Generate a Flutter application. [package] Generate a shareable Flutter project containing modular Dart code. [plugin] Generate a shareable Flutter project containing an API in Dart code with a platform-specific implementation for Android, for iOS code, or for both. --description The description to use for your new Flutter project. This string ends up in the pubspec.yaml file. (defaults to "A new Flutter project.") --org The organization responsible for your new Flutter project, in reverse domain name notation. This string is used in Java package names and as prefix in the iOS bundle identifier. (defaults to "com.example") -i, --ios-language [objc (default), swift] -a, --android-language [java (default), kotlin] 

帮助说的很清楚,如果在一个既存项目中运行这个命令,那么这将会修复当前项目,重新创建丢失的文件。简单示例代码:

flutter create -i objc . 

参数解释:

  • -i 是表示iOS项目开发语言,objc和swift两个选项,其中objc是默认的。
  • -a 是表示Android项目开发语言,java和kotlin两个选项,其中java是默认的。

当然了create命令还给我们提供了一些其他选项:

  • -t , --template=<type> 模板。共三个可选项:app,package,plugin。其中app是默认的。
  • --org 组织名称。这个参数将作为java包名以及iOS的BundleID前缀。默认是“com.example"。
  • --description 描述。这将用于描述当前的工程,也会在pubspec.yaml中有所体现。默认是”A new Flutter project.“。

到此为止,create命令就算介绍完了。有的同学可能会有疑问,这个修复到底有什么用?没有版本管理工具吗?实际上,这个命令非常有用。很多时候,写一个demo是没版本管理工具的,或者原来的项目是oc写的,突然又改变了主意,想改用swift了,这时候就该用create了。
希望本文对你有所帮助。欢迎加入 OpenFlutter交流群:892398530。
版本所有,转载请注明出处

原文链接:https://yq.aliyun.com/articles/657576
关注公众号

低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。

持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。

转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。

文章评论

共有0条评论来说两句吧...

文章二维码

扫描即可查看该文章

点击排行

推荐阅读

最新文章