Skip to content

Instantly share code, notes, and snippets.

@rpsnaik
Created October 8, 2019 19:03
Show Gist options
  • Save rpsnaik/7baff3a82c8c42581f42f6349ffb53cf to your computer and use it in GitHub Desktop.
Save rpsnaik/7baff3a82c8c42581f42f6349ffb53cf to your computer and use it in GitHub Desktop.
class SplashScreen extends StatefulWidget {
@override
_SplashScreenState createState() => _SplashScreenState();
}
class _SplashScreenState extends State<SplashScreen> {
Future onloadDecider() async {
FirebaseUser user = await FirebaseAuth.instance.currentUser();
if(user == null){
print("No User");
Navigator.pushReplacement(context, MaterialPageRoute(builder: (context)=>Material(
child: ChangeNotifierProvider(
builder: (_)=>SessionManagement(),
child: FirebaseSession(),
),
)));
}else{
print("Current User : "+user.uid);
Navigator.pushReplacement(context, MaterialPageRoute(builder: (context)=>Material(
child: MultiProvider(
providers: [
ChangeNotifierProvider(builder: (_)=>SessionManagement(),),
],
child: SpotifyHome(),
),
)));
}
}
@override
void initState() {
Future.delayed(Duration(seconds: 2), (){
onloadDecider();
});
super.initState();
}
@override
Widget build(BuildContext context) {
return Container(
child: Center(
child: Image.asset("./images/spotify_logo_title.png"),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment