init
This commit is contained in:
48
lib/app/config/app_config.dart
Normal file
48
lib/app/config/app_config.dart
Normal file
@@ -0,0 +1,48 @@
|
||||
import 'package:package_info_plus/package_info_plus.dart';
|
||||
|
||||
enum AppEnvironment { dev, staging, prod }
|
||||
|
||||
class EnvironmentValues {
|
||||
const EnvironmentValues({
|
||||
required this.environment,
|
||||
required this.baseUrl,
|
||||
required this.enableNetworkLog,
|
||||
});
|
||||
|
||||
final AppEnvironment environment;
|
||||
final String baseUrl;
|
||||
final bool enableNetworkLog;
|
||||
}
|
||||
|
||||
class AppConfig {
|
||||
AppConfig._();
|
||||
|
||||
static late EnvironmentValues current;
|
||||
static PackageInfo? packageInfo;
|
||||
|
||||
static const appName = 'Flutter Template';
|
||||
|
||||
static void configure({
|
||||
required AppEnvironment environment,
|
||||
PackageInfo? packageInfo,
|
||||
}) {
|
||||
AppConfig.packageInfo = packageInfo;
|
||||
current = switch (environment) {
|
||||
AppEnvironment.dev => const EnvironmentValues(
|
||||
environment: AppEnvironment.dev,
|
||||
baseUrl: 'https://example.com/api',
|
||||
enableNetworkLog: true,
|
||||
),
|
||||
AppEnvironment.staging => const EnvironmentValues(
|
||||
environment: AppEnvironment.staging,
|
||||
baseUrl: 'https://staging.example.com/api',
|
||||
enableNetworkLog: true,
|
||||
),
|
||||
AppEnvironment.prod => const EnvironmentValues(
|
||||
environment: AppEnvironment.prod,
|
||||
baseUrl: 'https://api.example.com',
|
||||
enableNetworkLog: false,
|
||||
),
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user