• Courses
  • YouTube
  • Dev News
  • Technology
  • Blogs
  • Flutter Jobs
  • Contact
    • About Us
    • RegisterLogin
    Navoki
    • Courses
    • YouTube
    • Dev News
    • Technology
    • Blogs
    • Flutter Jobs
    • Contact
      • About Us
    • RegisterLogin

      Developers

      • Home
      • Blog
      • Developers
      • 14 Flutter Commands a Developer must know, Cheat Sheet
      Flutter Commands A Developer Must Know, Cheat Sheet

      14 Flutter Commands a Developer must know, Cheat Sheet

      • Posted by Shivam Srivastava
      • Categories Developers, Flutter, Flutter Desktop, Flutter Mobile, Flutter Web
      • Date January 28, 2021
      • Comments 0 comment
      Spread the love
      Contents hide
      1 Where to run flutter commands ?
      2 Flutter Doctor
      3 Flutter Upgrade
      4 Flutter Packages Get
      5 Flutter Create Project
      5.1 1. Create a new project in Flutter
      5.2 2. New flutter project with custom package name
      5.3 3. Flutter project with different app name and folder name
      5.4 4. Flutter project with platform-specific native language
      5.5 5. Change native language in existing project
      5.6 5. Re-Create default original files in Flutter project
      5.7 6. Add other platform support to Flutter project
      6 Flutter Devices
      6.1 Get list of all devices supported by flutter SDK
      7 Flutter Run
      7.1 1. Run project on single device
      7.2 2. Run app on specific device
      7.3 3. Run app on specific device with detailed analysis
      7.4 4. Run app with target main.dart app launcher
      8 Flutter Channel
      9 Flutter Logs
      10 Flutter Clean
      11 Flutter Build
      11.1 1. Flutter build release version of flutter app
      11.2 2. Flutter build release with specific version and build name
      11.3 3. Flutter build debug version of flutter app
      12 Flutter Install
      12.1 1. Install already build executable flutter app
      12.2 2. Uninstall old version and Install already build executable flutter app
      12.3 3. Uninstall old version of flutter app
      13 Flutter Attach
      14 Flutter Config
      14.1 1. Enable Flutter Desktop support in Flutter SDK
      14.2 2. Enable Flutter Web support in Flutter SDK
      14.3 3. Set Android SDK path to Flutter SDK
      14.4 4. Set Android Studio path to Flutter SDK
      14.5 5. Reset Flutter Config to default values
      15 Flutter Format
      15.1 1. Format dart code on full project
      15.2 2. Format dart code on single file
      15.3 3. Format all dart code within lib folder
      15.4 4. Check if formatting is required on flutter project
      15.5 5. Change length of formatting lines in dart code
      16 Conclusion
      16.1 Please login to bookmark



      Hi, my name is Shivam, This is a flutter tutorial for beginners, some useful flutter commands or cli commands that a developer should know or you can say flutter commands cheat sheet. These list of flutter commands executed on command prompt.

      NOTE: There are still some commands left which will be updated soon in this article. If you feel any change required in this article please comment below.

      Where to run flutter commands ?

      You must be already using IntelliJ or Android Studio or VSCode, these IDE are already using these commands in the background to make your work easier by a single click. If you are working in any programming languages or framework, you should know their commands line execution. All commands are executed at my desired location C:\Users\TheDoctor\NavokiProjectsPractice\sample\ path as root directory. To install and flutter setup you can refer this article.

      Ready1 | 14 Flutter Commands A Developer Must Know, Cheat Sheet


      Flutter Doctor

      To know your flutter SDK is set up correctly and compatible with platforms, devices and IDE, type this flutter cli command, it gives you a brief description of tools and devices required for flutter development and then you can configure you flutter project.

      flutter doctor

      OUTPUT:

      Doctor summary (to see all details, run flutter doctor -v):
      [√] Flutter (Channel master, 1.26.0-13.0.pre.122, on Microsoft Windows [Version 10.0.18363.1316], locale en-IN)
      [X] Android toolchain - develop for Android devices
          X Unable to locate Android SDK.
            Install Android Studio from: https://developer.android.com/studio/index.html
            On first launch it will assist you in installing the Android SDK components.
            (or visit https://flutter.dev/docs/get-started/install/windows#android-setup for detailed instructions).
            If the Android SDK has been installed to a custom location, please use
            `flutter config --android-sdk` to update to that location.
      
      [√] Chrome - develop for the web
      [X] Visual Studio - develop for Windows
          X Visual Studio not installed; this is necessary for Windows development.
            Download at https://visualstudio.microsoft.com/downloads/.
            Please install the "Desktop development with C++" workload, including all of its default components
      [!] Android Studio (not installed)
      [√] Connected device (2 available)
      


      To know more about these in details type 

      flutter doctor -v

      OUTPUT:

      Doctor summary (to see all details, run flutter doctor -v):
      [√] Flutter (Channel master, 1.26.0-13.0.pre.122, on Microsoft Windows [Version 10.0.18363.1316], locale en-IN)
      [X] Android toolchain - develop for Android devices
          X Unable to locate Android SDK.
            Install Android Studio from: https://developer.android.com/studio/index.html
            On first launch it will assist you in installing the Android SDK components.
            (or visit https://flutter.dev/docs/get-started/install/windows#android-setup for detailed instructions).
            If the Android SDK has been installed to a custom location, please use
            `flutter config --android-sdk` to update to that location.
      
      [√] Chrome - develop for the web
      [X] Visual Studio - develop for Windows
          X Visual Studio not installed; this is necessary for Windows development.
            Download at https://visualstudio.microsoft.com/downloads/.
            Please install the "Desktop development with C++" workload, including all of its default components
      [!] Android Studio (not installed)
      [√] Connected device (2 available)
      
      ! Doctor found issues in 3 categories.
      PS C:\Users\Navoki\FlutterProjects\my_flutter_commands_app> flutter doctor -v                                           [√] Flutter (Channel master, 1.26.0-13.0.pre.122, on Microsoft Windows [Version 10.0.18363.1316], locale en-IN)
          • Flutter version 1.26.0-13.0.pre.122 at C:\Users\Navoki\flutter
          • Framework revision e599cdd414 (4 days ago), 2021-01-22 11:07:08 -0800
          • Engine revision 90641fa923
          • Dart version 2.12.0 (build 2.12.0-248.0.dev)
      
      [X] Android toolchain - develop for Android devices
          X Unable to locate Android SDK.
            Install Android Studio from: https://developer.android.com/studio/index.html
            On first launch it will assist you in installing the Android SDK components.
            (or visit https://flutter.dev/docs/get-started/install/windows#android-setup for detailed instructions).
            If the Android SDK has been installed to a custom location, please use
            `flutter config --android-sdk` to update to that location.
      
      [√] Chrome - develop for the web
          • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe
      [X] Visual Studio - develop for Windows
          X Visual Studio not installed; this is necessary for Windows development.
            Download at https://visualstudio.microsoft.com/downloads/.
            Please install the "Desktop development with C++" workload, including all of its default components
      
      [!] Android Studio (not installed)
          • Android Studio not found; download from https://developer.android.com/studio/index.html
            (or visit https://flutter.dev/docs/get-started/install/windows#android-setup for detailed instructions).
      
      [√] Connected device (2 available)
          • Windows (desktop) • windows • windows-x64    • Microsoft Windows [Version 10.0.18363.1316]
          • Chrome (web)      • chrome  • web-javascript • Google Chrome 88.0.4324.104
      ! Doctor found issues in 3 categories.
      



      Flutter Upgrade

      To download and update your flutter SDK current branch. You have to upgrade for each flutter channel, if you switch the channel. Run this flutter command

      flutter upgrade



      Flutter Packages Get

      This flutter cli command downloads and includes the package used in the flutter project. If the package is already downloaded, it will use offline package stored in flutter SDK.

      flutter packages get


      (adsbygoogle = window.adsbygoogle || []).push({});


      Flutter Create Project

      1. Create a new project in Flutter

      Suppose you want to create flutter project name my_flutter_commands_app , by default flutter create projects to support Android and iOS platform. You can add other platforms also more is given about this in topics below then the flutter command would be:

      flutter create my_flutter_commands_app

      OUTPUT:

      Flutter Project Structure


      2. New flutter project with custom package name

      Suppose you want to make the package name com.navoki.my_flutter_commands_app , where navoki.com is your organization’s web address. You have to use --org parameter, then cli command would be:

      flutter create --org=com.navoki  my_flutter_commands_app

      You can check applicationID in Android project

      Flutter Project Applicationid



      3. Flutter project with different app name and folder name

      While creating a new project, you can set specific <app-name> that will appear in flutter package name and in applicationID, while the folder name can be different. You have to use --project-name parameter

      flutter create --org=com.navoki --project-name=navoki my_flutter_commands_app


      4. Flutter project with platform-specific native language

      The native platform Android supports two languages Java and Kotlin (default). The native platform for iOS supports two languages Objective C and Swift (default). If you don’t specify any language, then default languages are selected codes will be generated

      Select native language in Android platform use parameter

      flutter create --org=com.navoki --android-language=java my_flutter_commands_app


      Select native language in iOS platform use parameter

      flutter create --org=com.navoki --ios-language=objc my_flutter_commands_app


      5. Change native language in existing project

      Suppose you already have a working project and want to change the native language of a specific platform. In that case, you can delete that platform folder and run command for a particular platform as mentioned on the above topic.
      It will create a new folder of that platform with a new language code and files. You may have to set up your existing project and their respective packages according to the new platform language like you may have to recode your logic according to new platform-specific language.

      flutter create --org=com.navoki --android-language=java --ios-language=objc my_flutter_commands_app


      5. Re-Create default original files in Flutter project

      Sometimes, by mistake you have deleted a file, so you want to re-create those original flutter codes and files. Still, you do not wish to override all the work you have done on another file in the flutter project. Then you can specify the parameter that does not overwrite the existing files of the project but create new files that are missing in default flutter projects. You have to use --no-overwrite parameter, by default its uses --overwrite.

      flutter create --no-overwrite --org=com.navoki my_flutter_commands_app


      6. Add other platform support to Flutter project

      By default flutter at support for Android and iOS platform, since flutter is a cross-platform framework, you can also add other platforms like flutter for Web and flutter for desktop app for Windows, Linux and MacOS. In an existing project go to app directory say my_flutter_commands_app, type these commands make sure you don’t miss dot(.) in the end. These commands will be available in the master branch of flutter SDK, so switch to master channel using flutter command,

      flutter channel master

      Windows Flutter Desktop App Support

      flutter create --platforms=windows .


      MacOS Flutter Desktop App Support

      flutter create --platforms=macos .


      Linux Flutter Desktop App Support

      flutter create --platforms=linux .


      Flutter Web App Support

      flutter create --platforms=web .

      If you want to make your Desktop app see course QR Code Generator and if you want to make web app then see course Flutter Web with Github Pages.



      Flutter Devices

      Get list of all devices supported by flutter SDK

      flutter devices

      OUTPUT:

      ONEPLUS A6010 (mobile)  • 64519b22      • android-arm64 • Android 10 (API 29)
      iPhone 8 Plus (mobile) • e5rx554rtdsskhna  • ios  • com.apple.CoreSimulator.SimRuntime.iOS-14-0 (simulator)
      macOS (desktop)        • macos   • darwin-x64   • Mac OS X 10.15.5 19F101
      Windows (desktop) • windows • windows-x64  • Microsoft Windows [Version 10.0.18363.1316]
      Linux (desktop) • linux • linux-x64 • Linux
      Chrome (web)   • chrome  • web-javascript • Google Chrome 88.0.4324.104
      Web Server • web-server • web-javascript • Flutter Tools
      

      In OUTPUT within each line 2nd parameter is called device-id which you will use to target devices for running apps as explained below.

      (adsbygoogle = window.adsbygoogle || []).push({});


      Flutter Run

      1. Run project on single device

      If your have single device for target platform on device list then run app using command

      flutter run


      2. Run app on specific device

      If your have multiple devices for target platform like android device is connected and emulator is also running.

      ONEPLUS A6010 (mobile)             • 64519b22      • android-arm64 • Android 10 (API 29)
      Android SDK built for x86 (mobile) • emulator-5554 • android-x86   • Android 10 (API 29) (emulator)

      then run app using command by specifying target device-id

      flutter run -d 64519b22


      3. Run app on specific device with detailed analysis

      If any error comes during flutter run commands and app doesn’t launch then add -v to get execution in details and know on which task app run failed.

      flutter run -d <device-id> -v


      4. Run app with target main.dart app launcher

      It may be possible you are working on flutter project on a different platform or different flavors, and you might have two or more launcher dart files say main.dart for mobile app main_win.dart for windows app. You can specify the target launcher file to launch the app.

      flutter run -d 64519b22  -t lib/main.dart  // for mobile
      flutter run -d windows -t lib/main_win.dart  // for windows desktop



      Flutter Channel

      Flutter Framework is in continuous development, and most developers use stable (default) channel of flutter SDK for Android and iOS. You have to switch the channel for development on other platforms or some new experimental/beta feature. If you don’t know any channel name, type

      flutter channel

      OUTPUT:

      Flutter channels:
        master
        dev
        beta
      * stable

      To change channel in flutter sdk, command would be

      flutter channel <channel-name>



      Flutter Logs

      You can see all debugPrint() in release app also. It happens many times that flutter debugger connection lost during app usage, but you can still see all print() flutter logs to console.

       flutter logs -d <device-id>

      OUTPUT:

      Showing ONEPLUS A6010 logs:
      I/flutter (  970): Observatory listening on http://127.0.0.1:39351/qfLRTS2mdgs=/
      I/flutter (  970): Count 1
      I/flutter (  970): Count 2
      I/flutter (  970): Count 3



      Flutter Clean

      Deletes all temporary folders from the project including flutter and native files and folders like build folder, iosbuild, Generated.xcconfig etc.

       flutter clean


      (adsbygoogle = window.adsbygoogle || []).push({});


      Flutter Build

      1. Flutter build release version of flutter app

      The last stage of flutter development is to build an executable file of app release on the app store. To create the final release executable for that platform. here --release by default.

       flutter build <target-platform-name> --release

      Target Names are
      Android – apk or appbundle
      iOS – ios
      Desktop App – windows ,macos, linux depends on desktop OS
      WebApp – web

      2. Flutter build release with specific version and build name

      Flutter app release file can be generated with required version name and build number can be changed from command line. This flutter command is for Android and iOS only.

       flutter build apk --build-number=8 --build-name=2.0.1


      3. Flutter build debug version of flutter app

      Flutter can also generate debug of flutter app

       flutter build <target-platform-name> --debug


      En | 14 Flutter Commands A Developer Must Know, Cheat Sheet



      Flutter Install

      1. Install already build executable flutter app

      Suppose we have already run the flutter run or flutter build command. Then the build folder already has debugged apk file or executable file for the target platform. If you want to install / re-install this executable app on the platform without going thru build process again, then type

      flutter install -d <target-platform-name>


      2. Uninstall old version and Install already build executable flutter app

      flutter install --no-uninstall-only -d <target-platform-name


      3. Uninstall old version of flutter app

      flutter install --uninstall-only -d <target-platform-name> 



      Flutter Attach

      If during debugging flutter lost the connection then you can’t use Hot-Reload or Hot-Restart changes in app. Instead of re-building and install the new app, you can attach with existing installed app.

      flutter attach -d <target-platform-name> 

      Now you can make changes to your code and do Hot-Reload and Hot-Restart


      (adsbygoogle = window.adsbygoogle || []).push({});



      Flutter Config

      Using this command, you can enable flutter desktop and flutter web support for other platforms which are disabled by default. After enabling them, you need to restart your terminal or IDE

      1. Enable Flutter Desktop support in Flutter SDK

      flutter config --enable-<platform-name>-desktop  // platform-name= windows,macos,linux


      2. Enable Flutter Web support in Flutter SDK

      flutter config --enable-web


      3. Set Android SDK path to Flutter SDK

      If in flutter doctor, SDK cannot find android SDK on your system then set path manually by

      flutter config  --android-sdk <path-to-android-sdk>


      4. Set Android Studio path to Flutter SDK

      If in flutter doctor, SDK cannot find Android Studio on your system then set path manually by

      flutter config  --android-studio-dir <path-to-android-sdk>


      5. Reset Flutter Config to default values

      flutter config  --clear-features



      Flutter Format

      Formatting (wrap to next line) your code is very common using your IDE, but what if you don’t have any IDE. You can use below commands to format your code after the length of every 80 characters (default).

      1. Format dart code on full project

      flutter format .


      2. Format dart code on single file

      flutter format lib/main.dart


      3. Format all dart code within lib folder

      flutter format lib/widgets


      4. Check if formatting is required on flutter project

      This command only check if the format is required in files and returns the file name where required, but it doesn’t format codes.

      flutter format --dry-run lib


      5. Change length of formatting lines in dart code

      By default code is wrapped to next line if line has more than 80 characters(default). You can change this limit

      flutter format --line-length=100 <folder-or-dart-file-name>



      Conclusion

      Similarly to flutter SDK, dart programming language also has many list of commands that a developer should, that will be covered in another article. If you like this article Share and Subscribe my Youtube Channel. Follow my on Twitter and LinkedIn


      Bookmark(1)

      Please login to bookmark

      Continue with Google
      +1

      Tag:clean flutter project, cli commands, create flutter project, dart programming language, flutter channel, flutter commands, flutter console log, flutter create project with package name, flutter for desktop, flutter for web, flutter tutorial for beginners, how to create flutter project

      • Share:
      author avatar
      Shivam Srivastava

      Mobile Solution [email protected], Android and Flutter Dev, Dart ,Founder of @Navoki, Instructor

      Previous post

      6 Things About HTTP Request in Dart For Beginners
      January 28, 2021

      Next post

      Flutter 2 is here | What's new in Flutter 2.0.0
      March 22, 2021

      You may also like

      everything-about-flutter-3-in-google-i-o-2022 navoki.com
      Everything about Flutter 3 in Google I/O 2022
      12 May, 2022
      Flutter-Web-CORS-Error-SOLVED-Navoki.com
      [SOLVED] Flutter Web CORS Error
      4 May, 2022
      How Video Call works in Flutter
      How Incoming Video Call Notification works in Flutter
      15 April, 2022

      Leave A Reply Cancel reply

      You must be logged in to post a comment.


      Categories

      • Android
      • Dart
      • Dart Server
      • Dart Web
      • Developers
      • Flutter
      • Flutter Desktop
      • Flutter Mobile
      • Flutter Web
      • Fuchsia
      • Go Lang
      • Technology
      • Uncategorized

      Recent Post

      • Everything-About-Flutter-3-In-Google-I-O-2022 Navoki.comEverything about Flutter 3 in Google I/O 2022
      • Flutter-Web-Cors-Error-Solved-Navoki.com[SOLVED] Flutter Web CORS Error
      • How Video Call Works In FlutterHow Incoming Video Call Notification works in Flutter

      Subscribe Now

       

      Recent Courses

      Single And Multi Selection Listview In Flutter

      Single and Multi Selection ListView in Flutter

      Go Installation And Variables

      Go Installation and Variables

      List In Dart Programming Language

      List in Dart Programming language

      Variables In Dart Programming Language

      Variables in Dart Programming language

      View All

      DON’T MISS
      FLUTTER UPDATES

      Be the first to know when our blog is published.

      flutter-mobile-mockup

      Check your inbox or spam folder to confirm your subscription.

      Contact

      •   Navoki Technologies Pvt. Ltd.
        JMD Megapolis , Sector 48, Gurugram, Haryana 122018

      Company

      • About Us
      • Blogs
      • Contact
      • Privacy policy
      • Terms & Condition

      Useful Links

      • Courses
      • Youtube
      • Dev News

      Mobile

      Click and Get started in seconds

      "Navoki" is a registered trademark of Navoki.com ® 2020–2030 Navoki Technologies Pvt Ltd.

      • Terms & Condition

      Login with your site account

      Continue with Google

      By "Sign in” above to accept Navoki’s Terms of Service & Privacy Policy.

      Not a member yet? Register now

      Register a new account

      Continue with Google

      By "Sign Up” above to accept Navoki’s Terms of Service & Privacy Policy.

      Are you a member? Login now

      We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.OkPrivacy policy