Skip to content

Instantly share code, notes, and snippets.

@Moiz-Ali-Moomin
Created November 9, 2020 16:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Moiz-Ali-Moomin/d204844571356c7127dcff5e0a6e4816 to your computer and use it in GitHub Desktop.
Save Moiz-Ali-Moomin/d204844571356c7127dcff5e0a6e4816 to your computer and use it in GitHub Desktop.
import 'LogIn.dart';
import 'package:flutter/material.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'HomePage.dart';
class IntroScreen extends StatefulWidget {
@override
_IntroScreenState createState() => _IntroScreenState();
}
class _IntroScreenState extends State<IntroScreen> {
final FirebaseAuth auth = FirebaseAuth.instance;
@override
Widget build(BuildContext context) {
return StreamBuilder<User>(
stream: auth.authStateChanges(),
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.active) {
User user = snapshot.data;
if (user == null) {
return LogIn();
}
print("homePage");
return HomePage();
} else if (snapshot.connectionState == ConnectionState.waiting) {
print("Waiting");
return Scaffold(
body: Center(
child: CircularProgressIndicator(),
),
);
}
return null;
},
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment