skip to content

Flutter CLI

The flutter command installs and diagnoses the SDK, switches channels, and drives create, run, attach and logs day to day. Interviewers use it to check that you can recover a broken toolchain.

on this pageshow

explore

questions

11

With flutter create, how do you start an app for Android, iOS and web only, and what do --org and --platforms control?

level: juniorimportance: must knowfreq 62%

answer

  1. reverse-domain prefix, default com.example
  2. folder name becomes the package name
  3. one platform folder per target
  4. underscores on Android, camelCase on Apple
  5. re-run create to add a platform

basics

~10 s

Run flutter create --org com.acme --platforms android,ios,web shop_app. --org sets the reverse-domain prefix of the Android application ID and iOS bundle ID; --platforms decides which platform folders are generated.

solid answer

~40 s

`flutter create --org com.acme --platforms android,ios,web shop_app` makes a project named after the folder, which must be a valid Dart package name. `--org` (default `com.example`) is the reverse-domain prefix for the platform identifiers: Android gets `com.acme.shop_app`, while iOS gets a camelCased bundle ID, `com.acme.shopApp`. `--platforms` lists the targets whose folders are generated; without it every enabled platform gets one. Other useful switches: `--empty` for a minimal `main.dart` without the counter demo or its widget test, `-t` for `app`, `module`, `package`, `package_ffi` or `plugin`, and `--android-language` (Kotlin by default). Running `flutter create --platforms macos .` later inside the project adds a platform and reuses the existing organisation.

code

bash · 6 lines
bash
flutter create --org com.acme --platforms android,ios,web --empty shop_app
cd shop_app
# android/app/build.gradle.kts -> applicationId = "com.acme.shop_app"
# ios/Runner.xcodeproj      -> PRODUCT_BUNDLE_IDENTIFIER = com.acme.shopApp

flutter create --platforms macos .   # later: add macOS; org is read from existing files

go deeper

for a junior

Know the create command with --org and --platforms, that the folder name becomes the package name, and what --empty gives you.

for a middle

Explain how --org becomes each platform's identifier, why iOS and Android differ, and how re-running create adds a platform without touching existing files.

for a senior

Choose identifiers and platforms up front, knowing their cost to change later, and pick the right template: app, module, package, plugin or package_ffi.

for a principal

Set the team's project bootstrap standard: identifier scheme, target platforms, and whether new apps start from create --empty or an internal template.

## The command and its result ```bash flutter create --org com.acme --platforms android,ios,web shop_app ``` This creates a `shop_app/` directory holding a Flutter **application** (the default template): `lib/main.dart`, `pubspec.yaml`, `analysis_options.yaml`, a `test/` folder and one folder per requested platform — here `android/`, `ios/` and `web/`. By default it then runs `flutter pub get` (`--no-pub` skips that). The **project name** comes from the directory name unless you pass `--project-name`. It must be a valid Dart package name: lowercase words joined by underscores, not starting with a digit, not a reserved word. `flutter create ShopApp` fails and suggests a valid alternative. ## What --org controls `--org` takes the organisation in **reverse domain notation** and defaults to `com.example`. The tool combines it with the project name into each platform's identifier, and each platform has its own character rules: | Platform | Identifier built | Example for `com.acme` + `shop_app` | |---|---|---| | Android (application ID and Kotlin package) | org + name, underscores kept | `com.acme.shop_app` | | iOS and macOS (bundle identifier) | org + name in camelCase | `com.acme.shopApp` | | Linux | same scheme as Android | `com.acme.shop_app` | Two consequences interviewers like: - The Android and iOS identifiers **differ by default**. If the stores or a backend expect one identical string, change it in the platform projects deliberately. - Shipping with `com.example` is a mistake; store consoles reject or flag it. Choose `--org` at creation time, because changing it later means editing Gradle files, Xcode settings and package paths by hand. ## What --platforms controls `--platforms` (alias `--platform`) accepts `ios`, `android`, `windows`, `linux`, `macos` and `web`, plus `darwin` for plugins that share iOS and macOS code. Without it, the tool generates **every platform enabled** in the Flutter configuration. A platform whose feature is disabled with `flutter config` is skipped even if requested. The platform folders matter beyond the build: `flutter run` treats a device as usable **only if the project has that platform's folder**. With `android,ios,web`, a macOS desktop device is listed as found but not supported by this project. To add a platform later: 1. `cd shop_app` 2. `flutter create --platforms macos .` Re-running `create` on an existing project **repairs** it: it recreates missing files and leaves existing ones alone unless you pass `--overwrite`. When `--org` is omitted, it reads the organisation from the existing platform files, and stops if they disagree. ## Templates and other switches - **`-t app`** (default) — a runnable application. - **`-t module`** — a Flutter module to embed in an existing Android or iOS app. - **`-t package`** — shareable Dart code with no native parts. - **`-t plugin`** — a Dart API with platform implementations reached through method channels. - **`-t package_ffi`** — native code bound through `dart:ffi`; the older `plugin_ffi` template is deprecated in its favour. - **`--empty` / `-e`** — the app template with a minimal `main.dart` and no widget test; valid only for `app`. - **`--android-language`** — `kotlin` (default) or `java`. The old `--ios-language` option is deprecated and has no effect; generated iOS code is always Swift. - **`--description`** — the `description` written into `pubspec.yaml`. ## A sensible sequence 1. Decide the organisation and the real target platforms before running `create`. 2. Create with `--org`, `--platforms` and usually `--empty`. 3. Commit the result before adding anything, so later template changes show up as diffs.

  • Why are the Android and iOS identifiers different for the same --org and project name?
    Each platform has its own identifier rules. The tool keeps underscores for Android and Linux (`com.acme.shop_app`) but converts the name to camelCase and strips disallowed characters for Apple bundle identifiers (`com.acme.shopApp`). If you need one identical identifier everywhere, change it in the platform projects deliberately.
  • What happens if you run flutter create in a directory that already contains a Flutter project?
    It repairs the project: missing files, including folders for newly requested platforms, are recreated, and existing files are left alone unless `--overwrite` is passed. Without `--org`, the organisation is read from the existing platform files, and the tool stops if they disagree.

