import 'package:flutter/material.dart'; import 'package:http/http.dart' as http; import 'api.dart'; import 'screens/home_screen.dart'; import 'screens/login_screen.dart'; import 'theme.dart'; void main() { final state = AppState(Api(http.Client()))..bootstrap(); runApp(KcApp(state: state)); } /// Minimal InheritedNotifier so screens can read `AppState.of(context)` and /// rebuild on change — no third-party state management. class AppScope extends InheritedNotifier { const AppScope({super.key, required AppState state, required super.child}) : super(notifier: state); static AppState of(BuildContext context) { final scope = context.dependOnInheritedWidgetOfExactType(); assert(scope != null, 'AppScope missing above this widget'); return scope!.notifier!; } } class KcApp extends StatelessWidget { const KcApp({super.key, required this.state}); final AppState state; @override Widget build(BuildContext context) { return AppScope( state: state, child: MaterialApp( title: 'KC-App', debugShowCheckedModeBanner: false, theme: buildKcTheme(), home: const _AuthGate(), ), ); } } class _AuthGate extends StatelessWidget { const _AuthGate(); @override Widget build(BuildContext context) { final state = AppScope.of(context); if (state.loading) { return const Scaffold(body: Center(child: CircularProgressIndicator())); } return state.isLoggedIn ? const HomeScreen() : const LoginScreen(); } }