cofounderella/lib/services/auth/auth_gate.dart

27 lines
709 B
Dart
Raw Normal View History

2024-04-29 14:36:25 +02:00
import 'package:flutter/material.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:cofounderella/services/auth/login_or_register.dart';
2024-04-29 14:36:25 +02:00
import 'package:cofounderella/pages/home_page.dart';
class AuthGate extends StatelessWidget{
const AuthGate({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
body: StreamBuilder(
stream: FirebaseAuth.instance.authStateChanges(),
builder: (context, snapshot){
// check if user is logged in or not
if(snapshot.hasData){
return HomePage();
2024-04-29 14:36:25 +02:00
}
else {
return const LoginOrRegister();
}
},
),
);
}
}