Skip to content

Commit 077d6b3

Browse files
committed
docs(mobile-client): rewrite local setup guide
- Restructured the content into a step-by-step format - Updated descriptions and removed redundant information - Added new section on environment configuration - Improved clarity and detailed explanations
1 parent 652414e commit 077d6b3

File tree

1 file changed

+39
-42
lines changed

1 file changed

+39
-42
lines changed
Lines changed: 39 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,65 @@
11
---
22
title: Local Setup
3-
description: Learn how to set up and run the Flutter mobile client on your local machine.
3+
description: A step-by-step guide to configuring and running the Flutter mobile client locally.
44
---
5-
import { Steps } from '@astrojs/starlight/components';
5+
import { Steps, Aside } from '@astrojs/starlight/components';
66

7-
This guide provides step-by-step instructions to get the Flutter mobile client running on your local machine for development and testing.
7+
This guide will walk you through setting up and running the Flutter News App Mobile Client on your local machine.
88

9-
## Prerequisites
9+
<Steps>
10+
1. **Prerequisites**
1011

11-
Before you begin, ensure you have the following installed on your system:
12-
- **Flutter SDK**: The mobile client is a Flutter application. Please follow the official [Flutter installation guide](https://flutter.dev/docs/get-started/install) for your operating system.
13-
- **An IDE**: A code editor like [VS Code](https://code.visualstudio.com/) with the Flutter extension or [Android Studio](https://developer.android.com/studio).
12+
Before you begin, you must have the Flutter SDK installed on your system. To ensure you are using the most up-to-date and accurate installation instructions, we recommend following the official guide directly from the Flutter team.
1413

15-
## Understanding the Environments
14+
- **Flutter SDK:** Please follow the [Official Flutter Installation Guide](https://flutter.dev/docs/get-started/install) for your specific operating system.
1615

17-
The application can be run in three different environments, configured in `lib/main.dart`:
16+
2. **Clone the Repository**
1817

19-
- `AppEnvironment.demo`: This is the default environment. It uses an in-memory data store (`DataInMemory`) populated with mock data. This is perfect for quickly running the app and exploring the UI without needing a live backend. The app also wraps itself in the `DevicePreview` package in this mode, allowing you to see how it looks on various devices.
20-
- `AppEnvironment.development`: This environment is configured to connect to a local instance of the API server. It uses the `DataApi` client to make live HTTP requests.
21-
- `AppEnvironment.production`: This environment points to your live, deployed API server.
18+
Open your terminal, navigate to your desired workspace directory, and clone the mobile client repository:
2219

23-
You can change the active environment by modifying the `appEnvironment` constant in `lib/main.dart`:
20+
```bash
21+
git clone https://github.com/flutter-news-app-full-source-code/flutter-news-app-mobile-client-full-source-code.git
22+
cd apps/flutter-news-app-mobile-client-full-source-code
23+
```
2424

25-
```dart title="lib/main.dart"
26-
// Define the current application environment (production/development/demo).
27-
const appEnvironment = AppEnvironment.demo;
28-
```
25+
3. **Install Dependencies**
2926

30-
## Dependency Injection
27+
Fetch all the required Dart and Flutter packages for the project:
3128

32-
The application's dependencies, such as repositories and data clients, are initialized in the `bootstrap.dart` file. This function reads the selected `AppEnvironment` and injects the appropriate data clients.
29+
```bash
30+
flutter pub get
31+
```
3332

34-
For example, in `demo` mode, it injects `AuthInmemory` and `DataInMemory` clients. In `development` or `production` mode, it sets up an `HttpClient` and injects `AuthApi` and `DataApi` clients to communicate with the backend. This clean separation makes the app highly testable and configurable.
33+
4. **Configure the Environment**
3534

36-
## Running the Application
35+
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.
3736

38-
<Steps>
39-
1. **Navigate to the Project Directory**
37+
- Open the file `lib/main.dart`.
38+
- Locate the `appEnvironment` constant.
39+
- Set its value to one of the following:
40+
- `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.
41+
- `AppEnvironment.development`: Connects the app to a locally running instance of the API server (typically at `http://localhost:8080`).
42+
- `AppEnvironment.production`: Connects the app to your live, deployed backend API.
4043

41-
Open your terminal and navigate to the mobile client's root directory:
42-
```sh
43-
cd apps/flutter-news-app-mobile-client-full-source-code
44+
```dart title="lib/main.dart"
45+
// Use `AppEnvironment.demo` to run with in-memory data (no API needed).
46+
// Use `AppEnvironment.development` to connect to a local backend API.
47+
// Use `AppEnvironment.production` to connect to a live backend API.
48+
const appEnvironment = AppEnvironment.demo;
4449
```
4550

46-
2. **Get Dependencies**
51+
<Aside>
52+
For the `development` environment, you must have the [API Server running locally](/docs/api-server/local-setup/) first.
53+
</Aside>
4754

48-
Run the following command to fetch all the required packages from `pubspec.yaml`:
49-
```sh
50-
flutter pub get
51-
```
55+
5. **Run the Application**
5256

53-
3. **Select a Device**
57+
Start the Flutter development server. Ensure you have a simulator/emulator running or a physical device connected.
5458

55-
Ensure you have a simulator running (iOS) or an emulator running (Android), or a physical device connected. You can see a list of available devices with:
56-
```sh
57-
flutter devices
59+
```bash
60+
flutter run
5861
```
5962

60-
4. **Run the App**
63+
The application will now be running on your selected device.
6164

62-
Start the application using the `flutter run` command. By default, this will launch the app in `demo` mode.
63-
```sh
64-
flutter run
65-
```
6665
</Steps>
67-
68-
The application should now be running on your selected device. Because it's in `demo` mode, you can immediately start exploring the UI and features with the pre-loaded mock data.

0 commit comments

Comments
 (0)