Created
December 3, 2021 21:26
-
-
Save imaNNeo/336b1674e3036e626ec475fe2ad10afe to your computer and use it in GitHub Desktop.
PieChart dyanmic radius
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:fl_chart/fl_chart.dart'; | |
import 'package:flutter/material.dart'; | |
void main() { | |
runApp(const MyApp()); | |
} | |
class MyApp extends StatelessWidget { | |
const MyApp({Key? key}) : super(key: key); | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
title: 'fl_chart Pie Chart Sizing Bug', | |
home: Scaffold( | |
appBar: AppBar( | |
title: Text('fl_chart Pie Chart Sizing Bug'), | |
), | |
body: Container( | |
width: 300.0, | |
height: 300.0, | |
color: Colors.blue, | |
child: LayoutBuilder( | |
builder: (context, constraints) { | |
final shortestSide = constraints.biggest.shortestSide; | |
return PieChart( | |
PieChartData( | |
sections: [ | |
PieChartSectionData( | |
value: 60.0, | |
color: Colors.green, | |
radius: shortestSide / 2, | |
), | |
PieChartSectionData( | |
value: 40.0, | |
color: Colors.purple, | |
radius: shortestSide / 2, | |
), | |
], | |
centerSpaceRadius: 0, | |
), | |
); | |
}, | |
), | |
)), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
pie_dynamic_radius.mp4