ios Flutter:如何创建一个新项目

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/49047411/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 09:41:01  来源:igfitidea点击:

Flutter: How to create a new project

iosxcodeflutterxcode9.3-beta

提问by Krunal

I installed Flutter SDK, following steps, provided from this link: Install on macOS - iOS setup.

我按照此链接提供的步骤安装了 Flutter SDK:Install on macOS - iOS setup

But unable create a new sample project in Xcode. I can't find proper way to start a new project using Xcode.

但无法在 Xcode 中创建新的示例项目。我找不到使用 Xcode 启动新项目的正确方法。

Here are steps to start a new sample project but not for Xcode: Get Started: Test Drive

以下是启动新示例项目但不适用于 Xcode 的步骤:入门:试驾

How to create a new Flutter project in Xcode?

如何在 Xcode 中创建一个新的 Flutter 项目?

I'm using Xcode 9.3 - beta 3

我正在使用Xcode 9.3 - beta 3

回答by Rémi Rousselet

There's no need to use XCode

无需使用 XCode

You can just do a flutter create my_project_namein the terminal

你可以flutter create my_project_name在终端做一个

回答by Andrey

I think a better way is to create Flutter project by command line

我认为更好的方法是通过命令行创建 Flutter 项目

flutter create --org com.yourdomain your_app_name

Swift, Kotlin, and androidx dependencies are the default options

Swift、Kotlin 和 androidx 依赖项是默认选项

After just open the created project in Android Studio or in VSCode

在 Android Studio 或 VSCode 中打开创建的项目后

Parameter

范围

--org com.yourcompany

will form applicationId for Android:

将为Android形成applicationId:

com.yourcompany.yourappname

and iOS PRODUCT_BUNDLE_IDENTIFIER:

和 iOS PRODUCT_BUNDLE_IDENTIFIER:

com.yourcompany.yourAppName

To explore all possible parameters type

探索所有可能的参数类型

flutter create --help

回答by Sen Sokha

Here is in advance! Without android studio, you can create new project with some arguments (Option Migration androidX, Platform languages).

这里提前了!如果没有 android studio,您可以使用一些参数(选项迁移 androidX、平台语言)创建新项目。

flutter create --androidx -t app --org com.companyname.packagename -a kotlin -i swift myapp

Explore Yourself by Flutter CLI

flutter create --help

  • --[no-]pub: Whether to run "flutter pub get" after the project has been created. (defaults to on)

  • --[no-]offline: When "flutter pub 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) 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.
    
  • -s, --sample=≶id>: Specifies the Flutter code sample to use as the main.dart for an application. Implies --template=app. The value should be the sample ID of the desired sample from the API documentation website (http://docs.flutter.dev). An example can be found at https://master-api.flutter.dev/flutter/widgets/SingleChildScrollView-class.html

  • --list-samples=≶path>: Specifies a JSON output file for a listing of Flutter code samples that can created with --sample.

  • --[no-]overwrite: When performing operations, overwrite existing files.

  • --descriptionThe 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")

  • --project-name: The project name for this new Flutter project. This must be a valid dart package name.

  • -i, --ios-language: [objc, swift (default)]
  • -a, --android-language: [java, kotlin (default)]
  • --[no-]androidx: Generate a project using the AndroidX support libraries

通过 Flutter CLI 探索你自己

flutter create --help

  • --[no-]pub: 是否在项目创建后运行“flutter pub get”。(默认为开)

  • --[no-]offline: 当 create 命令运行“flutter pub get”时,这表示是否在离线模式下运行它。在离线模式下,它需要在 pub 缓存中已经有所有可用的依赖项才能成功。

  • --[no-]with-driver-test:还添加了 flutter_driver 依赖项并生成示例“flutter drive”测试。

  • -t, --template=≶type>:指定要创建的项目类型:

     [app]                (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.
    
  • -s, --sample=≶id>:指定 Flutter 代码示例以用作应用程序的 main.dart。暗示 --template=app。该值应该是 API 文档网站 ( http://docs.flutter.dev) 中所需样本的样本 ID 。一个例子可以在https://master-api.flutter.dev/flutter/widgets/SingleChildScrollView-class.html找到

  • --list-samples=≶path>:为可以使用 --sample 创建的 Flutter 代码示例列表指定 JSON 输出文件。

  • --[no-]overwrite:执行操作时,覆盖现有文件。

  • --description用于新 Flutter 项目的描述。该字符串最终出现在 pubspec.yaml 文件中。(默认为“一个新的 Flutter 项目”。)

  • --org:负责您的新 Flutter 项目的组织,采用反向域名表示法。此字符串用于 Java 包名称和 iOS 包标识符中的前缀。(默认为“com.example”)

  • --project-name:这个新 Flutter 项目的项目名称。这必须是有效的 dart 包名称。

  • -i, --ios-language: [objc, swift (默认)]
  • -a, --android -language: [java, kotlin (默认)]
  • --[no-]androidx: 使用 AndroidX 支持库生成项目

Flutter Site: AndroidX Migration

Flutter 站点:AndroidX 迁移

回答by MobileApps

Yet, there is no way to create a project using Xcode Editor.

但是,无法使用 Xcode 编辑器创建项目。

As of now, you must have to create a project using 'Terminal' app.

到目前为止,您必须使用“终端”应用程序创建一个项目。

Here I created a sample test_projectusing following terminal command

在这里,我test_project使用以下终端命令创建了一个示例

flutter create test_project

And here is my Xcode Project ready with workspace.

这是我的 Xcode 项目准备好工作区。

enter image description here

在此处输入图片说明

回答by Omkar Deshmukh

In Android Studio there is direct option to Create new flutter project

在 Android Studio 中有直接选项来创建新的颤振项目

In Editors using any command shell, if you want create sample project then this is usefull, to create sample project following command is used

在使用任何命令 shell 的编辑器中,如果您想创建示例项目,那么这很有用,使用以下命令创建示例项目

flutter create sample_project

if you want to explore more:

如果你想探索更多:

flutter create --help