Skip to main content

Environment Configuration

Viax supports multiple environments with different backend configurations. Learn how to switch between local development, staging, and production setups.

Environment Types

Development

Local development with Laragon
  • Backend: localhost
  • Database: Local MySQL
  • Hot reload enabled
  • Debug mode active

Staging

Testing environment
  • Backend: Staging server
  • Database: Test database
  • Mirrors production
  • Safe for testing

Production

Live environment
  • Backend: VPS (76.13.114.194)
  • Database: Production MySQL
  • Optimized builds
  • Real user data

Configuration Architecture

Viax uses a centralized configuration system that automatically detects the environment based on the API base URL.

AppConfig Class

Location: lib/src/core/config/app_config.dart

Environment Setup

Development (Local)

The Android emulator maps localhost to 10.0.2.2.
Full URL structure:
  • Base: http://10.0.2.2/viax/backend
  • Auth: http://10.0.2.2/viax/backend/auth
  • Conductor: http://10.0.2.2/viax/backend/conductor
  • User: http://10.0.2.2/viax/backend/user
  • Admin: http://10.0.2.2/viax/backend/admin

Staging (Optional)

If you have a staging server:

Production

Connect to the live VPS server:

Backend Configuration

Development Backend (Laragon)

File: backend/config/database.php

Production Backend (VPS)

File: backend/config/database.php

Environment Variables

Flutter Environment Variables

Viax supports custom configuration through Dart defines:
Available Variables:
Create configuration files for different environments: config/dev.env:
config/prod.env:
Use with scripts:

VS Code Launch Configurations

Create .vscode/launch.json for easy environment switching:
Usage:
  1. Press F5 in VS Code
  2. Select configuration from dropdown
  3. App launches with selected environment

Testing Configuration

Verify Backend Connection

Create a simple test to verify your configuration:
Run test:

Manual Health Check

Test backend endpoints directly:

URL Structure Reference

Complete URL Mapping


Build Configurations

Development Build

Staging Build

Production Build


Environment-Specific Features

Debug Mode Features

Analytics Control


Troubleshooting

Problem: Canโ€™t connect to localhost from Android emulatorSolution:
  • Use 10.0.2.2 instead of localhost
  • Verify Laragon/backend is running
  • Check firewall settings
Problem: Canโ€™t connect using local IPSolution:
  • Verify same WiFi network
  • Check IP address is correct
  • Disable firewall temporarily to test
  • Use explicit IP, not hostname
Problem: App using wrong environmentSolution:
  • Verify --dart-define syntax
  • Check for typos in URL
  • Print environment in app:
Problem: App still using old base URLSolution:

Best Practices

Never Hardcode URLs

Always use AppConfig.baseUrl instead of hardcoded URLs in your code.

Use Launch Configs

Set up VS Code launch configurations for quick environment switching.

Test All Environments

Test features in development before deploying to production.

Secure Production

Use HTTPS, strong passwords, and proper authentication in production.
Configuration Complete! You can now switch between environments seamlessly and configure Viax for any deployment scenario.