animated_pie_chart 0.0.2 animated_pie_chart: ^0.0.2 copied to clipboard
An animated pie chart with rotation and selected index functionality provides a visually appealing way to showcase data. In start it automatically sort list and shows the data in descending form and h [...]
import 'package:flutter/material.dart';
import 'package:animated_pie_chart/animated_pie_chart.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatefulWidget {
MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Flutter Demo',
theme: ThemeData(
// This is the theme of your application.
//
// Try running your application with "flutter run". You'll see the
// application has a blue toolbar. Then, without quitting the app, try
// changing the primarySwatch below to Colors.green and then invoke
// "hot reload" (press "r" in the console where you ran "flutter run",
// or simply save your changes to "hot reload" in a Flutter IDE).
// Notice that the counter didn't reset back to zero; the application
// is not restarted.
primarySwatch: Colors.blue,
),
home: Scaffold(
appBar: AppBar(title: Text('Animated Pie Chart'),),
body: Center(
child: AnimatedPieChart(
sort: true,
stokeWidth: 8.0,
padding:3.0,
animatedSpeed:500,
pieRadius: 70.0,
colorsList: [
Colors.brown,
Colors.purple,
Colors.red,
Colors.yellow,
Colors.green,
Colors.blue,
],
pieData: [
for(int i=0;i<pieChartList.length;i++)
MdPieChart(value: pieChartList[i].value, name: pieChartList[i].name)
],
) ,
),
)
);
}
List<MdPieChart> pieChartList = [
MdPieChart( value: 10,name: 'Apple'),
MdPieChart( value: 5,name: 'Peach'),
MdPieChart( value: 15,name: 'Mango'),
MdPieChart( value: 20,name: 'Banana'),
MdPieChart( value: 2,name: 'Peach'),
MdPieChart( value: 8,name: 'Guava'),
MdPieChart( value: 12,name: 'Lemon'),
MdPieChart( value: 14,name: 'pineApple'),
MdPieChart( value: 6,name: 'kiwi'),
MdPieChart( value: 8,name: 'pear'),
];
}