import 'package:flutter/material.dart';
import 'package:pie_chart/pie_chart.dart';
class HomePage extends StatelessWidget {
Map<String, double> dataMap = {
"Flutter": 5,
"React": 3,
"Xamarin": 2,
"Ionic": 2,
};
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Pie Chart"),
centerTitle: true,
backgroundColor: Colors.green[700],
brightness: Brightness.dark,
),
body: Container(
child: Center(
child: PieChart(
dataMap: dataMap,
chartRadius: MediaQuery.of(context).size.width / 1.7,
legendOptions: LegendOptions(
legendPosition: LegendPosition.bottom,
),
chartValuesOptions: ChartValuesOptions(
showChartValuesInPercentage: true,
),
),
),
),
);
}
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter