🍨 Deep Dive · Intermediate

Product flavor trên Windows và Linux trong Flutter 3.47

Build dev/staging/prod từng là chuyện riêng mobile. Flutter 3.47 mang flavor lên Windows và Linux.

Sơ đồ: Desktop Flavors

Asset theo flavor trong pubspec

flutter:
  assets:
    - path: assets/flavor_a/images
      flavors:
        - flavor_a
    - path: assets/flavor_b/images
      flavors:
        - flavor_b

Build

flutter build windows --flavor flavor_a
flutter build linux --flavor flavor_a

Vì sao team desktop quan tâm

  • App ID và icon tách biệt cho bản internal vs store.
  • API base URL khác nhau không cần hack string trong Dart.
  • CI matrix sinh được installer cạnh nhau.

Cạm bẫy

  • Ghép flavor với dart-define hoặc env compile-time — flavor tự nó không inject secret.
  • Packaging desktop (MSIX, deb/rpm, AppImage) vẫn có luật identity riêng.
#Flutter#Desktop#Flavors#Build