Flutter wrapper — bind your project to an explicit flutter release

passsy
May 30, 2018 · 5 min read
  1. manually added flutter to your PATH.

Don’t share the Flutter SDK across projects

Having a single Flutter SDK on you system, shared across all projects, isn’t practical. After updating Flutter you also have to update your apps or they’ll become incompatible with the latest Flutter release over time. If you’re working on multiple apps, this becomes pretty time consuming.

Missing Flutter SDK pinning

By default, Flutter projects don’t declare a Flutter SDK version which should be used to build the app. Coworkers aren’t able to determinate which version should be used without asking. There’s no hint in any file in the git repository. This makes it impossible to reproduce bugs because builds aren’t deterministic across machines.

dependencies:
  flutter:
    sdk: flutter
dependencies:
  flutter:
    sdk: flutterenvironment:
  flutter: "0.4.5-pre.57"

flutter-wrapper for the rescue

The flutter-wrapper is an executable in your project root called flutterw. When you execute ./flutterw run, it will checkout the correct commit of the Flutter SDK and then run your app.

Installing flutterw

Disclaimer: Only tested on OSX.

curl -sL https://raw.githubusercontent.com/passsy/flutter_wrapper/master/install.sh | bash -
Flutter Wrapper installed, initialized with channel master.Run your app with:     ./flutterw runSwitch channel:        ./flutterw channel beta
Flutter settings in IntelliJ

Benefits from having one SDK per project

Since I moved the Flutter SDK inside my projects, search became much easier. I can simply search my project folder and find all possible callers from my code, from the exact Flutter SDK I’m currently using.


grandcentrix

thoughts, stories and ideas | from the grandcentrix team | https://www.grandcentrix.net

passsy

Written by

passsy

Google Developer Expert for Flutter and passionate Android developer #kotlin working at @grandcentrix in Cologne

grandcentrix

thoughts, stories and ideas | from the grandcentrix team | https://www.grandcentrix.net