'Instance of 'Future<dynamic>' in Flutter when returning Firestore value

I thought this was going to be far easier than it turned out but I have a collection called 'USER_TABLE' with userID, email, first name and lastName.

I want to retrieve the firstName from the database and then use it in a Text widget

I am printing the firstName for debug purposes and im getting the right value but its displaying in my app as Instance of 'Future

Any ideas as to what im doing wrong? Getting no errors currently

Thanks

CODE:

import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:moodful/components/authentication_service.dart';
import 'package:moodful/components/background.dart';
import 'package:moodful/Screens/Login/login_screen.dart';


class HomeScreen extends StatefulWidget {
  HomeScreen({Key? key}) : super(key: key);

  @override
  State<HomeScreen> createState() => _HomeScreenState();
}

class _HomeScreenState extends State<HomeScreen> {
  @override
  Widget build(BuildContext context) {
    Size size = MediaQuery.of(context).size;
    // This size provide us total height and width of our screen

    var firstName = getData();

    //return Scaffold(
    return BackgroundLogoRight(
      text: "Home",
      child: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: <Widget>[
          const Spacer(),
          Expanded(
            flex: 5,
            child: Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                Expanded(
                  flex: 10,
                  child: Text(
                    "$firstName \n\n "
                    "Glad you're back, please enter a mood for today.\n\n "
                    "Be sure to check the insights page for the most up to date mood analysis\n\n"
                    "The more you know the more control you have",
                    style: TextStyle(color: Colors.black, fontSize: 15),
                    textAlign: TextAlign.center,
                  ),
                ),
              ],
            ),
          ),
          Expanded(
            flex: 5,
            child: Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                GestureDetector(
                  onTap: () {
                    Navigator.push(
                      context,
                      MaterialPageRoute(
                        builder: (context) {
                          return LoginScreen(); // change to return something sensible
                        },
                      ),
                    );
                  }, // handle your image tap here
                  child: Image.asset(
                    "assets/images/recordMoodLogo.jpg",
                    width: size.width * 0.5,

                    fit: BoxFit.cover, // this is the solution for border

                    height: 110.0,
                  ),
                ),
              ],
            ),
          ),
        ],
      ),
    );
  }

  getData() async {
    var currentUser = FirebaseAuth.instance.currentUser;

    DocumentSnapshot variable = await FirebaseFirestore.instance
        .collection('USER_TABLE')
        .doc(currentUser!.uid)
        .get();
    print(variable['firstName']);
    return variable['firstName'];
  }
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source