You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

145 lines
4.1 KiB

import 'package:flutter/material.dart';
import 'config/config_loader.dart';
void main() {
// Load configuration based on environment
// In a real app, this would come from environment variables or build config
const String environment = String.fromEnvironment(
'ENV',
defaultValue: 'dev',
);
final config = ConfigLoader.load(environment);
if (config.enableLogging) {
debugPrint('App initialized with config: $config');
}
runApp(const MyApp());
}
/// The root widget of the application.
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
// Load config to display in UI
const String environment = String.fromEnvironment(
'ENV',
defaultValue: 'dev',
);
final config = ConfigLoader.load(environment);
return MaterialApp(
title: 'App Boilerplate',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.blue),
useMaterial3: true,
),
home: Scaffold(
appBar: AppBar(
title: const Text('App Boilerplate'),
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Icon(
Icons.check_circle_outline,
size: 64,
color: Colors.green,
),
const SizedBox(height: 24),
const Text(
'Flutter Modular App Boilerplate',
style: TextStyle(
fontSize: 24,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 32),
Card(
margin: const EdgeInsets.symmetric(horizontal: 32),
child: Padding(
padding: const EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Configuration',
style: Theme.of(context).textTheme.titleMedium?.copyWith(
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 12),
_ConfigRow(
label: 'Environment',
value: environment.toUpperCase(),
),
const SizedBox(height: 8),
_ConfigRow(
label: 'API Base URL',
value: config.apiBaseUrl,
),
const SizedBox(height: 8),
_ConfigRow(
label: 'Logging',
value: config.enableLogging ? 'Enabled' : 'Disabled',
),
],
),
),
),
const SizedBox(height: 32),
Text(
'Phase 0: Project Setup Complete ✓',
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
color: Colors.grey,
),
),
],
),
),
),
);
}
}
/// Widget to display a configuration row.
class _ConfigRow extends StatelessWidget {
final String label;
final String value;
const _ConfigRow({
required this.label,
required this.value,
});
@override
Widget build(BuildContext context) {
return Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
width: 100,
child: Text(
'$label:',
style: Theme.of(context).textTheme.bodySmall?.copyWith(
color: Colors.grey,
),
),
),
Expanded(
child: Text(
value,
style: Theme.of(context).textTheme.bodyMedium,
),
),
],
);
}
}

Powered by TurnKey Linux.