title: How to save user sign-in details in Flutter?
body: <p>I am new to flutter and want to make an app which only authenticated users (via filling email and password) can use. So I am thinking of making a root widget called <code>Authentication</code>  where I will check if the user is authenticated or not. If they are then take them to <code>Home()</code> Widget (which is basically app home page) else to SignIn() Widget (which is signin page) . </p>
  
  <ul>
  <li>I have to check for user authentication in 2 senerios:    
  
  <ul>
  <li>When app opens so that previously signed in user does not have to signin again </li>
  <li>After filling up Email-Id and Password user clicks on <code>Sign In</code> button </li>
  </ul></li>
  </ul>
  
  <p>I am facing the following problem and don't know how do I solve them ( Assume that there is no signup option and user data is entered to db directly not through some UI ):</p>
  
  <ul>
  <li><p>If a user is already signed in how to take them directly to <code>Home()</code> Widget ?</p>
  
  <p>This is code of what I have currently I am not sure if is the right way of doing this type of app so if there is a better way to do this please tell : </p></li>
  </ul>
  
  <pre><code>
      import 'package:flutter/material.dart';
      import 'package:myapp/home.dart';
      import 'package:myapp/signIn.dart';
  
  
      void main() =&gt; runApp(Authenticate());
  
      class Authenticate extends StatelessWidget {
  
  
        final String authenticateEmail;
        final String authenticatePassword;
  
        Authenticate({this.authenticateEmail, this.authenticatePassword}); 
  
  
  
  
        // Make a call to db to check if the data provided is correct or not 
        // If it is correct we then navigate the user to Home() Widget 
        // Else to SignIn() Widget
  
    @override
    Widget build(BuildContext context) {
  
       if ( make some call to db to check if data is there) {
         return Home();
       }
       else {
         return SignIn();
       }
  
    }
  }
  </code></pre>
  
  <p>The issue with above code is when the app is opened for the first time how to take user directly to SignIn() Widget should I initilize the fields with empty string and in method check for condition if string is empty or not ?   </p>