Local Setup
This guide will walk you through setting up and running the Flutter News App Mobile Client on your local machine.
-
Prerequisites
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.
- Flutter SDK: Please follow the Official Flutter Installation Guide for your specific operating system.
-
Set Up a Firebase Project (Required)
The mobile client requires a Firebase project for core features like push notifications. You will need to create your own Firebase project as the configuration files are not included in the source code.
-
Create a Firebase Project: Go to the Firebase Console and create a new project.
-
Add an Android App:
- In your Firebase project, add an Android app.
- The package name must match the one in the project:
com.example.flutter_news_app_mobile_client_full_source_code. - Download the generated
google-services.jsonfile.
-
Add an iOS App:
- In the same Firebase project, add an iOS app.
- The iOS bundle ID must match the one in the project:
com.example.flutterNewsAppMobileClientFullSourceCode. - Download the generated
GoogleService-Info.plistfile.
-
Place the Configuration Files:
- Place the
google-services.jsonfile in theandroid/app/directory of the mobile client project. - Place the
GoogleService-Info.plistfile in theios/Runner/directory of the mobile client project.
- Place the
-
-
Set Up OneSignal (Optional)
If you plan to use OneSignal for push notifications, create an account and a project on the OneSignal Dashboard. You will need the App IDs for Android and iOS from the Keys & IDs section of your OneSignal project settings.
-
Download the Latest Release
Download the source code of the latest release from the GitHub releases page for the Mobile Client:
- Mobile Client: https://github.com/flutter-news-app-full-source-code/flutter-news-app-mobile-client-full-source-code/releases/latest
After downloading and extracting the archive, navigate into the project directory.
-
Install Dependencies
Fetch all the required Dart and Flutter packages for the project:
Terminal window flutter pub get -
Configure the Environment
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.
Required Environment Variables
Section titled “Required Environment Variables”For a
developmentorproductionbuild, you must provide the following variables. The Firebase values can be copied directly from thegoogle-services.jsonandGoogleService-Info.plistfiles you downloaded earlier.APP_ENVIRONMENT:developmentorproduction.BASE_URL: The URL of your API server (e.g.,http://localhost:8080for local development).
OneSignal Keys:
ONE_SIGNAL_ANDROID_APP_ID: Your OneSignal Android App ID.ONE_SIGNAL_IOS_APP_ID: Your OneSignal iOS App ID.
Firebase Keys (from
google-services.json&GoogleService-Info.plist):FIREBASE_PROJECT_ID: fromproject_info.project_idFIREBASE_MESSAGING_SENDER_ID: fromproject_info.project_numberFIREBASE_STORAGE_BUCKET: fromproject_info.storage_bucketFIREBASE_ANDROID_API_KEY: fromclient[0].api_key[0].current_keyFIREBASE_ANDROID_APP_ID: fromclient[0].client_info.mobilesdk_app_idFIREBASE_IOS_API_KEY: from theAPI_KEYfield in your.plistfile.FIREBASE_IOS_APP_ID: from theGOOGLE_APP_IDfield in your.plistfile.
-
Run the Application
Start the application using one of the commands below. Ensure you have a simulator/emulator running or a physical device connected.
-
Demo Mode (Default): Runs the app with in-memory mock data. No backend API or extra variables are required, making it perfect for focusing on UI changes.
Terminal window flutter run -
Development Mode: Connects the app to a locally running instance of the API server. You must provide all the required
--dart-definevariables.Terminal window # Example for Androidflutter run \--dart-define=APP_ENVIRONMENT=development \--dart-define=BASE_URL=http://localhost:8080 \--dart-define=ONE_SIGNAL_ANDROID_APP_ID=YOUR_ONESIGNAL_ID \--dart-define=FIREBASE_ANDROID_API_KEY=YOUR_FIREBASE_ANDROID_API_KEY \# ... and all other required keys
The application will now launch on your selected device.
-