如何解决使用带有LabelAccessorFn的FutureBuilder的Flutter Charts
我正在使用StreamBuilder来为Flutter Charts outside label pie chart创建数据。数据字段( categoryId )是另一个数据模型的整数外键,被用作域,聚合值( expenseTotal )是度量。我正在尝试使用从sqlite查找的FutureBuilder,用labelAccessorFn用其各自的描述性字符串标题替换此数据字段。正确调用了将来的函数( getCategoryTitle ),并检索了正确的标题值,但是,无论出于何种原因,它都不会返回ConnectionState.done。我得到的只是一个FutureBuilder。
我在其他地方使用FutureBuilder取得了成功,但不是这种情况。我希望有一些指示。非常感谢!
List<charts.Series<TotalByCategory,int>>
totalByCategorySeries = [
charts.Series<TotalByCategory,int>(
id: 'expenseByCategory',seriesColor: charts.ColorUtil.fromDartColor(Theme.of(context).accentColor),domainFn: (TotalByCategory expense,_) => expense.categoryId,measureFn: (TotalByCategory expense,_) => expense.expenseTotal,data: weeklyTotalByCategoryList,labelAccessorFn: (TotalByCategory row,_) => FutureBuilder<String> (
future: getCategoryTitle(row.categoryId),builder: (BuildContext context,AsyncSnapshot categoryInfoSnapshot) {
if (categoryInfoSnapshot.connectionState == ConnectionState.done){
if(categoryInfoSnapshot.hasData) { return Text('${categoryInfoSnapshot.data.toString()}'); }
return Text('?');
}
return Text('?');
},).toString(),colorFn: (_,index) => charts.MaterialPalette.green.makeShades(weeklyTotalByCategoryList.length)[index],)];
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。