DEV Community

Cover image for Flutter
Maxime HEBRARD
Maxime HEBRARD

Posted on

Flutter

If you want to develop an application for mobile, you should probably look into Flutter, that allow to deploy the same code base on Android, IOS and web.
If your goal is to deploy on IOS, you will need to use a Mac, have an Apple ID and Xcode

Following the instructions from (Flutter)[https://docs.flutter.dev/get-started/install)

Install Xcode (to build for IOS)

  • If you are using an Apple Silicon, enable rosetta translation
sudo softwareupdate --install-rosetta --agree-to-license
Enter fullscreen mode Exit fullscreen mode
  • Install Xcode
    • Open App Store
    • Search for Xcode
    • Click on 'Get'
    • Click on 'Install'
    • Click on 'Open'
    • Setup Xcode for Flutter
  sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
  sudo xcodebuild -runFirstLaunch
Enter fullscreen mode Exit fullscreen mode
  • Install Cocoapods
brew install cocoapods
Enter fullscreen mode Exit fullscreen mode

Install Flutter SDK

  • Install Flutter extension for VSCode
    • Open VSCode
    • Navigate to 'Extensions'
    • Search 'Flutter'
    • Click on 'Install'
    • Click on 'Trust Publisher & Install'
  • Install the Flutter SDK
    • Open VSCode
    • Open the Command Palette (Press Command + Shift + P)
    • Search 'flutter'
    • Select 'Flutter: New Project'
    • Click on 'Download SDK'
    • Click on 'Clone Flutter'
  • Add Flutter to the PATH

    • Edit .zshrc
    vim .zshrc
    
    • Press 'i' to enter insert mode
    • Add the content as follow
    • replace [Pathto] by the correct path
    export PATH=$HOME/[Pathto]/flutter/bin:$PATH
    
    • Press 'esc' to exit insert mode
    • Press ':' and 'x' end 'return' to save and quit the file
    • Update Terminal
    source .zshrc
    

Install Android studio (to build for Android)

  • Install Android studio
brew install --cask android-studio
Enter fullscreen mode Exit fullscreen mode
  • Launch adroid studio

    • Install Type: Standard
    • Accept the licences
    • Finish the installation
    • In android studio top menu, select 'Android studio' / 'Settings...'
    • Search for 'Android SDK'
    • In 'SDK Platforms' tab, check 'Android 15.0 ("VanillaIceCream") 35'
    • In 'SDK Tools' tab, check
    • 'Android SDK Build Tool'
    • 'Android SDK Command-line Tool'
    • 'Android Emulator'
    • 'Android SDK Platform-Tools'
    • Click on 'Apply'
    • Click on 'OK'
    • Click on 'Finish'
    • Click on 'OK'
  • Close Android studio

  • Accept android licences

flutter doctor --android-licenses
Enter fullscreen mode Exit fullscreen mode
  • Accept the licences

Check Flutter install

At any time you can check which element of flutter are missing and get some instructions to solve the issue

flutter doctor
Enter fullscreen mode Exit fullscreen mode

flutter doctor

My first app

Flutter game basic template

dart pub global activate sample_downloader
Enter fullscreen mode Exit fullscreen mode
  • Navigate to the parent direct where you want the application to be created
  • Run the downloader
sample_downloader
Enter fullscreen mode Exit fullscreen mode
  • Follow the instructions of the downloader
    • Do you want to use your environment's GitHub credentials? > 1) Yes
    • Choose sample: > 4) templates/basic
    • Enter name of new directory (ENTER for flutter-games-basic): ENTER

GitHub repository

  • Create a new GitHub repository named flutter_match3 for example
  • Clone the repository on you machine
  • Create a new branch feature/flutter-basic
  • Copy the content of flutter-games-basic into flutter_match3 (you can keep or replace the README.md as you see fit)
  • Navigate to the GitHub repo
cd flutter_match3/
Enter fullscreen mode Exit fullscreen mode
  • Stage all changes
  • Commit changes

Update the template configuration

  • Update android/build.gradle
ext.kotlin_version = '2.1.21'
Enter fullscreen mode Exit fullscreen mode
  • Update android/settings.gradle
id "com.android.application" version "8.4.0" apply false
Enter fullscreen mode Exit fullscreen mode
  • Update android/gradle/wrapper/gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-all.zip
Enter fullscreen mode Exit fullscreen mode
  • Stage all changes
  • Commit changes

Add mobile simulators

  • Select lib/main.dart
  • From the bottom menu, click on 'macos (darwin)'
  • In the top drop down, select 'Start flutter emulator'
  • Also Start IOS emulator
  • Run the app
flutter clean
flutter pub get
flutter run
Enter fullscreen mode Exit fullscreen mode

You can select the device you prefer and run the app

app running

Top comments (0)

Some comments may only be visible to logged-in visitors. Sign in to view all comments.