VSCode Multi-Root Magic: Run Flutter APK Builds in Separate Git Repos

TL;DR

Stuck with “No pubspec.yaml found” when building Flutter APKs in a multi-root VSCode workspace? Fix it in 3 steps:

  • perfect workspace naming,
  • cwd overrides,
  • emulator-ready URLs.

The Problem

  • Top-level folder with 2 separate Git repos:
    • flutter_app/ (Flutter)
    • fastapi_backend/ (Python)
  • Flutter .vscode/tasks.json ignored in parent.
  • Tasks fail: “Must be run from root of Flutter project” or “No pubspec.yaml found”.
Continue Reading »

Dynamic Values when buiding Flutter app

Let me explain the usecase

I’m working on a flutter app that talks to REST API. During the development, the server wil lbe on localhost but in production it would be real server.

Solution ? Use --dart-define

Way to do this is pass the value during the build time like flutter build apk --dart-define=BASE_URL=http://10.0.2.2:8000

10.0.2.2 is a special alias to your host machine from within the Android emulator. 1 When running the app on an Android emulator, it allows access to your local development server.

Continue Reading »

How to use real android device for flutter development

I recently started learning Flutter. My 10 year old MBP with 8GB RAM is apparently not “enough” based on this documentation

It “recommends” 32GB RAM.

Lowest number listed is 8GB, but it means I can’t use Android Emulator, which seems like most common way to test the app during the development phase.

But I do have a real android device, can I use that instead ?

But most documentation talks/assumes emulator.

This does have information about using physical device, but I think it glosses over the instructions at a very high level.

Continue Reading »