Skip to content
Get started
Menu
Get started

Report a problem

Open a report from transaction detail to flag a duplicate charge, wrong amount, or missing purchase. The sheet carries the selected transaction’s reference and amount, so the person only has to pick a reason and can add an optional note. Reporting does not change the payment, open a dispute, or start a refund.

From example/:

Terminal window
flutter run -d <device-id> -t lib/history_block_demo.dart

Open any transaction and tap Laporkan masalah (Report a problem). You can also get there from Paged history in Gallery. To try recovery, select Gagal kirim laporan sekali in the standalone demo’s scenario menu before opening the transaction. Pick a reason, add a note and tap Kirim laporan. The first send fails before a case is created. Send again without retyping: the demo host confirms a case ID that stays visible until you close the sheet.

Copy report_problem_block.dart. Call showReportProblem(context, record: …, onSubmit: …) from the detail action, passing the selected TransactionRecord. The sheet sends a ReportProblemDraft with the stable transactionId, the displayed reference (the ID if the record has no reference), the reason, and the note. The note is optional and limited to 500 characters in the UI.

  1. Authorize the current account against the transaction ID on your server. Treat the reference and note as untrusted data; validate them server-side.
  2. Return a ConfirmedProblemReport with the draft your service actually accepted and its nonblank case ID. Throw when the submitted draft cannot be confirmed. The sheet keeps the current draft and shows retry copy if the confirmation is missing or refers to a different draft.
  3. Make retries safe in your host. The sheet blocks overlapping sends while open, but a timeout may mean the server accepted the report. Reconcile that submission or reuse a host-owned idempotency key for the same logical report rather than creating a second case. If the person edits the draft after a timeout, reconcile the outstanding submission before deciding whether the edited draft is a new report. Never attach an earlier case ID to the edited draft unless the service confirms it accepted the edit. Leave the payment and refund state alone.

An unconfirmed send keeps the draft in memory in the open sheet. Closing a dirty draft requires confirmation. There is no disk persistence, and the block does not send notes anywhere except through onSubmit. Do not log free text or ask users for PINs, OTPs or card numbers.

UI Existing library surface
Focused task and discard confirmation showPaymentFocusView, PaymentSheet, showPaymentConfirmDialog
Read-only transaction context and confirmed case ID PaymentPropertyList, AmountText
Reason, optional note and send PaymentSelect, PaymentTextArea, PaymentButton
Retry message PaymentBanner
Source: compositions/report_problem_block.dart

Open this file on GitHub. Copy and adapt it in your host app.

import 'dart:async';
import 'package:flutter/material.dart';
import 'package:rakit_ui/rakit_ui.dart';
enum ReportProblemReason { chargedTwice, wrongAmount, notReceived, other }
typedef ReportProblemDraft = ({
String transactionId,
String reference,
ReportProblemReason reason,
String note,
});
typedef ConfirmedProblemReport = ({ReportProblemDraft draft, String caseId});
/// Returns the draft the host actually accepted and its nonblank case ID.
/// Do not relabel an earlier confirmation with an edited draft. Throw if the
/// submitted draft cannot be confirmed. The host owns safe retries.
typedef SubmitProblemReport =
Future<ConfirmedProblemReport> Function(ReportProblemDraft draft);
/// Opens a draft for this transaction. Closing the sheet never submits a
/// report or changes the payment. Drafts only live while the sheet is open.
Future<void> showReportProblem(
BuildContext context, {
required TransactionRecord record,
required SubmitProblemReport onSubmit,
}) async {
if (ModalRoute.of(context)?.isCurrent == false) return;
await showPaymentFocusView<void>(
context,
builder: (_) => _ReportProblemSheet(record: record, onSubmit: onSubmit),
);
}
enum _SendState { idle, sending, failed }
class _ReportProblemSheet extends StatefulWidget {
const _ReportProblemSheet({required this.record, required this.onSubmit});
final TransactionRecord record;
final SubmitProblemReport onSubmit;
@override
State<_ReportProblemSheet> createState() => _ReportProblemSheetState();
}
class _ReportProblemSheetState extends State<_ReportProblemSheet> {
final _note = TextEditingController();
final _retryMessage = GlobalKey();
ReportProblemReason? _reason;
_SendState _state = _SendState.idle;
String? _caseId;
int _attempt = 0;
bool _closeAfterKeyboard = false;
String get _reference => widget.record.reference ?? widget.record.id;
bool get _sending => _state == _SendState.sending;
String _t(String en, String id) =>
Localizations.localeOf(context).languageCode == 'id' ? id : en;
@override
void dispose() {
_note.dispose();
super.dispose();
}
Future<void> _close() async {
final route = ModalRoute.of(context);
if (_sending || route == null || !route.isCurrent) return;
if (_caseId == null && (_reason != null || _note.text.isNotEmpty)) {
if (MediaQuery.viewInsetsOf(context).bottom > 0) {
// The confirmation sheet does not avoid the keyboard. Wait for the
// actual inset change rather than guessing the IME animation time.
_closeAfterKeyboard = true;
FocusScope.of(context).unfocus();
return;
}
final discard = await showPaymentConfirmDialog(
context,
title: _t('Discard this report?', 'Buang laporan ini?'),
message: _t(
'Your reason and note will be lost.',
'Alasan dan catatan Anda akan hilang.',
),
confirmLabel: _t('Discard', 'Buang'),
destructive: true,
);
if (!discard || !mounted || !route.isCurrent || _sending) return;
}
Navigator.pop(context);
}
Future<void> _send() async {
final reason = _reason;
if (reason == null ||
_sending ||
_caseId != null ||
ModalRoute.of(context)?.isCurrent != true) {
return;
}
final draft = (
transactionId: widget.record.id,
reference: _reference,
reason: reason,
note: _note.text,
);
FocusScope.of(context).unfocus();
setState(() {
_closeAfterKeyboard = false;
_attempt++;
_state = _SendState.sending;
});
String? caseId;
try {
final confirmed = await widget.onSubmit(draft);
if (confirmed.draft == draft) caseId = confirmed.caseId.trim();
} catch (_) {
// Host errors may contain private details; only show safe recovery copy.
}
if (!mounted) return;
setState(() {
if (caseId != null && caseId.isNotEmpty) {
_caseId = caseId;
_state = _SendState.idle;
} else {
_state = _SendState.failed;
}
});
if (_state == _SendState.failed) {
WidgetsBinding.instance.addPostFrameCallback((_) {
// On a short screen this banner scrolls with the form. Bring it
// into view even when the editor was at the bottom of the viewport.
final message = _retryMessage.currentContext;
if (message != null) unawaited(Scrollable.ensureVisible(message));
});
}
}
@override
Widget build(BuildContext context) {
final keyboard = MediaQuery.viewInsetsOf(context).bottom;
if (_closeAfterKeyboard && keyboard == 0) {
WidgetsBinding.instance.addPostFrameCallback((_) {
// Send may have canceled the close since this frame was built.
if (!mounted || !_closeAfterKeyboard) return;
_closeAfterKeyboard = false;
unawaited(_close());
});
}
return PopScope<void>(
// Every dismissal goes through live state, even if Back follows Send
// before Flutter rebuilds the footer.
canPop: false,
onPopInvokedWithResult: (didPop, _) {
if (!didPop) unawaited(_close());
},
child: LayoutBuilder(
builder: (context, constraints) => _buildSheet(
context,
constraints.maxHeight - keyboard,
keyboard > 0,
),
),
);
}
Widget _buildSheet(
BuildContext context,
double availableHeight,
bool keyboardOpen,
) {
final l = PaymentLocalizations.of(context);
final t = _t;
final theme = PaymentTheme.of(context);
final compact = availableHeight < 360 || keyboardOpen;
// Leave an editing viewport as well as a full-sized button. At smaller
// heights the action scrolls with the form instead of taking all the room.
final pinAction = availableHeight >= 160;
const sheetKey = Key('report-problem-sheet');
if (_caseId case final caseId?) {
final title = t('Report sent', 'Laporan terkirim');
final caseLabel = t('Case ID', 'ID kasus');
final header = PaymentSheetHeader(
title: title,
onClose: () => unawaited(_close()),
);
final done = PaymentButton(
label: t('Done', 'Selesai'),
onPressed: _close,
);
return PaymentSheet(
key: sheetKey,
header: compact ? null : header,
footer: pinAction ? done : null,
body: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
if (compact) header,
Semantics(
container: true,
liveRegion: true,
excludeSemantics: true,
label: '$title. $caseLabel: $caseId',
child: PaymentPropertyList(
items: [
PaymentPropertyListItem(label: caseLabel, valueText: caseId),
],
),
),
if (!pinAction) done,
],
),
);
}
final header = PaymentSheetHeader(
title: t('Report a problem', 'Laporkan masalah'),
onClose: _sending ? null : () => unawaited(_close()),
);
final error = _state == _SendState.failed
? KeyedSubtree(
key: _retryMessage,
child: PaymentBanner(
key: ValueKey(_attempt),
tone: StatusTone.danger,
title: t(
'No case ID yet. Try again.',
'Belum ada ID kasus. Coba lagi.',
),
announce: !keyboardOpen,
),
)
: null;
final send = PaymentButton(
key: const Key('send-report'),
label: t('Send report', 'Kirim laporan'),
busyLabel: t('Sending report', 'Mengirim laporan'),
busy: _sending,
onPressed: _reason == null || _sending ? null : _send,
);
return PaymentSheet(
key: sheetKey,
// Keep the scroll view mounted when both header and footer change.
header: SizedBox(child: compact ? null : header),
footer: !pinAction
? null
: compact
? send
: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
spacing: theme.space(PaymentSpace.related),
children: [
?error,
PaymentButtonGroup(
direction: Axis.vertical,
children: [
send,
PaymentButton(
key: const Key('report-cancel'),
label: l.cancel,
variant: PaymentButtonVariant.quiet,
onPressed: _sending ? null : _close,
),
],
),
],
),
body: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
spacing: theme.space(PaymentSpace.group),
children: [
if (compact) ...[header, ?error],
PaymentPropertyList(
items: [
PaymentPropertyListItem(
label: t('Reference', 'Referensi'),
valueText: _reference,
),
PaymentPropertyListItem(
label: t('Amount', 'Nominal'),
value: AmountText(widget.record.amount),
),
],
),
PaymentSelect<ReportProblemReason>(
label: t('What went wrong?', 'Apa masalahnya?'),
value: _reason,
onChanged: _sending
? null
: (value) => setState(() => _reason = value),
options: [
for (final reason in ReportProblemReason.values)
PaymentSelectOption(
value: reason,
label: switch (reason) {
ReportProblemReason.chargedTwice => t(
'Charged twice',
'Terdebit dua kali',
),
ReportProblemReason.wrongAmount => t(
'Wrong amount',
'Nominal salah',
),
ReportProblemReason.notReceived => t(
"Didn't get what I paid for",
'Pesanan tidak diterima',
),
ReportProblemReason.other => t('Something else', 'Lainnya'),
},
),
],
),
PaymentTextArea(
key: const ValueKey('report-note'),
label: t(
'Describe the problem (optional)',
'Jelaskan masalahnya (opsional)',
),
description: t(
"Don't include your PIN, OTP or card number.",
'Jangan tulis PIN, OTP, atau nomor kartu.',
),
controller: _note,
minLines: compact ? 1 : 3,
maxLength: 500,
enabled: !_sending,
),
if (!pinAction) send,
],
),
);
}
}
Source: history_block_demo.dart

