buildChart method
Implementation
@override
Widget buildChart() {
// Define default theme data
const defaultThemeData = ChartThemeData(
backgroundColor: Colors.white,
labelStyle: TextStyle(color: Colors.black, fontSize: 16),
valueStyle: TextStyle(
fontSize: 24, fontWeight: FontWeight.bold, color: Colors.blue),
unitStyle: TextStyle(color: Colors.grey, fontSize: 14),
);
TextStyle labelStyle = themeData?.labelStyle ?? defaultThemeData.labelStyle;
TextStyle valueStyle = themeData?.valueStyle ?? defaultThemeData.valueStyle;
double progressPercent =
(progress / goal).clamp(0, 1); // Ensure the value is between 0 and 1
return ChartCard(
themeData: themeData ?? defaultThemeData,
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(label, style: labelStyle),
const SizedBox(height: 8),
LinearProgressIndicator(
value: progressPercent,
backgroundColor: Colors.grey[300],
valueColor: const AlwaysStoppedAnimation<Color>(Colors.green),
),
const SizedBox(height: 4),
Text('${progress.toStringAsFixed(1)}/$goal$unit', style: valueStyle),
],
),
);
}