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.