Flutter

Google SDK for building cross platform apps.

  • Dart Language
  • Flutter is single threaded and runs on an event loop, similar to Node

Getting Started

  • Setup dependencies
sudo pacman -S flutter
sudo yay -S flutter
# install android-studio
  • Check for missing dependencies with flutter doctor -v
  • Disable Google Analytics Reports with flutter config --no-analytics
  • Add current user to flutter users with sudo gpasswd -a $USER flutterusers
    • or if that doesn’t work sudo chown -R $USER:$USER /opt/flutter
  • Update to the latest version with flutter upgrade
  • Download flutter dev dependencies flutter upgrade

Troubleshooting

Chrome executable not found

# set chrome executable for arch
export CHROME_EXECUTABLE=google-chrome-stable

Missing sdkmanager

Install the Android SDK Command-Line Tools using the Android Studio SDK-Manager. Then accept the licenses with:

flutter doctor --android-licenses

Learned Concepts

  • Flutter Stateless Widgets
  • Flutter Stateful Widgets
  • Flutter Inherited Widgets
  • Flutter Keys
  • Flutter Isolates for proper Multithreading
  • Flutter Async for non-blocking synchronous Work

Best Practises

Prefer creating new Widgets over using helper methods

Extracting common functionality into a new Widgets has following benefits:

  • Isolating redrawing of UI changes to the current Widgets
  • Prefer const constructors wherever possible to enable short circuiting
  • Making the component more easily Testable
  • Avoids stale build contexts Source: Youtube