I'm trying to calculate the sum of TotalPrice column in my table Items but it returns a null(waiting ...) in a text widget according to the condition I've given.
Future calculateTotal(var order) async {
var dbClient = db;
var result = await dbClient.rawQuery(
'select sum(TotalPrice) as Total from Items where refID = ?'[order]);
print(result.toList());
}
*above is the code in my database helper class**
double _total;
void _calcTotal() async {
var total =
(await OrderProvider().calculateTotal(widget.order))[0]['Total'];
print(total);
setState(() {
_total = total;
});
}
Widget showItems() {
return Container(
color: Colors.blueGrey,
child: Column(
children: <Widget>[
Container(
color: Colors.amberAccent,
padding: EdgeInsets.only(
top: 10,
bottom: 10,
),
child: Center(
child: Text(
_total != null ? _total : 'waiting ...',
style: TextStyle(fontSize: 10),
),
)),
above is the code in my widget class. I've used this example I've used this example