Skip to main content

Overview

Invenicum uses environment variables and compile-time constants to configure API connectivity, timeouts, and core application settings. These settings are defined in lib/config/environment.dart.

Environment Variables

API_URL
string
default:"http://192.168.1.43:3000"
Base URL for the backend API server. This can be overridden at compile time using the --dart-define flag.Example:
flutter run --dart-define=API_URL=https://api.production.com

Application Constants

These constants are defined in lib/config/environment.dart:7-31 and cannot be changed at runtime.

General Settings

ConstantTypeValueDescription
appNameString"Invenicum"Application display name
appVersionString"1.0.0"Current application version
apiVersionString"/api/v1"API version path prefix
baseUrlString"$apiUrl/api/v1"Complete base URL (computed)

Documentation URLs

ConstantTypeValue
docsUrlString"https://docs.invenicum.com"
stacDocsUrlString"https://docs.stac.dev/introduction"

Network Timeouts

connectTimeout
int
default:"15000"
Connection timeout in milliseconds (15 seconds). Used when establishing initial connection to the API server.
receiveTimeout
int
default:"45000"
Response timeout in milliseconds (45 seconds). Maximum time to wait for a response after connection is established.

API Endpoints

Authentication endpoints relative to baseUrl:
EndpointPathDescription
Login/auth/loginUser authentication
Logout/auth/logoutSession termination
Refresh Token/auth/refreshToken renewal

Storage Keys

These keys are used for secure storage. Do not modify unless coordinating with backend changes.
KeyPurpose
authTokenKeyStores the user’s authentication token
refreshTokenKeyStores the refresh token for session renewal

Configuration Usage

Access environment configuration in your code:
import 'package:invenicum/lib/config/environment.dart';

// Use the configured base URL
final apiUrl = Environment.baseUrl;

// Access timeout settings
final timeout = Environment.connectTimeout;

// Get application info
final appName = Environment.appName;
final version = Environment.appVersion;

Build Configurations

You can create different configurations for development, staging, and production:
flutter run --dart-define=API_URL=http://localhost:3000

Best Practices

For Development: Use your local machine’s IP address instead of localhost when testing on physical devices or emulators.
Security: Never commit production API URLs or credentials to version control. Use environment-specific build configurations instead.
The Environment class uses const values for compile-time optimization, meaning values cannot be changed at runtime.
  • Environment Config: lib/config/environment.dart:1-32
  • API Service: lib/data/services/api_service.dart
  • Preferences Service: lib/data/services/preferences_service.dart

Build docs developers (and LLMs) love