Flutter App - Getting Started
Flutter Development Setup
Complete guide to set up your development environment and get the Axe VPN Flutter app running on your local machine. Follow these steps to start developing and customizing the mobile application.
Prerequisites
Windows
- • Windows 10 (64-bit) or later
- • Minimum 8 GB RAM
- • 10 GB free disk space
- • Git for Windows
macOS
- • macOS 10.14 (Mojave) or later
- • Xcode 12.0 or later
- • CocoaPods installed
- • Command Line Tools
Android
- • Android device (API level 21+)
- • USB debugging enabled
- • Android Studio installed
- • Android SDK configured
iOS (macOS only)
- • iOS device or simulator
- • iOS 11.0 or later
- • Apple Developer account
- • Xcode with iOS SDK
Flutter SDK Setup
1. Download Flutter SDK
Download the latest stable Flutter SDK from the official website:
2. Install Flutter SDK
- Extract the downloaded ZIP file to a location like
C:\flutter
- Add Flutter to your PATH environment variable:
# Add to your PATH environment variable
C:\flutter\bin
- Open a new command prompt and verify installation:
flutter --version
flutter doctor
- Extract the downloaded file to your desired location:
cd ~/development
unzip ~/Downloads/flutter_macos_*-stable.zip
- Add Flutter to your PATH by editing your shell profile:
# Add to ~/.zshrc or ~/.bash_profile
export PATH="$PATH:`pwd`/flutter/bin"
- Reload your shell and verify installation:
source ~/.zshrc # or source ~/.bash_profile
flutter --version
flutter doctor
3. Run Flutter Doctor
Flutter Doctor checks your environment and displays a report of the status of your Flutter installation:
flutter doctor
Flutter Doctor Output
This command checks your environment and displays a report. Follow any recommendations to install missing dependencies.
IDE Setup
- Install Visual Studio Code
- Install Flutter extension:
Extensions → Search "Flutter" → Install
The Flutter extension automatically installs the Dart extension.
- Install Android Studio
- Install Flutter and Dart plugins:
File → Settings → Plugins →
Search "Flutter" → Install → Restart
Required for Android development and emulator.
Android Development Setup
Android SDK Requirements
Android Studio installation includes Android SDK. Ensure you have the latest SDK tools and platform tools installed.
- Open Android Studio and navigate to SDK Manager
- Install the required SDK components:
SDK Platforms:
- Android 13 (API Level 33)
- Android 12 (API Level 31)
- Android 11 (API Level 30)
SDK Tools:
- Android SDK Build-Tools
- Android SDK Platform-Tools
- Android SDK Tools
- Android Emulator
- Accept Android licenses:
flutter doctor --android-licenses
iOS Development Setup (macOS only)
- Install Xcode from the Mac App Store
- Install Xcode command-line tools:
sudo xcode-select --install
- Install CocoaPods:
sudo gem install cocoapods
- Agree to Xcode license:
sudo xcodebuild -license accept
Project Setup
1. Clone the Repository
Clone the Axe VPN Flutter app repository to your local machine:
# Clone the repository
git clone https://github.com/your-username/axevpn-flutter.git
# Navigate to the project directory
cd axevpn-flutter
# Switch to the development branch (if applicable)
git checkout develop
2. Install Dependencies
Install the required Flutter packages and dependencies:
# Get Flutter packages
flutter pub get
# For iOS, install CocoaPods dependencies
cd ios
pod install
cd ..
3. Project Structure Overview
Core Directories
lib/
├── main.dart # App entry point
├── config/ # App configuration
├── models/ # Data models
├── services/ # API and VPN services
├── providers/ # State management
├── screens/ # UI screens
├── widgets/ # Reusable components
└── utils/ # Helper functions
Platform Directories
android/ # Android specific code
├── app/
│ ├── src/main/
│ └── build.gradle
ios/ # iOS specific code
├── Runner/
├── Runner.xcodeproj/
└── Podfile
Configuration
1. API Configuration
Configure the backend API endpoints in the app configuration:
// lib/config/api_config.dart
class ApiConfig {
static const String baseUrl = 'http://127.0.0.1:8000/api';
static const String socketUrl = 'ws://127.0.0.1:8000';
// API Endpoints
static const String loginEndpoint = '/auth/login';
static const String serversEndpoint = '/servers';
static const String userEndpoint = '/user';
static const String subscriptionEndpoint = '/subscription';
}
2. Firebase Configuration
Set up Firebase for push notifications:
- Create a new Firebase project at Firebase Console
- Add Android and iOS apps to your Firebase project
- Download configuration files:
- Download
google-services.json
- Place it in
android/app/
directory
- Ensure package name matches your app
- Download
GoogleService-Info.plist
- Add it to iOS project in Xcode
- Ensure bundle ID matches your app
3. VPN Configuration
Configure OpenVPN settings for your app:
// lib/config/vpn_config.dart
class VpnConfig {
static const String defaultProtocol = 'UDP';
static const int defaultPort = 1194;
static const String defaultCipher = 'AES-256-CBC';
static const String defaultAuth = 'SHA256';
// Connection timeouts
static const int connectTimeout = 30; // seconds
static const int reconnectAttempts = 3;
static const int reconnectDelay = 5; // seconds
}
First Run
1. Device/Emulator Setup
- Enable Developer Options on your device
- Enable USB Debugging
- Connect device via USB
- Verify device is detected:
flutter devices
adb devices
- Open Android Studio
- Go to AVD Manager
- Create a new virtual device
- Start the emulator
# List available emulators
flutter emulators
# Start specific emulator
flutter emulators --launch <emulator_id>
2. Run the App
Now you're ready to run the Axe VPN app:
# Run in debug mode
flutter run
# Run in release mode
flutter run --release
# Run on specific device
flutter run -d <device_id>
# Run with hot reload enabled (default in debug)
flutter run --hot
3. Verify App Functionality
Initial Testing Checklist
- ✓ App launches without errors
- ✓ Login/registration screens load
- ✓ Server list displays (may be empty initially)
- ✓ Navigation between screens works
- ✓ API connection is established
- ✓ No console errors or warnings
Troubleshooting
Common Issues and Solutions
Solution Steps:
- Run
flutter doctor -v
for detailed information
- Install missing dependencies as recommended
- Update Android SDK tools if needed
- Accept Android licenses:
flutter doctor --android-licenses
- For iOS: Install Xcode and command line tools
Troubleshooting Steps:
- Check USB connection and cable
- Enable USB debugging on Android device
- Install device drivers (Windows)
- Verify device authorization
- Restart ADB:
adb kill-server && adb start-server
Check These Items:
- Verify backend server is running (127.0.0.1:8000)
- Check API endpoint URLs in configuration
- Ensure CORS is properly configured on backend
- Test API endpoints with Postman or curl
- Check network connectivity on device/emulator
Next Steps
Great! You have the Flutter app running. Here's what to explore next: