Bersihkan semua 20 analyzer issue: hapus _initAuth/_ProductCard/dead code, rename underscore var, print->debugPrint, perbaiki BuildContext async guard (analyze 0 issue)

This commit is contained in:
Onie
2026-10-18 15:16:14 +07:00
parent a3629a7d82
commit a52e0ea9b1
5 changed files with 27 additions and 168 deletions

View File

@@ -211,7 +211,7 @@ class _RiwayatScreenState extends State<RiwayatScreen> {
lastDate: DateTime.now(),
initialDateRange: _dateRange,
);
if (mounted && picked != null) {
if (picked != null && context.mounted) {
setState(() => _dateRange = picked);
context.read<AppState>().resetPagination();
}
@@ -691,7 +691,6 @@ class _RiwayatScreenState extends State<RiwayatScreen> {
final result = await showDialog<double>(
context: parentContext,
builder: (ctx) {
bool submitting = false;
return StatefulBuilder(
builder: (context, setDialog) {
final isUnpaid = currentSale.paymentStatus == 'unpaid';
@@ -784,7 +783,7 @@ class _RiwayatScreenState extends State<RiwayatScreen> {
children: [
Expanded(
child: OutlinedButton(
onPressed: submitting ? null : () => Navigator.pop(ctx),
onPressed: () => Navigator.pop(ctx),
style: OutlinedButton.styleFrom(
foregroundColor: kMuted,
side: const BorderSide(color: kBorder),
@@ -795,17 +794,13 @@ class _RiwayatScreenState extends State<RiwayatScreen> {
const SizedBox(width: 10),
Expanded(
child: FilledButton(
onPressed: submitting
? null
: () {
onPressed: () {
final val = (RupiahInputFormatter.getRawValue(payCtrl.text) ?? 0).toDouble();
if (val <= 0) return;
Navigator.pop(ctx, val);
},
style: FilledButton.styleFrom(backgroundColor: kSuccess, foregroundColor: const Color(0xFF06210F)),
child: submitting
? const SizedBox(height: 18, width: 18, child: CircularProgressIndicator(strokeWidth: 2, color: Color(0xFF06210F)))
: const Text('Simpan'),
child: const Text('Simpan'),
),
),
],
@@ -830,7 +825,7 @@ class _RiwayatScreenState extends State<RiwayatScreen> {
if (sheetContext.mounted) {
Navigator.pop(sheetContext);
}
if (mounted) {
if (parentContext.mounted) {
final messenger = ScaffoldMessenger.of(parentContext);
final msg = err == null
? isNowPaid
@@ -865,7 +860,6 @@ class _RiwayatScreenState extends State<RiwayatScreen> {
final confirm = await showDialog<bool>(
context: parentContext,
builder: (ctx) {
bool cancelling = false;
return StatefulBuilder(
builder: (context, setDialog) {
return AlertDialog(
@@ -879,7 +873,7 @@ class _RiwayatScreenState extends State<RiwayatScreen> {
children: [
Expanded(
child: OutlinedButton(
onPressed: cancelling ? null : () => Navigator.pop(ctx, false),
onPressed: () => Navigator.pop(ctx, false),
style: OutlinedButton.styleFrom(
foregroundColor: kMuted,
side: const BorderSide(color: kBorder),
@@ -890,13 +884,9 @@ class _RiwayatScreenState extends State<RiwayatScreen> {
const SizedBox(width: 10),
Expanded(
child: FilledButton(
onPressed: cancelling
? null
: () => Navigator.pop(ctx, true),
onPressed: () => Navigator.pop(ctx, true),
style: FilledButton.styleFrom(backgroundColor: kDanger),
child: cancelling
? const SizedBox(height: 18, width: 18, child: CircularProgressIndicator(strokeWidth: 2, color: Colors.white))
: const Text('Batalkan'),
child: const Text('Batalkan'),
),
),
],
@@ -909,7 +899,7 @@ class _RiwayatScreenState extends State<RiwayatScreen> {
);
if (confirm == true && mounted) {
final err = await state.cancelSale(currentSale.id);
if (mounted) {
if (sheetContext.mounted) {
Navigator.pop(sheetContext);
messenger.showSnackBar(
SnackBar(