null safety

This commit is contained in:
efrilm
2025-09-19 19:12:35 +07:00
parent 6acfbdc4ca
commit 3022d8de9f
7 changed files with 41 additions and 39 deletions
@@ -73,26 +73,28 @@ class ProfitLossWidget extends StatelessWidget {
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
title,
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
color: Color(0xFF0F172A),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
title,
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
color: Color(0xFF0F172A),
),
),
),
const SizedBox(height: 6),
Text(
'Analisis profitabilitas dan margin keuntungan',
style: TextStyle(
fontSize: 14,
color: Colors.grey[600],
const SizedBox(height: 6),
Text(
'Analisis profitabilitas dan margin keuntungan',
style: TextStyle(
fontSize: 14,
color: Colors.grey[600],
),
),
),
],
],
),
),
Container(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10),
@@ -628,7 +630,7 @@ class ProfitLossWidget extends StatelessWidget {
);
}
Widget _buildProductMetric(String label, int value, Color color) {
Widget _buildProductMetric(String label, num value, Color color) {
return Container(
padding: const EdgeInsets.all(8),
decoration: BoxDecoration(
@@ -722,7 +724,7 @@ class ProfitLossWidget extends StatelessWidget {
sections: breakdownData.asMap().entries.map((entry) {
final item = entry.value;
final grossProfit = data.summary.grossProfit;
final value = item['value'] as int;
final value = item['value'] as num;
// Handle division by zero
final percentage =
@@ -772,7 +774,7 @@ class ProfitLossWidget extends StatelessWidget {
),
),
Text(
_formatCurrency(item['value'] as int),
_formatCurrency(item['value'] as num),
style: const TextStyle(
fontSize: 12,
fontWeight: FontWeight.bold,
@@ -1154,7 +1156,7 @@ class ProfitLossWidget extends StatelessWidget {
return AppColorProfitLoss.danger;
}
String _formatCurrency(int amount) {
String _formatCurrency(num amount) {
final formatter = NumberFormat.currency(
locale: 'id_ID',
symbol: 'Rp ',
@@ -1163,7 +1165,7 @@ class ProfitLossWidget extends StatelessWidget {
return formatter.format(amount);
}
String _formatCurrencyShort(int amount) {
String _formatCurrencyShort(num amount) {
if (amount >= 1000000) {
return 'Rp ${(amount / 1000000).round()}M';
} else if (amount >= 1000) {