System Requirements
Operating System:
- Windows: 10 or higher
- macOS: 10.14 Mojave or higher
- Linux: Any distribution that supports Flutter
Hardware Requirements:
- RAM: Minimum 8 GB (16 GB recommended)
- Disk Space: At least 10 GB free
- Processor: Intel i3 or equivalent (i5 or higher recommended)
- Graphics: A GPU that supports hardware acceleration (optional but recommended for smoother development experience)
Software Requirements:
- Flutter SDK: Version 3.6.0
- Dart SDK: Comes with the Flutter SDK
- Android Studio: Latest version (with Android SDK tools)
- Xcode: Latest version (for iOS development, macOS only)
- Visual Studio Code (Optional): Recommended for code editing
- Git: Version control system
Installing Flutter SDK
Step 1: Download Flutter SDK
- Visit the Flutter official website and download the latest stable version of the Flutter SDK for your operating system.
Step 2: Extract and Add to Path
- Extract the Flutter SDK to a location of your choice.
- Add the Flutter tool to your system path:
- Windows: Add
flutter/bin
to the PATH
environment variable.
- macOS/Linux: Add
export PATH="$PATH:
flutter/bin"
to your shell configuration file (e.g., .bashrc
, .zshrc
).
Step 3: Verify Installation
flutter doctor
- Follow the prompts to install any missing dependencies (e.g., Android SDK, Xcode).
Setting Up the IDE
Visual Studio Code (Optional)
- Install Visual Studio Code from the official website.
- Install the following extensions from the VSCode Marketplace:
- Flutter: Provides Flutter support and tools.
- Dart: Provides Dart language support.
- GitLens: Enhances Git capabilities in VSCode.
Android Studio
- Install Android Studio from the official website.
- During installation, ensure that you also install the Android SDK, Android SDK Command-line Tools, and an Android Virtual Device (AVD).
- After installation, open Android Studio and go to Plugins in the settings. Search for and install the Flutter and Dart plugins.
Xcode (macOS Only)
- Install Xcode from the Mac App Store.
- Open Xcode and install additional components when prompted.
- Go to Preferences > Locations and ensure that the Command Line Tools are set to the latest version of Xcode.
Cloning the Project Repository
Step 1: Clone the Repository
- Open a terminal and navigate to the directory where you want to clone the project.
- Run the following command:
git clone https://gitlab.com/rifqidmw/base-flutter.git
cd base-flutter
Step 2: Install Dependencies
- Run the following command to install all necessary dependencies:
flutter pub get
- This will download and install the packages listed in
pubspec.yaml
.
Setting Up Environment Variables
AppEnvironment
class is located in the core
folder of your project. This class is responsible for managing different environments (SIT, UAT, Preprod, Prod) by setting the baseApiUrl
and title
for each environment.
- Location: The
AppEnvironment
class is found in lib/core/app_environment.dart
.
- Code:
enum Environment { sit, uat, preprod, prod }
abstract class AppEnvironment {
static late String baseApiUrl;
static late String title;
static late Environment _environment;
static Environment get environment => _environment;
static setupEnv(Environment env) {
_environment = env;
switch (env) {
case Environment.sit:
baseApiUrl = 'https://sit.dummyjson.com';
title = 'SIT';
break;
case Environment.uat:
baseApiUrl = 'https://uat.dummyjson.com';
title = 'UAT';
break;
case Environment.preprod:
baseApiUrl = 'https://preprod.dummyjson.com';
title = 'PRE PROD';
break;
case Environment.prod:
baseApiUrl = 'https://dummyjson.com';
title = 'PROD';
break;
}
}
}
Running the Project
Step 1: Run on Android
- Ensure that an Android emulator is running or connect a physical device.
- In the terminal, run:
flutter run
- Select the target device if prompted.
Step 2: Run on iOS (macOS Only)
- Ensure that an iOS simulator is running or connect a physical iOS device.
- Run the following command:
flutter run
- Select the iOS device from the device list if prompted.