saying these in an interview costs you the question

  • Leaves --org at com.example for an app headed to the stores
  • Assumes Android and iOS always get identical identifiers
  • Names the project folder with capitals or hyphens
  • Deletes and recreates the project to add a platform
  • Thinks --ios-language objc still generates Objective-C code
open as a page

In Flutter, how do flutter devices, flutter emulators and flutter run -d work together to run an app on a chosen device?

level: juniorimportance: must knowfreq 58%

basics

~10 s

flutter devices lists connected devices with their ids, flutter emulators --launch starts an emulator or simulator, and flutter run -d <id or name prefix> runs on that device; -d all targets every device.

open as a page

In Flutter, what does the flutter doctor command check, and how do you read its markers and the extra detail flutter doctor -v adds?

level: juniorimportance: must knowfreq 72%

basics

~20 s

flutter doctor runs validators for the Flutter SDK, each host toolchain, connected devices and network access, marking each [✓] ready, [!] partial or [✗] missing with a fix hint; -v adds paths, revisions and timings.

open as a page

How do you install the Flutter SDK so flutter and dart work in any terminal, and what does flutter doctor flag when PATH is wrong?

level: juniorimportance: should knowfreq 40%

basics

~10 s

Extract the Flutter SDK to a user-writable folder and put its bin directory on PATH, which provides both flutter and dart. Doctor warns when either is missing from PATH or resolves outside that SDK.

open as a page

What does flutter clean delete in a Flutter project, and when does it fix a build rather than just slow the next one?

level: middleimportance: should knowfreq 48%

basics

~20 s

flutter clean deletes the project's build/ and .dart_tool/ directories, platform ephemeral folders and generated files, and cleans the Xcode workspace. It helps when stale generated state survives an SDK, plugin or config change; otherwise it only forces a slower full rebuild.

open as a page

In a Flutter app, what does flutter pub get do beyond dart pub get, and which flutter pub subcommands simply forward to pub?

level: middleimportance: should knowfreq 36%

basics

~20 s

flutter pub runs the Dart SDK bundled with Flutter as dart pub, so resolution is identical. After get, upgrade, add and remove it also regenerates the plugin list and platform tooling; other subcommands forward unchanged.

open as a page

In Flutter, what are the stable, beta and main channels, and how do flutter channel, flutter upgrade and flutter downgrade move the SDK?

level: middleimportance: should knowfreq 52%

basics

~20 s

The Flutter SDK is a git checkout and a channel is its branch: stable for production, beta monthly, main for contributors. flutter channel switches branch, flutter upgrade moves to the channel's latest release, flutter downgrade undoes the last upgrade.

open as a page

In Flutter, what do flutter config --jdk-dir and --android-sdk change, and how does the tool otherwise find a JDK and the Android SDK?

level: middleimportance: should knowfreq 32%

basics

~10 s

flutter config stores per-user overrides: --jdk-dir and --android-sdk pin the JDK and Android SDK paths. Without them Flutter tries Android Studio's JDK, then JAVA_HOME, then PATH, and reads ANDROID_HOME for the SDK.

open as a page

In Flutter, when would you use flutter attach instead of flutter run, and what does attach need to find and connect to the app?

level: seniorimportance: should knowfreq 30%

basics

~20 s

Use flutter attach when the app was launched by something other than flutter run, such as a native host embedding a Flutter module. It finds the app's Dart VM Service, or waits for it, and attaches a debug session.

open as a page

On a new laptop, flutter doctor marks the Android toolchain [!] with 'Android license status unknown' — how do you diagnose and fix it with the Flutter tool?

level: seniorimportance: should knowfreq 42%

basics

~20 s

Doctor checks licences by running the SDK's sdkmanager --licenses with the JDK it found; status unknown means that run failed. Install cmdline-tools, point Flutter at a working JDK, then run flutter doctor --android-licenses and accept.

open as a page

Why can flutter analyze fail a CI job on info-level diagnostics that dart analyze lets pass, and how do you control it?

level: middleimportance: nice to knowfreq 26%

basics

~10 s

flutter analyze treats info-level diagnostics as fatal by default, while dart analyze only fails on warnings and errors unless --fatal-infos is passed. Pass --no-fatal-infos to flutter analyze, or fix or reconfigure the infos.

open as a page