【发布时间】:2021-05-08 08:34:29
【问题描述】:
我想将数据总和显示为字符串,但出现错误。
“列表”不是类型转换中“列表”类型的子类型 在第 11 行
我正在使用 Hive 作为数据库。
你能帮我解决这个错误吗?
class Home extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: Container(
child: Center(
child: ValueListenableBuilder(
valueListenable: getBoxValueListeneable(),
builder: (context, box, _) => Text(
sumWater(box.get(formatTimeToString(DateTime.now()))).toString(),
style: Theme.of(context).textTheme.headline2)),
),
),
),
floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
floatingActionButton: FloatingActionButton(
child: Icon(Icons.add),
onPressed: () async {
Navigator.pushNamed(context, '/addWaterBox');
},
),
);
}
}
【问题讨论】: