mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 15:17:31 +00:00
Refactor padding and add const constructors for improved performance and consistency in chart widgets
This commit is contained in:
@ -22,7 +22,7 @@ abstract final class EnergyManagementChartsHelper {
|
||||
getTitlesWidget: (value, meta) => Padding(
|
||||
padding: const EdgeInsetsDirectional.only(top: 20.0),
|
||||
child: Text(
|
||||
value.getMonthName,
|
||||
(value + 1).getMonthName,
|
||||
style: context.textTheme.bodySmall?.copyWith(
|
||||
color: ColorsManager.greyColor,
|
||||
fontSize: 12,
|
||||
@ -66,7 +66,7 @@ abstract final class EnergyManagementChartsHelper {
|
||||
static List<LineTooltipItem?> getTooltipItems(List<LineBarSpot> touchedSpots) {
|
||||
return touchedSpots.map((spot) {
|
||||
return LineTooltipItem(
|
||||
getToolTipLabel(spot.x, spot.y),
|
||||
getToolTipLabel(spot.x + 1, spot.y),
|
||||
const TextStyle(
|
||||
color: ColorsManager.textPrimaryColor,
|
||||
fontWeight: FontWeight.w600,
|
||||
@ -101,7 +101,7 @@ abstract final class EnergyManagementChartsHelper {
|
||||
}
|
||||
|
||||
static FlGridData gridData() {
|
||||
return FlGridData(
|
||||
return const FlGridData(
|
||||
show: true,
|
||||
drawVerticalLine: false,
|
||||
drawHorizontalLine: true,
|
||||
|
@ -11,7 +11,7 @@ class AnalyticsEnergyManagementView extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(32),
|
||||
padding: const EdgeInsetsDirectional.all(32),
|
||||
child: Row(
|
||||
spacing: 20,
|
||||
children: [
|
||||
@ -30,7 +30,7 @@ class AnalyticsEnergyManagementView extends StatelessWidget {
|
||||
decoration: subSectionContainerDecoration.copyWith(
|
||||
borderRadius: BorderRadius.circular(30),
|
||||
),
|
||||
padding: const EdgeInsets.all(32),
|
||||
padding: const EdgeInsetsDirectional.all(32),
|
||||
child: const Column(
|
||||
spacing: 10,
|
||||
children: [
|
||||
|
@ -20,7 +20,7 @@ class EnergyConsumptionPerDeviceDevicesList extends StatelessWidget {
|
||||
|
||||
Widget _buildDeviceCell(int index) {
|
||||
return Container(
|
||||
padding: EdgeInsetsDirectional.symmetric(
|
||||
padding: const EdgeInsetsDirectional.symmetric(
|
||||
vertical: 8,
|
||||
horizontal: 12,
|
||||
),
|
||||
@ -34,14 +34,14 @@ class EnergyConsumptionPerDeviceDevicesList extends StatelessWidget {
|
||||
child: Row(
|
||||
spacing: 6,
|
||||
children: [
|
||||
CircleAvatar(
|
||||
const CircleAvatar(
|
||||
radius: 4,
|
||||
backgroundColor: Colors.purple,
|
||||
),
|
||||
Text(
|
||||
'Device ${index + 1}',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
style: const TextStyle(
|
||||
color: ColorsManager.blackColor,
|
||||
fontWeight: FontWeight.w400,
|
||||
fontSize: 14,
|
||||
|
@ -52,7 +52,7 @@ class TotalEnergyConsumptionChart extends StatelessWidget {
|
||||
)
|
||||
.toList(),
|
||||
color: ColorsManager.blueColor.withValues(alpha: 0.6),
|
||||
shadow: Shadow(color: Colors.black12),
|
||||
shadow: const Shadow(color: Colors.black12),
|
||||
show: true,
|
||||
isCurved: true,
|
||||
belowBarData: BarAreaData(
|
||||
@ -68,7 +68,7 @@ class TotalEnergyConsumptionChart extends StatelessWidget {
|
||||
end: Alignment.bottomCenter,
|
||||
),
|
||||
),
|
||||
dotData: FlDotData(show: false),
|
||||
dotData: const FlDotData(show: false),
|
||||
isStrokeCapRound: true,
|
||||
barWidth: 3,
|
||||
),
|
||||
|
@ -41,8 +41,8 @@ class _TotalEnergyConsumptionChartBoxState
|
||||
spacing: 20,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
ChartTitle(title: Text('Total Energy Consumption')),
|
||||
Divider(),
|
||||
const ChartTitle(title: Text('Total Energy Consumption')),
|
||||
const Divider(),
|
||||
TotalEnergyConsumptionChart(chartData: state.chartData),
|
||||
],
|
||||
),
|
||||
|
Reference in New Issue
Block a user