title: How to Get Array Field Values From Firestore
body: <p>I have a Flutter app that uses Firestore to store user data. I need help with retrieving the values stored in the 'friends' array. The image below shows the structure of my Firestore. As you can see, the 'friends' field is an array with two values: '123456' and '789123'.</p>
  <p><a href="https://i.stack.imgur.com/l85gc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/l85gc.png" alt="A screenshot of a Firestore database showing the collection name, document name, and 'friends', 'uid' and 'username' fields." /></a></p>
  <p>I want to store these values in my variable called <code>friendsList</code> and I try to do this in getFriendsList(). To test and see if the 'friends' array values were stored in the <code>friendsList</code> variable, I use a print statement at the end of getFriendsList() to print the value of <code>friendsList</code>. But when I check my Console, <code>Instance of 'Future&lt;dynamic&gt;'</code> is printed and not the values of the 'friends' field.</p>
  <p>How can I assign the values of the 'friends' array field from Firestore into my <code>friendsList</code> variable?</p>
  <pre><code>import 'package:flutter/cupertino.dart';
  import 'package:flutter/material.dart';
  import 'package:firebase_auth/firebase_auth.dart';
  import 'package:mood/components/nav_drawer.dart';
  import 'package:cloud_firestore/cloud_firestore.dart';
  
  FirebaseAuth auth = FirebaseAuth.instance;
  User currentUser;
  String currentUserUID;
  Future&lt;dynamic&gt; friendsList;
  
  class LandingScreen extends StatefulWidget {
    static const String id = 'landing_screen';
  
    @override
    _LandingScreenState createState() =&gt; _LandingScreenState();
  }
  
  class _LandingScreenState extends State&lt;LandingScreen&gt; {
    final _auth = FirebaseAuth.instance;
  
    @override
    void initState() {
      super.initState();
      getUserData();
    }
  
    void getUserData() {
      getCurrentUser();
      getCurrentUserUID();
      getFriendsList();
    }
  
    void getCurrentUser() {
      final currentUser = _auth.currentUser;
    }
  
    void getCurrentUserUID() {
      currentUserUID = auth.currentUser.uid;
    }
  
    void getFriendsList() {
      friendsList = FirebaseFirestore.instance
          .collection(&quot;Users&quot;)
          .doc(currentUserUID)
          .get()
          .then((value) {
        return value.data()[&quot;friends&quot;];
      });
      print(friendsList);
    }
  </code></pre>