Flutter饼图标签——如何使其工作



我试图让我的饼图标签可见,但在设置arcRenderRecorders后,它会进入

  1. RenderBox未布局:ChartContainerRenderObject#1bf0d NEEDS-PAINT'package:flatt/src/rendering/box.dart':断言失败:行1927位置12:"hasSize">
  2. RenderBox未布局:RenderPointerListener#5ff88 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE'package:flatt/src/rendering/box.dart':断言失败:行1927位置12:"hasSize">
  3. RenderBox未布局:RenderSemanticsGestureHandler#4a473 NEEDS-PAINT NEEDS-COMPOSITING-BITS-PDATE'package:flatt/src/rendering/box.dart':断言失败:行1927位置12:"hasSize">
  4. RenderBox未布局:ChartContainerRenderObject#1bf0d'package:flatt/src/rendering/box.dart':断言失败:行1927位置12:"hasSize"问题

我必须使用什么样的小工具才能工作。请帮忙。

final List<DeveloperSeries> data = [
DeveloperSeries(
year: "2017",
developers: 40000,
barColor: charts.ColorUtil.fromDartColor(Colors.blue),
),
DeveloperSeries(
year: "2019",
developers: 40000,
barColor: charts.ColorUtil.fromDartColor(Colors.blue),
),
DeveloperSeries(
year: "2020",
developers: 35000,
barColor: charts.ColorUtil.fromDartColor(Colors.blue),
),
DeveloperSeries(
year: "2021",
developers: 45000,
barColor: charts.ColorUtil.fromDartColor(Colors.blue),
),
];
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: DeveloperChart(
data: data,
)
),
);
}
}
class DeveloperChart extends StatelessWidget {
final List<DeveloperSeries> data;
DeveloperChart({required this.data});
@override
Widget build(BuildContext context) {
List<charts.Series<DeveloperSeries, String>> series = [
charts.Series(
id: "developers",
data: data,
domainFn: (DeveloperSeries series, _) => series.year,
measureFn: (DeveloperSeries series, _) => series.developers,
colorFn: (DeveloperSeries series, _) => series.barColor,
labelAccessorFn: (DeveloperSeries row, _) => row.year,
)
];
return Container(
height: 500,
width: 500,
child: Card(
child: Padding(
padding: const EdgeInsets.all(9.0),
child: Column(
children: <Widget>[
Text(
"Yearly Growth in the Flutter Community",
style: Theme
.of(context)
.textTheme
.bodyText2,
),
Expanded(
child: charts.PieChart(series, animate: true,
defaultRenderer: charts.ArcRendererConfig(
arcRendererDecorators: [
charts.ArcLabelDecorator(
labelPosition: charts.ArcLabelPosition
.outside)
])
)
)
]
),
),
)
);
}
}```

同样的问题,我通过替换来解决:

charts.PieChart(

带有:

charts.PieChart<String>(

最新更新