Created
March 24, 2019 20:13
-
-
Save xsahil03x/633b29cc83c1a07874b02c2a98a978a6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void main() { | |
| runApp(MyApp()); | |
| } | |
| class MyApp extends StatelessWidget { | |
| final FirebaseAuth _auth = FirebaseAuth.instance; | |
| @override | |
| Widget build(BuildContext context) { | |
| return MaterialApp( | |
| title: 'Firebase Auth Demo', | |
| routes: { | |
| '/phone': (context) => FlutterPhoneAuth(), | |
| '/home': (context) => HomeScreen(), | |
| }, | |
| home: FutureBuilder( | |
| initialData: false, | |
| future: _isUserLoggedIn(), | |
| builder: (BuildContext context, AsyncSnapshot<bool> snapshot) { | |
| return snapshot.data ? HomeScreen() : FlutterPhoneAuth(); | |
| }, | |
| ), | |
| ); | |
| } | |
| Future<bool> _isUserLoggedIn() async { | |
| return await _auth.currentUser().then((user) { | |
| if (user != null) { | |
| return true; | |
| } else | |
| return false; | |
| }); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment