Skip to content

Commit 065f048

Browse files
committed
docs(web-dashboard): add deployment guide for Flutter web dashboard
- Cover essential steps for deploying the Flutter News App Web Dashboard - Include configuration for production, building the web application, choosing a hosting provider, and deploying the application - Provide examples using popular hosting services like Firebase Hosting, Vercel, Netlify, and GitHub Pages
1 parent 2c477ec commit 065f048

File tree

1 file changed

+75
-0
lines changed

1 file changed

+75
-0
lines changed
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
---
2+
title: 'Deployment: Web Dashboard'
3+
description: A guide to building and deploying the Flutter web dashboard to a production environment.
4+
---
5+
6+
import { Steps, Aside } from '@astrojs/starlight/components';
7+
8+
This guide covers the essential steps for deploying the Flutter News App Web Dashboard to a production hosting service.
9+
10+
<Steps>
11+
1. **Configure for Production**
12+
13+
Before building, you must configure the dashboard to connect to your live production API.
14+
15+
- Open the file `lib/main.dart`.
16+
- Locate the `appEnvironment` constant.
17+
- Set its value to `AppEnvironment.production`.
18+
19+
```dart title="lib/main.dart"
20+
// Use `AppEnvironment.production` to connect to a live backend API.
21+
const appEnvironment = AppEnvironment.production;
22+
```
23+
24+
<Aside>
25+
Ensure that the `baseUrl` for the `production` environment in `lib/app/config/app_config.dart` points to the correct URL of your deployed [API Server](/api-server/deployment/).
26+
</Aside>
27+
28+
2. **Build the Web Application**
29+
30+
Next, create a production-optimized build of the Flutter web app. This compiles the Dart code to JavaScript and bundles all necessary assets for web deployment.
31+
32+
Run the following command from the root of your web dashboard project:
33+
```bash
34+
flutter build web
35+
```
36+
This will generate a `build/web` directory containing all the static files for your web application.
37+
38+
3. **Choose a Hosting Provider**
39+
40+
You can deploy the contents of the `build/web` directory to any hosting service that supports static websites. Popular and easy-to-use choices include:
41+
42+
- [Firebase Hosting](https://firebase.google.com/docs/hosting)
43+
- [Vercel](https://vercel.com/)
44+
- [Netlify](https://www.netlify.com/for/web-applications/)
45+
- [GitHub Pages](https://docs.github.com/en/pages)
46+
47+
4. **Deploy the Application**
48+
49+
Follow the deployment instructions for your chosen hosting provider. The general process involves:
50+
51+
- Initializing the hosting service in your project directory.
52+
- Specifying the `build/web` directory as the public or publish directory.
53+
- Running the provider's deploy command from your terminal.
54+
55+
For example, if you were using Firebase Hosting, the commands would look something like this:
56+
57+
```bash
58+
# Install Firebase CLI (if you haven't already)
59+
npm install -g firebase-tools
60+
61+
# Log in to Firebase
62+
firebase login
63+
64+
# Initialize Firebase in your project
65+
firebase init hosting
66+
67+
# When prompted, set the public directory to "build/web"
68+
69+
# Deploy to Firebase Hosting
70+
firebase deploy
71+
```
72+
73+
Once the deployment is complete, your web dashboard will be live at the URL provided by your hosting service.
74+
75+
</Steps>

0 commit comments

Comments
 (0)