Instance of ‘Future’

Solution for Instance of ‘Future
is Given Below:

Future<int> getCountTodo(int taskId) async {
   Database db = await this.db;
   List<Map<String, dynamic>> x = await db.rawQuery('SELECT COUNT (*) from $todoTable where taskId=$taskId');
   // List<Map<String, dynamic>> x = await db.rawQuery('SELECT  COUNT(*),t.title FROM todo_table td, task_table t WHERE t.id=td.taskId GROUP BY taskId');
   int result = Sqflite.firstIntValue(x);
   print('Todo inside task: $result');
   return result;
 }

Text (
 // '${1}'+" ITEM", 
 DatabaseHelper.instance.getCountTodo(task.tasklist[index].id).toString(),
 style: TextStyle(
   fontSize: 14.0,
   color: Colors.grey,
   fontWeight: FontWeight.bold),
)

How can i get the count result here in text widget. I’m getting Instance of ‘Future’.

It’s better practice to use a future builder here:

FutureBuilder(
 future: DatabaseHelper.instance.getCountTodo(task.tasklist[index].id),
 builder: (BuildContext context, AsyncSnapshot<String> snapshot) {
       switch (snapshot.connectionState) {
         case ConnectionState.waiting: return Text('Loading....');
         default:
           if (snapshot.hasError)
              return Text('Error: ${snapshot.error}');
           else if (snapshot.data==null)
              return Text('Loading....');
           else
          return Text('${snapshot.data}');
        }
      },
    )


)