饼图
这个 Flutter 包提供了一个带有酷炫动画的饼图小部件。
? 安装
在 pubspec.yaml 的 dependencies: 部分,添加以下行
dependencies:
pie_chart: <latest version>
❔ 用法
导入此类
import 'package:pie_chart/pie_chart.dart';
使用方法很简单。 饼图是一个组件,它只需要一个 Map<String,double> 作为其数据输入。

Map<String, double> dataMap = new Map();
dataMap.putIfAbsent("Flutter", () => 5);
dataMap.putIfAbsent("React", () => 3);
dataMap.putIfAbsent("Xamarin", () => 2);
dataMap.putIfAbsent("Ionic", () => 2);
PieChart(
dataMap: dataMap,
legendFontColor: Colors.blueGrey[900],
legendFontSize: 14.0,
legendFontWeight: FontWeight.w500,
animationDuration: Duration(milliseconds: 800),
chartLegendSpacing: 32.0,
chartRadius: MediaQuery
.of(context)
.size
.width / 2.7,
showChartValuesInPercentage: true,
showChartValues: true,
chartValuesColor: Colors.blueGrey[900].withOpacity(0.9),
)