Flutter: How to create a new project

ぃ、小莉子 提交于 2019-12-03 16:07:15

问题


Just a day ago, Flutter, a new hybrid (mobile apps) development framework released by Google Inc.

I installed Flutter SDK, following steps, provided from this link: 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.

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

How to create a new Flutter project in Xcode?

I'm using Xcode 9.3 - beta 3


回答1:


There's no need to use XCode

You can just do a flutter create my_project_name in the terminal




回答2:


I think a better way is to create Flutter project by command line with iOS support:

In the terminal in a desired directory run command

flutter create -i swift -a kotlin your_gibrid_project_name

This util will create a project that you can run on iOS and on Android as well!

After you can develop it in IDE that suits for you

Full command for production can look like

flutter create --org com.yourcompany -i swift -a kotlin --description 'Your App Description' your_app_name

Params

--org com.yourcompany

will form applicationId for Android:

com.yourcompany.yourappname

and iOS PRODUCT_BUNDLE_IDENTIFIER:

com.yourcompany.yourAppName

parameter

--description 'Your App Description' 

sets package description in our pubspec.yaml

To find all possible options run in the terminal command

flutter create --help



回答3:


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

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

Here I created a sample test_project using following terminal command

flutter create test_project

And here is my Xcode Project ready with workspace.




回答4:


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

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.

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

  • --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 Site: AndroidX Migration



来源:https://stackoverflow.com/questions/49047411/flutter-how-to-create-a-new-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!