Open this file on GitHub. Copy and adapt it in your host app.

import 'dart:async';
import 'package:flutter/material.dart';
import 'package:rakit_ui/rakit_ui.dart';
import 'block_demo_shell.dart';
import 'compositions/merchant_history.dart';
import 'compositions/report_problem_block.dart';
void main() => runBlockDemo(const HistoryBlockDemo());
enum HistoryDemoState { ready, loading, empty, error, nextPageError }
enum _PageRequest { idle, loading, failed }
typedef HistoryPage = ({List<TransactionRecord> records, String? nextCursor});
typedef HistoryPageSource =
Future<HistoryPage> Function(
String query,
TransactionFilter filter,
String? cursor,
);
final _historyFixture = [
for (final (id, amount, method, status, minute) in [
('INV-2048', 150000, 'QRIS', PaymentStatus.succeeded, 42),
('INV-2047', 320000, 'Transfer', null, 38),
('INV-2046', 210000, 'QRIS', PaymentStatus.pending, 30),
('INV-2045', 95000, 'Saldo', PaymentStatus.failed, 20),
])
TransactionRecord(
id: id,
title: id,
reference: id,
amount: Money.idr(amount),
createdAt: DateTime(2026, 11, 4, 10, minute),
methodLabel: method,
status: status,
),
TransactionRecord(
id: 'INV-2044',
title: 'INV-2044',
reference: 'INV-2044',
amount: const Money.idr(240000),
createdAt: DateTime(2026, 11, 3, 15, 10),
methodLabel: 'Transfer',
status: PaymentStatus.succeeded,
refund: const RefundInfo(
status: RefundStatus.partial,
amount: Money.idr(50000),
),
),
for (var i = 0; i < 24; i++)
TransactionRecord(
id: 'INV-${2043 - i}',
title: 'INV-${2043 - i}',
reference: 'INV-${2043 - i}',
amount: Money.idr(75000 + 5000 * i),
createdAt: DateTime(2026, 11, 3).subtract(Duration(days: i)),
methodLabel: i.isEven ? 'QRIS' : 'Transfer',
status: i % 3 == 0 ? PaymentStatus.failed : PaymentStatus.succeeded,
),
];
/// A runnable host with a synthetic cursor source. No network or payment occurs.
class HistoryBlockDemo extends StatefulWidget {
const HistoryBlockDemo({
super.key,
this.initialState = HistoryDemoState.ready,
this.initialDark = false,
this.embedded = false,
this.fetchPage,
this.submitReport,
this.fixtureDelay = const Duration(milliseconds: 280),
});
final HistoryDemoState initialState;
final bool initialDark;
final bool embedded;
final HistoryPageSource? fetchPage;
final SubmitProblemReport? submitReport;
final Duration fixtureDelay;
@override
State<HistoryBlockDemo> createState() => _HistoryBlockDemoState();
}
class _HistoryBlockDemoState extends State<HistoryBlockDemo> {
late HistoryDemoState _mode = widget.initialState;
late bool _dark = widget.initialDark;
String _query = '';
TransactionFilter _filter = TransactionFilter.all;
List<TransactionRecord> _records = [];
String? _nextCursor;
int _generation = 0;
int _failedAttempt = 0;
_PageRequest _request = _PageRequest.idle;
bool _failNextReport = false;
int _cases = 0;
@override
void initState() {
super.initState();
unawaited(_loadPage());
}
void _restart(String query, TransactionFilter filter) {
setState(() {
_generation++;
_query = query;
_filter = filter;
_records = [];
_nextCursor = null;
_request = _PageRequest.idle;
});
unawaited(_loadPage());
}
Future<void> _loadPage() async {
if (_request == _PageRequest.loading ||
(_nextCursor == null && _records.isNotEmpty)) {
return;
}
final generation = _generation;
final cursor = _nextCursor;
setState(() => _request = _PageRequest.loading);
if (_mode == HistoryDemoState.loading) return;
try {
final page = await (widget.fetchPage ?? _fixturePage)(
_query,
_filter,
cursor,
);
// A completed request (including an error) may belong to an old query.
if (!mounted || generation != _generation) return;
setState(() {
_records = [..._records, ...page.records];
_nextCursor = page.nextCursor;
_request = _PageRequest.idle;
});
} catch (_) {
if (!mounted || generation != _generation) return;
setState(() {
_request = _PageRequest.failed;
_failedAttempt++;
});
}
}
Future<HistoryPage> _fixturePage(
String query,
TransactionFilter filter,
String? cursor,
) async {
final mode = _mode;
final fail =
mode == HistoryDemoState.error ||
(mode == HistoryDemoState.nextPageError && cursor != null);
if (fail) _mode = HistoryDemoState.ready;
if (widget.fixtureDelay > Duration.zero) {
await Future<void>.delayed(widget.fixtureDelay);
}
if (fail) throw StateError('Synthetic page failure');
final matching = TransactionRecord.where(
mode == HistoryDemoState.empty ? const [] : _historyFixture,
query: query,
filter: filter,
);
// Only the synthetic server interprets the cursor.
final start = cursor == null ? 0 : int.parse(cursor);
final end = start + 3;
return (
records: matching.skip(start).take(3).toList(),
nextCursor: end < matching.length ? '$end' : null,
);
}
Future<ConfirmedProblemReport> _submitFixtureReport(
ReportProblemDraft draft,
) async {
final fail = _failNextReport;
_failNextReport = false;
if (widget.fixtureDelay > Duration.zero) {
await Future<void>.delayed(widget.fixtureDelay);
}
if (fail) throw StateError('Synthetic rejection before creating a case');
return (
draft: draft,
caseId: 'CASE-DEMO-${(++_cases).toString().padLeft(4, '0')}',
);
}
Widget _block(BuildContext context) => MerchantHistory(
records: _records,
query: _query,
filter: _filter,
onQueryChanged: (value) => _restart(value, _filter),
onFilterChanged: (value) {
if (value != _filter) _restart(_query, value);
},
onResetFilters: () => _restart('', TransactionFilter.all),
hasMore: _nextCursor != null,
loading: _request == _PageRequest.loading,
error: _request != _PageRequest.failed
? null
: (
attempt: _failedAttempt,
message: switch ((
Localizations.localeOf(context).languageCode,
_nextCursor,
)) {
('id', null) => 'Riwayat belum dapat dimuat. Coba lagi.',
('id', _) =>
'Halaman berikutnya gagal dimuat. Transaksi sebelumnya tetap tersedia.',
(_, null) => 'History couldn’t load. Try again.',
_ =>
'Couldn’t load the next page. Previous transactions are still available.',
},
),
onRequestPage: () => unawaited(_loadPage()),
onOpen: (record) => showPaymentSheet<void>(
context: context,
builder: (context) => MerchantHistoryDetail(
record: record,
onClose: () => Navigator.pop(context),
onReport: () {
unawaited(
showReportProblem(
context,
record: record,
onSubmit: widget.submitReport ?? _submitFixtureReport,
),
);
},
),
),
);
@override
Widget build(BuildContext context) => widget.embedded
? _block(context)
: BlockDemoShell(
title: 'Riwayat · Demo',
dark: _dark,
onToggleDark: () => setState(() => _dark = !_dark),
scenarios: [
for (final (state, label) in [
(HistoryDemoState.ready, 'Data tersedia'),
(HistoryDemoState.loading, 'Memuat'),
(HistoryDemoState.empty, 'Belum ada transaksi'),
(HistoryDemoState.error, 'Gagal memuat riwayat'),
(
HistoryDemoState.nextPageError,
'Gagal memuat halaman berikutnya',
),
])
(
label: label,
onSelected: () {
_mode = state;
_restart('', TransactionFilter.all);
},
),
(
label: 'Gagal kirim laporan sekali',
onSelected: () => _failNextReport = true,
),
],
body: _block,
);
}

The Transaction history block shows the detail action. The demo uses synthetic transactions and case IDs; it is not a support integration.