From 2e571fc1ccb854ed1a745626ae713ce6426dde5b Mon Sep 17 00:00:00 2001 From: fulleni Date: Fri, 24 Oct 2025 21:57:30 +0100 Subject: [PATCH 1/2] docs(local-setup): update mobile client and web dashboard environment configuration - Replace in-code environment configuration with dart-define flags - Add instructions for running in different environments using flutter run - Remove outdated lib/main.dart code references - Update step descriptions for running the applications - Remove physical device connection note for web dashboard setup --- .../docs/mobile-client/local-setup.mdx | 37 ++++++++++--------- .../docs/web-dashboard/local-setup.mdx | 37 ++++++++++--------- 2 files changed, 40 insertions(+), 34 deletions(-) diff --git a/src/content/docs/mobile-client/local-setup.mdx b/src/content/docs/mobile-client/local-setup.mdx index 0530760..93d571d 100644 --- a/src/content/docs/mobile-client/local-setup.mdx +++ b/src/content/docs/mobile-client/local-setup.mdx @@ -31,21 +31,22 @@ This guide will walk you through setting up and running the Flutter News App Mob 4. **Configure the Environment** - The mobile client can be run in different environments, allowing you to connect it to a live API, a local API, or run it with mock data for UI development. - - - Open the file `lib/main.dart`. - - Locate the `appEnvironment` constant. - - Set its value to one of the following: - - `AppEnvironment.demo`: **(Recommended for UI development)** Runs the app with in-memory mock data. No backend API is required, making it perfect for focusing on UI changes and component testing. - - `AppEnvironment.development`: Connects the app to a locally running instance of the API server (typically at `http://localhost:8080`). - - `AppEnvironment.production`: Connects the app to your live, deployed backend API. - - ```dart title="lib/main.dart" - // Use `AppEnvironment.demo` to run with in-memory data (no API needed). - // Use `AppEnvironment.development` to connect to a local backend API. - // Use `AppEnvironment.production` to connect to a live backend API. - const appEnvironment = AppEnvironment.demo; - ``` + The mobile client uses compile-time variables to configure its environment. This allows you to easily switch between mock data, a local API, or a live production API without changing the code. + + You can specify the environment by passing a `--dart-define` flag to the `flutter run` command. + + - **Demo (Default):** Runs the app with in-memory mock data. No backend API is required, making it perfect for focusing on UI changes and component testing. + ```bash + flutter run + ``` + - **Development:** Connects the app to a locally running instance of the API server. + ```bash + flutter run --dart-define=APP_ENVIRONMENT=development + ``` + - **Production:** Connects the app to your live, deployed backend API. You must also provide the base URL for your API. + ```bash + flutter run --dart-define=APP_ENVIRONMENT=production --dart-define=BASE_URL=https://your.api.com + ```