eigentliche Handwerksapp
This commit is contained in:
57
main.dart
Normal file
57
main.dart
Normal file
@@ -0,0 +1,57 @@
|
||||
import 'package:firebase_auth/firebase_auth.dart';
|
||||
import 'package:firebase_core/firebase_core.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'firebase_options.dart';
|
||||
import 'screens/auth/auth_screen.dart';
|
||||
import 'screens/firebase_setup_required_screen.dart';
|
||||
import 'screens/home/auftraege_home_screen.dart';
|
||||
import 'theme/app_theme.dart';
|
||||
|
||||
Future<void> main() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
try {
|
||||
await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);
|
||||
} catch (e, st) {
|
||||
debugPrint('Firebase init failed: $e\n$st');
|
||||
runApp(FirebaseSetupRequiredScreen(error: e));
|
||||
return;
|
||||
}
|
||||
runApp(const HandwerksApp());
|
||||
}
|
||||
|
||||
class HandwerksApp extends StatelessWidget {
|
||||
const HandwerksApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
title: 'Handwerksapp',
|
||||
debugShowCheckedModeBanner: false,
|
||||
theme: AppTheme.light(),
|
||||
home: const _AuthGate(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _AuthGate extends StatelessWidget {
|
||||
const _AuthGate();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return StreamBuilder<User?>(
|
||||
stream: FirebaseAuth.instance.authStateChanges(),
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||
return const Scaffold(
|
||||
body: Center(child: CircularProgressIndicator()),
|
||||
);
|
||||
}
|
||||
if (snapshot.hasData) {
|
||||
return const AuftraegeHomeScreen();
|
||||
}
|
||||
return const AuthScreen();
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user