Flutter学习Flutter圈子Flutter中文社区

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

2018-09-27  本文已影响47人  JarvanMo

最近有朋友遇到了这样的一个问题:在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 .

参数解释:

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

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

上一篇下一篇

猜你喜欢

热点阅读