title: Flutter get logged user data to other screen view
body: <p>I have API.dart like this to authenticating a user, log in and log out</p>
  
  <pre><code>class Api {
  
  
  static FirebaseAuth _auth = FirebaseAuth.instance;
    static GoogleSignIn _googleSignIn = GoogleSignIn();
  
    FirebaseUser firebaseUser;
  
    Api(FirebaseUser user) {
      this.firebaseUser = user;
    }
  
    static Future&lt;FBApi&gt; signInWithGoogle() async {
      final GoogleSignInAccount googleUser = await _googleSignIn.signIn();
      final GoogleSignInAuthentication googleAuth = await googleUser.authentication;
  
      final FirebaseUser user = await _auth.signInWithGoogle(
        accessToken: googleAuth.accessToken,
        idToken: googleAuth.idToken,
      );
  
      assert(user.email != null);
      assert(user.displayName != null);
  
      assert(await user.getIdToken() != null);
  
      final FirebaseUser currentUser = await _auth.currentUser();
      assert(user.uid == currentUser.uid);
  //    print('photoURL api ' + user.photoUrl);
      return Api(user);
    }
  
    static Future&lt;void&gt; signOut() async {
      await _auth.signOut().then((_) {
        print("***** log out...what the hell?");
        _googleSignIn.signOut();
      });
    }
  }
  </code></pre>
  
  <p>I've have a cloud function to create new user to database cloud firestore.
  And in view account settings, I want to update user information like displayName, photoUrl into firestore. How I get current user in my account setting view.</p>
  
  <pre><code>class Settings extends StatelessWidget {
  
  
  @override
    Widget build(BuildContext context) {
      return new Scaffold(
        appBar: new AppBar(
          title: new Text(
            'ACCOUNT',
            style: TextStyle(color: primaryColor, fontWeight: FontWeight.bold),
          ),
          centerTitle: true,
        ),
        body: new SettingsScreen(),
      );
    }
  }
  
  class SettingsScreen extends StatefulWidget {
    @override
    State createState() =&gt; new SettingsScreenState();
  }
  
  class SettingsScreenState extends State&lt;SettingsScreen&gt; {
    TextEditingController controllerNickname;
  
    SharedPreferences prefs;
  
    String id;
    String nickName;
    String photoUrl;
  
    bool isLoading = false;
    File avatarImageFile;
  
    final FocusNode focusNodeNickname = new FocusNode();
  
    @override
    void initState() {
      super.initState();
      readLocal();
    }
  
    void readLocal() async {
      prefs = await SharedPreferences.getInstance();
      id = prefs.getString('id') ?? '';
      nickName = prefs.getString('nickName') ?? '';
      photoUrl = prefs.getString('photoUrl') ?? '';
  
      controllerNickname = new TextEditingController(text: nickName);
  
      // Force refresh input
      setState(() {});
    }
  
    Future getImage() async {
      File image = await ImagePicker.pickImage(source: ImageSource.gallery);
  
      if (image != null) {
        setState(() {
          avatarImageFile = image;
          isLoading = true;
        });
      }
      uploadFile();
    }
  
    Future uploadFile() async {
      String fileName = id;
      StorageReference reference = FirebaseStorage.instance.ref().child(fileName);
      StorageUploadTask uploadTask = reference.putFile(avatarImageFile);
      StorageTaskSnapshot storageTaskSnapshot;
      uploadTask.onComplete.then((value) {
        if (value.error == null) {
          storageTaskSnapshot = value;
          storageTaskSnapshot.ref.getDownloadURL().then((downloadUrl) {
            photoUrl = downloadUrl;
            Firestore.instance
                .collection('users')
                .document(id)
                .updateData({'displayName': nickName, 'photoUrl': photoUrl}).then((data) async {
              await prefs.setString('photoUrl', photoUrl);
              setState(() {
                isLoading = false;
              });
              Fluttertoast.showToast(msg: "Upload success");
            }).catchError((err) {
              setState(() {
                isLoading = false;
              });
              Fluttertoast.showToast(msg: err.toString());
            });
          }, onError: (err) {
            setState(() {
              isLoading = false;
            });
            Fluttertoast.showToast(msg: 'This file is not an image');
          });
        } else {
          setState(() {
            isLoading = false;
          });
          Fluttertoast.showToast(msg: 'This file is not an image');
        }
      }, onError: (err) {
        setState(() {
          isLoading = false;
        });
        Fluttertoast.showToast(msg: err.toString());
      });
    }
  
    void handleUpdateData() {
      focusNodeNickname.unfocus();
  
      setState(() {
        isLoading = true;
      });
  
      Firestore.instance
          .collection('users')
          .document(id)
          .updateData({'displayName': nickName, 'photoUrl': photoUrl}).then((data) async {
        await prefs.setString('nickname', nickName);
        await prefs.setString('photoUrl', photoUrl);
  
        setState(() {
          isLoading = false;
        });
  
        Fluttertoast.showToast(msg: "Update success");
      }).catchError((err) {
        setState(() {
          isLoading = false;
        });
  
        Fluttertoast.showToast(msg: err.toString());
      });
    }
  
    @override
    Widget build(BuildContext context) {
    ...
  </code></pre>