pilot_ui 0.0.13
pilot_ui: ^0.0.13 copied to clipboard
A dynamic, theme-aware JSON UI rendering engine for Flutter with extensible parsers, action handlers, and ready-to-use smart dispatch & RTS action components.
example/lib/main.dart
import 'package:flutter/material.dart';
import 'package:pilot_ui/pilot.dart';
void main() {
runApp(const PilotExampleApp());
}
class PilotExampleApp extends StatelessWidget {
const PilotExampleApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Pilot Example',
debugShowCheckedModeBanner: false,
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
textTheme: const TextTheme(
titleMedium: TextStyle(fontWeight: FontWeight.w600, color: Colors.black87),
bodyLarge: TextStyle(fontWeight: FontWeight.w600, color: Colors.black87),
),
elevatedButtonTheme: ElevatedButtonThemeData(
style: ElevatedButton.styleFrom(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
elevation: 0,
backgroundColor: const Color(0xFF7C4DFF),
foregroundColor: Colors.white,
),
),
textButtonTheme: TextButtonThemeData(
style: TextButton.styleFrom(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
side: const BorderSide(color: Color(0xFFE0E0E0)),
),
foregroundColor: const Color(0xFF5C6BC0),
),
),
),
home: const RtsDashboardScreen(),
);
}
}
class RtsDashboardScreen extends StatefulWidget {
const RtsDashboardScreen({super.key});
@override
State<RtsDashboardScreen> createState() => _RtsDashboardScreenState();
}
class _RtsDashboardScreenState extends State<RtsDashboardScreen> {
// Dummy RTS Events matching the UI mockups
final List<Map<String, dynamic>> _dummyEvents = [
{
"id": 210,
"event_type": "rts",
"severity": "warning",
"urgency": "warning",
"title": "Abas Ali is asking to return to station with 1 undelivered package",
"description": "Driver Abas Ali requested a return to station while still having 1 undelivered package on his route.",
"ai_diagnosis": "• **Driver:** Abas Ali (📞 9524289296)\n• **Undelivered Packages:** 1\n• **Return Reason:** Undeliverable packages return\n• **Operational Recommendation:** Reject the RTS request as there are still undelivered packages remaining on the route.",
"audio_url": "https://d2m6ddk1wudw4z.cloudfront.net/pilot_audio/5979a604-15c5-43e8-98b0-fe6ad5c4d3d3.wav",
"is_actionable": true,
"action_type": "APPROVE_RTS",
"action_label": "Reject",
"action_payload": {
"reason": "Please complete remaining deliveries on your route before returning.",
"status": "rejected",
"user_id": 25,
"driver_id": 24
},
"actions": [],
"ui_schema": {
"data": {
"id": 17,
"reason": "Undeliverable packages return",
"status": "rts_pending",
"user_id": 25,
"latitude": null,
"driver_id": 24,
"longitude": null,
"driver_name": "Abas Ali",
"driver_phone": "9524289296",
"last_message": {
"id": 96,
"message": "🚨 RTS Requested\nUndeliverables: 1\nReason: Undeliverable packages return",
"sender_id": 25,
"created_at": "2026-09-17T23:26:22.595004",
"attachments": [],
"sender_name": "Abas Ali",
"sender_role": "driver",
"attachment_url": null,
"message_content": "🚨 RTS Requested\nUndeliverables: 1\nReason: Undeliverable packages return"
},
"requested_at": "2026-09-17T23:26:22.579921",
"attendance_id": 118,
"location_name": null,
"transporter_id": "A3GCA2K2BYII3J",
"has_conversation": true,
"undeliverables_count": 1,
"unread_message_count": 0
},
"badge": "WARNING",
"urgency": "warning",
"severity": "warning",
"driver_id": "24",
"driver_name": "Abas Ali",
"driver_phone": "9524289296",
"component_type": "RtsActionCard"
},
"status": "pending",
"target_role": "admin",
"target_user_id": null,
"created_by": null,
"expires_in_seconds": null,
"expires_at": null,
"created_at": "2026-09-17T23:26:22.703939Z",
"updated_at": "2026-09-17T23:26:36.500532Z"
},
{
"id": 209,
"event_type": "rts",
"severity": "warning",
"urgency": "warning",
"title": "📦 Jared Blade Snodgrass Brown is asking to return to station with 2 undelivered packages",
"description": "Driver Jared Blade Snodgrass Brown has requested a return to station due to closed businesses with 2 packages remaining.",
"ai_diagnosis": "• **Driver:** Jared Blade Snodgrass Brown (📞 6129977150)\n• **Undelivered Packages:** 2\n• **Return Reason:** businesses closed\n• **Operational Recommendation:** Reject the RTS request since there are still undelivered packages on the route that need attention.",
"audio_url": "https://d2m6ddk1wudw4z.cloudfront.net/pilot_audio/53348b38-e0fd-47f1-b41a-c5ce90c5452c.wav",
"is_actionable": true,
"action_type": "APPROVE_RTS",
"action_label": "Reject",
"action_payload": {
"reason": "Rejected. Please complete remaining deliveries on your route before returning.",
"status": "rejected",
"user_id": 125,
"driver_id": 124
},
"actions": [
{
"action_type": "APPROVE_RTS",
"action_label": "Approve",
"action_payload": {
"reason": "",
"status": "approved",
"user_id": 125,
"driver_id": 124
}
},
{
"action_type": "APPROVE_RTS",
"action_label": "Reject",
"action_payload": {
"reason": "",
"status": "rejected",
"user_id": 125,
"driver_id": 124
}
}
],
"ui_schema": {
"data": {
"id": 16,
"reason": "businesses closed",
"status": "rts_pending",
"user_id": 125,
"latitude": null,
"driver_id": 124,
"longitude": null,
"driver_name": "Jared Blade Snodgrass Brown",
"driver_phone": "6129977150",
"last_message": {
"id": 94,
"message": "🚨 RTS Requested\nUndeliverables: 2\nReason: businesses closed",
"sender_id": 125,
"created_at": "2026-09-17T22:24:59.702443",
"attachments": [],
"sender_name": "Jared Blade Snodgrass Brown",
"sender_role": "driver",
"attachment_url": null,
"message_content": "🚨 RTS Requested\nUndeliverables: 2\nReason: businesses closed"
},
"requested_at": "2026-09-17T22:24:59.686120",
"attendance_id": 111,
"location_name": null,
"transporter_id": "A3UB071MJRIPP3",
"has_conversation": true,
"undeliverables_count": 2,
"unread_message_count": 0
},
"badge": "WARNING",
"urgency": "warning",
"severity": "warning",
"driver_id": "124",
"driver_name": "Jared Blade Snodgrass Brown",
"driver_phone": "6129977150",
"component_type": "RtsActionCard"
},
"status": "pending",
"target_role": "admin",
"target_user_id": null,
"created_by": null,
"expires_in_seconds": null,
"expires_at": null,
"created_at": "2026-09-17T22:24:59.799514Z",
"updated_at": "2026-09-17T22:25:11.822852Z"
},
{
"id": 208,
"event_type": "route_pace",
"severity": "warning",
"urgency": "warning",
"title": "⚠️ Route TX96 is running behind schedule",
"description": "Route TX96 operated by Spencer James Suchoski is currently behind pace with 21 stops remaining.",
"ai_diagnosis": "• **Driver:** Spencer James Suchoski • **Pace Variance:** 0 stops behind target pace • **Workload Remaining:** 21 stops / 22 deliveries remaining • **Projected RTS Impact:** Low impact on return to station time • **Recommendation:** Monitor progress over the next 30 minutes",
"audio_url": "https://d2m6ddk1wudw4z.cloudfront.net/pilot_audio/5ea723fd-eb67-4d75-a5d2-3db89c8c6651.wav",
"is_actionable": false,
"action_type": null,
"action_label": null,
"action_payload": {},
"actions": [],
"ui_schema": {
"data": {
"id": 101,
"lat": null,
"long": null,
"speed": null,
"status": "open",
"route_id": 18,
"created_at": "2026-09-17T11:27:29.039522",
"created_by": 3,
"deleted_at": null,
"is_deleted": false,
"route_code": "TX96",
"updated_at": "2026-09-17T22:10:31.949557",
"updated_by": 3,
"driver_name": "Spencer James Suchoski",
"pace_status": "BEHIND",
"total_stops": 199,
"estimate_rts": null,
"transporter_id": "A343H7XLTDEHJX",
"completed_stops": 178,
"current_stop_id": null,
"daily_roster_id": 4,
"pace_difference": 0,
"remaining_stops": 21,
"last_location_at": null,
"total_deliveries": 260,
"completed_deliveries": 238,
"remaining_deliveries": 22
},
"badge": "WARNING",
"urgency": "warning",
"route_id": "18",
"severity": "warning",
"driver_name": "Spencer James Suchoski",
"component_type": "DefaultActionCard"
},
"status": "pending",
"target_role": "admin",
"target_user_id": 193,
"created_by": null,
"expires_in_seconds": null,
"expires_at": null,
"created_at": "2026-09-17T22:10:31.975603Z",
"updated_at": "2026-09-17T22:10:42.413244Z"
},
{
"id": 164,
"event_type": "route_alert",
"severity": "critical",
"urgency": "critical",
"title": "🚨 10 safety violations recorded for Kevin Michael Davis in SYD971 (Latest: Backing)",
"description": "Kevin Michael Davis has accumulated 10 repeat safety alerts today while operating vehicle SYD971, heavily dominated by frequent backing incidents. Immediate operational review is required to address spatial navigation habits.",
"ai_diagnosis": "• **Driver:** Kevin Michael Davis (📞 6125923033)\n• **Vehicle / Route:** SYD971 / Route Standard Parcel - Extra Large Van - US\n• **Total Violations (10):** 1 Safety Violation, 8 Backing, 1 Hard Acceleration\n• **Latest Violation:** Backing (Backing at Moderate Speed)\n• **Safety Event Timeline:**\n - 12:06:02 AM: **Safety Violation** (Driver Kevin Michael Davis triggered a moderate backing safety violation while operating vehicle SYD971.)\n - 06:48:00 PM: **Backing** (Backing at Moderate Speed)\n - 07:12:00 PM: **Backing** (Backing at Moderate Speed)\n - 07:33:00 PM: **Backing** (Backing at Moderate Speed)\n - 07:54:00 PM: **Backing** (Backing at Moderate Speed)\n - 07:57:01 PM: **Backing** (Backing at Moderate Speed)\n - 08:06:00 PM: **Backing** (Backing at Moderate Speed)\n - 09:39:00 PM: **Backing** (Backing at Moderate Speed)\n - 09:51:00 PM: **Hard acceleration** (Moderate)\n - 09:57:00 PM: **Backing** (Backing at Moderate Speed)\n• **Repeat Pattern & Risk Analysis:** The driver shows a persistent, highly repetitive pattern of unsafe backing maneuvers throughout the shift, compounded by a sudden hard acceleration. This indicates potential delivery rushing, spatial disorientation in tight spaces, or poor route planning requiring frequent reversing.\n• **Operational Recommendation:** Pull the driver aside for immediate safety coaching focused on proper parking positioning and avoiding unnecessary reversing, and audit the route map for difficult delivery locations.",
"audio_url": "https://d2m6ddk1wudw4z.cloudfront.net/pilot_audio/1a85bbd3-4054-4e13-856f-090c3360d9f0.wav",
"is_actionable": false,
"action_type": null,
"action_label": null,
"action_payload": {},
"actions": [],
"ui_schema": {
"data": {
"id": 274,
"title": "Backing",
"category": "Backing",
"severity": "Moderate",
"driver_id": 131,
"video_url": "https://idms.netradyne.com/console/#/alerts/6519537809",
"alert_type": "Backing",
"created_at": "2026-09-17T21:57:00.570412",
"created_by": null,
"deleted_at": null,
"is_deleted": false,
"route_code": "Standard Parcel - Extra Large Van - US",
"updated_at": "2026-09-17T21:57:00.570593",
"updated_by": null,
"vehicle_id": 5,
"description": "Backing at Moderate Speed",
"driver_name": "Kevin Michael Davis",
"resolved_at": null,
"driver_phone": "6125923033",
"triggered_at": "2026-09-17T21:53:00",
"vehicle_name": "SYD971",
"acknowledged_at": null,
"daily_roster_id": 4,
"alert_external_id": "6519537809",
"is_safety_violation": true,
"route_assignment_id": 127,
"previous_occurrences": [
{
"time": "12:06:02 AM",
"alert_type": "Safety Violation",
"route_code": "Route",
"description": "Driver Kevin Michael Davis triggered a moderate backing safety violation while operating vehicle SYD971.",
"vehicle_name": "Vehicle"
},
{
"time": "06:48:00 PM",
"alert_type": "Backing",
"route_code": "Standard Parcel - Extra Large Van - US",
"description": "Backing at Moderate Speed",
"vehicle_name": "SYD971"
},
{
"time": "07:12:00 PM",
"alert_type": "Backing",
"route_code": "Standard Parcel - Extra Large Van - US",
"description": "Backing at Moderate Speed",
"vehicle_name": "SYD971"
},
{
"time": "07:33:00 PM",
"alert_type": "Backing",
"route_code": "Standard Parcel - Extra Large Van - US",
"description": "Backing at Moderate Speed",
"vehicle_name": "SYD971"
},
{
"time": "07:54:00 PM",
"alert_type": "Backing",
"route_code": "Standard Parcel - Extra Large Van - US",
"description": "Backing at Moderate Speed",
"vehicle_name": "SYD971"
},
{
"time": "07:57:01 PM",
"alert_type": "Backing",
"route_code": "Standard Parcel - Extra Large Van - US",
"description": "Backing at Moderate Speed",
"vehicle_name": "SYD971"
},
{
"time": "08:06:00 PM",
"alert_type": "Backing",
"route_code": "Standard Parcel - Extra Large Van - US",
"description": "Backing at Moderate Speed",
"vehicle_name": "SYD971"
},
{
"time": "09:39:00 PM",
"alert_type": "Backing",
"route_code": "Standard Parcel - Extra Large Van - US",
"description": "Backing at Moderate Speed",
"vehicle_name": "SYD971"
},
{
"time": "09:51:00 PM",
"alert_type": "Hard acceleration",
"route_code": "Standard Parcel - Extra Large Van - US",
"description": "Moderate",
"vehicle_name": "SYD971"
},
{
"time": "09:57:00 PM",
"alert_type": "Backing",
"route_code": "Standard Parcel - Extra Large Van - US",
"description": "Backing at Moderate Speed",
"vehicle_name": "SYD971"
}
]
},
"badge": "CRITICAL",
"urgency": "critical",
"severity": "critical",
"driver_id": "131",
"vehicle_id": "5",
"driver_name": "Kevin Michael Davis",
"event_count": 10,
"occurrences": [
{
"time": "12:06:02 AM",
"alert_type": "Safety Violation",
"route_code": "Route",
"description": "Driver Kevin Michael Davis triggered a moderate backing safety violation while operating vehicle SYD971.",
"vehicle_name": "Vehicle"
},
{
"time": "06:48:00 PM",
"alert_type": "Backing",
"route_code": "Standard Parcel - Extra Large Van - US",
"description": "Backing at Moderate Speed",
"vehicle_name": "SYD971"
},
{
"time": "07:12:00 PM",
"alert_type": "Backing",
"route_code": "Standard Parcel - Extra Large Van - US",
"description": "Backing at Moderate Speed",
"vehicle_name": "SYD971"
},
{
"time": "07:33:00 PM",
"alert_type": "Backing",
"route_code": "Standard Parcel - Extra Large Van - US",
"description": "Backing at Moderate Speed",
"vehicle_name": "SYD971"
},
{
"time": "07:54:00 PM",
"alert_type": "Backing",
"route_code": "Standard Parcel - Extra Large Van - US",
"description": "Backing at Moderate Speed",
"vehicle_name": "SYD971"
},
{
"time": "07:57:01 PM",
"alert_type": "Backing",
"route_code": "Standard Parcel - Extra Large Van - US",
"description": "Backing at Moderate Speed",
"vehicle_name": "SYD971"
},
{
"time": "08:06:00 PM",
"alert_type": "Backing",
"route_code": "Standard Parcel - Extra Large Van - US",
"description": "Backing at Moderate Speed",
"vehicle_name": "SYD971"
},
{
"time": "09:39:00 PM",
"alert_type": "Backing",
"route_code": "Standard Parcel - Extra Large Van - US",
"description": "Backing at Moderate Speed",
"vehicle_name": "SYD971"
},
{
"time": "09:51:00 PM",
"alert_type": "Hard acceleration",
"route_code": "Standard Parcel - Extra Large Van - US",
"description": "Moderate",
"vehicle_name": "SYD971"
},
{
"time": "09:57:00 PM",
"alert_type": "Backing",
"route_code": "Standard Parcel - Extra Large Van - US",
"description": "Backing at Moderate Speed",
"vehicle_name": "SYD971"
}
],
"driver_phone": "6125923033",
"component_type": "DefaultActionCard"
},
"status": "pending",
"target_role": "admin",
"target_user_id": 132,
"created_by": null,
"expires_in_seconds": null,
"expires_at": null,
"created_at": "2026-09-17T21:57:00.579889Z",
"updated_at": "2026-09-17T21:57:14.911986Z"
},
{
"id": 206,
"event_type": "rts",
"severity": "warning",
"urgency": "warning",
"title": "📦 Bepara Cham Cham is asking to return to station with 1 undelivered package",
"description": "Driver Bepara Cham Cham is requesting an RTS with 1 remaining undelivered package on the route.",
"ai_diagnosis": "• **Driver:** Bepara Cham Cham (📞 6513610418)\n• **Undelivered Packages:** 1\n• **Return Reason:** Undeliverable packages return\n• **Operational Recommendation:** Reject the RTS request as there is still 1 pending delivery that must be attempted.",
"audio_url": "https://d2m6ddk1wudw4z.cloudfront.net/pilot_audio/a2e2b5e0-0591-4663-a06c-da9394f55641.wav",
"is_actionable": true,
"action_type": "APPROVE_RTS",
"action_label": "Reject",
"action_payload": {
"reason": "Rejected. Please complete your remaining delivery on the route before returning to the station.",
"status": "rejected",
"user_id": 72,
"driver_id": 71
},
"actions": [
{
"action_type": "APPROVE_RTS",
"action_label": "Approve",
"action_payload": {
"reason": "",
"status": "approved",
"user_id": 72,
"driver_id": 71
}
},
{
"action_type": "APPROVE_RTS",
"action_label": "Reject",
"action_payload": {
"reason": "",
"status": "rejected",
"user_id": 72,
"driver_id": 71
}
}
],
"ui_schema": {
"data": {
"id": 14,
"reason": "Undeliverable packages return",
"status": "rts_pending",
"user_id": 72,
"latitude": null,
"driver_id": 71,
"longitude": null,
"driver_name": "Bepara Cham Cham",
"driver_phone": "6513610418",
"last_message": {
"id": 88,
"message": "🚨 RTS Requested\nUndeliverables: 1\nReason: Undeliverable packages return",
"sender_id": 72,
"created_at": "2026-09-17T21:31:39.562047",
"attachments": [],
"sender_name": "Bepara Cham Cham",
"sender_role": "driver",
"attachment_url": null,
"message_content": "🚨 RTS Requested\nUndeliverables: 1\nReason: Undeliverable packages return"
},
"requested_at": "2026-09-17T21:31:39.547998",
"attendance_id": 74,
"location_name": null,
"transporter_id": "AEECFP4SYCEBR",
"has_conversation": true,
"undeliverables_count": 1,
"unread_message_count": 0
},
"badge": "WARNING",
"urgency": "warning",
"severity": "warning",
"driver_id": "71",
"driver_name": "Bepara Cham Cham",
"driver_phone": "6513610418",
"component_type": "RtsActionCard"
},
"status": "pending",
"target_role": "admin",
"target_user_id": null,
"created_by": null,
"expires_in_seconds": null,
"expires_at": null,
"created_at": "2026-09-17T21:31:39.670512Z",
"updated_at": "2026-09-17T21:31:51.554499Z"
},
{
"id": 203,
"event_type": "vehicle_inspection_under_90s",
"severity": "warning",
"urgency": "warning",
"title": "⚠️ Abdullahi Ibrahim completed the vehicle inspection in under 90 seconds",
"description": "Driver Abdullahi Ibrahim rushed the check-out inspection in under 90 seconds, skipping the required 3-minute safety walk-around.",
"ai_diagnosis": "• **Driver:** Abdullahi Ibrahim (📞 6129977147)\n• **Vehicle:** Ram ProMaster (RVK243)\n• **Inspection Type:** Check-Out\n• **Duration Flag:** Completed in <90 seconds (Amazon DVIC required time: ~3 mins)\n• **Suspected Root Cause:** Rushed submission or uploading pre-saved/old photos without conducting a physical vehicle walk-around\n• **Safety & Compliance Risk:** Undetected tire wear, unreported body damages, fluid leaks, or missing safety equipment prior to departure\n• **Operational Recommendation:** Physically verify vehicle condition on departure/return, review uploaded inspection photos for authenticity, and remind driver to conduct a full 3-minute walk-around inspection",
"audio_url": "https://d2m6ddk1wudw4z.cloudfront.net/pilot_audio/4ffba58d-6cd4-4f34-94ad-3fcf1173421c.wav",
"is_actionable": false,
"action_type": null,
"action_label": null,
"action_payload": {},
"actions": [],
"ui_schema": {
"data": {
"id": 175,
"driver_id": 39,
"under_90s": true,
"created_at": "2026-09-17T21:05:46.871944",
"created_by": 1,
"deleted_at": null,
"is_deleted": false,
"updated_at": "2026-09-17T21:05:46.872108",
"updated_by": 1,
"vehicle_id": 10,
"vin_number": "3C6LRVDG5RE114207",
"driver_name": "Abdullahi Ibrahim",
"media_count": 0,
"driver_phone": "6129977147",
"inspected_at": "2026-09-17T16:05:46.871830",
"plate_number": "RVK243",
"vehicle_name": "Ram ProMaster (RVK243)",
"inspection_id": 175,
"daily_roster_id": 4,
"inspection_type": "check_out",
"route_assignment_id": 110,
"driver_transporter_id": "A3OLXHNU1JNDVP"
},
"badge": "WARNING",
"urgency": "warning",
"severity": "warning",
"driver_id": "39",
"vehicle_id": "10",
"driver_name": "Abdullahi Ibrahim",
"driver_phone": "6129977147",
"component_type": "DefaultActionCard"
},
"status": "pending",
"target_role": "admin",
"target_user_id": 40,
"created_by": null,
"expires_in_seconds": null,
"expires_at": null,
"created_at": "2026-09-17T21:05:46.886182Z",
"updated_at": "2026-09-17T21:05:58.849804Z"
},
{
"id": 202,
"event_type": "rts",
"severity": "warning",
"urgency": "warning",
"title": "Martial Nkoudawan Amouzouvi kpongbe is asking to return to station with 7 undelivered packages",
"description": "Driver Martial Nkoudawan Amouzouvi kpongbe has requested a return to station with 7 undelivered packages remaining on their route.",
"ai_diagnosis": "• **Driver:** Martial Nkoudawan Amouzouvi kpongbe (📞 6129977147)\n• **Undelivered Packages:** 7\n• **Return Reason:** Undeliverable packages return\n• **Operational Recommendation:** Since there are still 7 undelivered packages remaining, reject the request and instruct the driver to complete the route.",
"audio_url": "https://d2m6ddk1wudw4z.cloudfront.net/pilot_audio/6f9cfc77-ff23-4097-9f79-d80d538894c6.wav",
"is_actionable": true,
"action_type": "APPROVE_RTS",
"action_label": "Reject",
"action_payload": {
"reason": "Please complete your remaining deliveries on your route before returning to the station.",
"status": "rejected",
"user_id": 144,
"driver_id": 143
},
"actions": [
{
"action_type": "APPROVE_RTS",
"action_label": "Approve",
"action_payload": {
"reason": "",
"status": "approved",
"user_id": 144,
"driver_id": 143
}
},
{
"action_type": "APPROVE_RTS",
"action_label": "Reject",
"action_payload": {
"reason": "",
"status": "rejected",
"user_id": 144,
"driver_id": 143
}
}
],
"ui_schema": {
"data": {
"id": 11,
"reason": "Undeliverable packages return",
"status": "rts_pending",
"user_id": 144,
"latitude": null,
"driver_id": 143,
"longitude": null,
"driver_name": "Martial Nkoudawan Amouzouvi kpongbe",
"driver_phone": "6129977147",
"last_message": {
"id": 84,
"message": "🚨 RTS Requested\nUndeliverables: 7\nReason: Undeliverable packages return",
"sender_id": 144,
"created_at": "2026-09-17T20:54:23.875847",
"attachments": [],
"sender_name": "Martial Nkoudawan Amouzouvi kpongbe",
"sender_role": "driver",
"attachment_url": null,
"message_content": "🚨 RTS Requested\nUndeliverables: 7\nReason: Undeliverable packages return"
},
"requested_at": "2026-09-17T20:54:23.859936",
"attendance_id": 81,
"location_name": null,
"transporter_id": "A1N68BN3ZE0M6P",
"has_conversation": true,
"undeliverables_count": 7,
"unread_message_count": 0
},
"badge": "WARNING",
"urgency": "warning",
"severity": "warning",
"driver_id": "143",
"driver_name": "Martial Nkoudawan Amouzouvi kpongbe",
"driver_phone": "6129977147",
"component_type": "RtsActionCard"
},
"status": "pending",
"target_role": "admin",
"target_user_id": null,
"created_by": null,
"expires_in_seconds": null,
"expires_at": null,
"created_at": "2026-09-17T20:54:23.940444Z",
"updated_at": "2026-09-17T20:54:34.671741Z"
},
{
"id": 201,
"event_type": "rts",
"severity": "warning",
"urgency": "warning",
"title": "Garrett Michael Cropsey is asking to return to station with 3 undelivered packages",
"description": "Garrett Michael Cropsey has requested to return to the station early with 3 undelivered packages remaining.",
"ai_diagnosis": "• **Driver:** Garrett Michael Cropsey (📞 6125923033)\n• **Undelivered Packages:** 3\n• **Return Reason:** Undeliverable packages return\n• **Operational Recommendation:** Reject the RTS request since there are still undelivered packages on the route that need to be completed.",
"audio_url": "https://d2m6ddk1wudw4z.cloudfront.net/pilot_audio/de27bd89-0fdb-44c8-91d3-34df9db43161.wav",
"is_actionable": true,
"action_type": "APPROVE_RTS",
"action_label": "Reject",
"action_payload": {
"reason": "Please complete your remaining deliveries on the route before returning to the station.",
"status": "rejected",
"user_id": 106,
"driver_id": 105
},
"actions": [
{
"action_type": "APPROVE_RTS",
"action_label": "Approve",
"action_payload": {
"reason": "",
"status": "approved",
"user_id": 106,
"driver_id": 105
}
},
{
"action_type": "APPROVE_RTS",
"action_label": "Reject",
"action_payload": {
"reason": "",
"status": "rejected",
"user_id": 106,
"driver_id": 105
}
}
],
"ui_schema": {
"data": {
"id": 10,
"reason": "Undeliverable packages return",
"status": "rts_pending",
"user_id": 106,
"latitude": null,
"driver_id": 105,
"longitude": null,
"driver_name": "Garrett Michael Cropsey",
"driver_phone": "6125923033",
"last_message": {
"id": 83,
"message": "🚨 RTS Requested\nUndeliverables: 3\nReason: Undeliverable packages return",
"sender_id": 106,
"created_at": "2026-09-17T20:52:00.927035",
"attachments": [],
"sender_name": "Garrett Michael Cropsey",
"sender_role": "driver",
"attachment_url": null,
"message_content": "🚨 RTS Requested\nUndeliverables: 3\nReason: Undeliverable packages return"
},
"requested_at": "2026-09-17T20:52:00.911127",
"attendance_id": 88,
"location_name": null,
"transporter_id": "A2KZPMVZTQP37M",
"has_conversation": true,
"undeliverables_count": 3,
"unread_message_count": 0
},
"badge": "WARNING",
"urgency": "warning",
"severity": "warning",
"driver_id": "105",
"driver_name": "Garrett Michael Cropsey",
"driver_phone": "6125923033",
"component_type": "RtsActionCard"
},
"status": "pending",
"target_role": "admin",
"target_user_id": null,
"created_by": null,
"expires_in_seconds": null,
"expires_at": null,
"created_at": "2026-09-17T20:52:01.034866Z",
"updated_at": "2026-09-17T20:52:09.036380Z"
},
];
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('RTS Driver Requests', style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18)),
backgroundColor: Colors.white,
elevation: 0.5,
surfaceTintColor: Colors.transparent,
),
body: ListView.builder(
padding: const EdgeInsets.all(12),
itemCount: _dummyEvents.length,
itemBuilder: (context, index) {
final event = _dummyEvents[index];
return RtsActionCard(
data: event,
isDarkMode: true,
showEdit: false,
onButtonTap: (action) async {
// Simulate async network request
await Future.delayed(const Duration(milliseconds: 1200));
if (!context.mounted) return;
final isApprove = action?.actionLabel.toLowerCase().contains('approve') ?? false;
setState(() {
event['status'] = isApprove ? 'resolved' : 'dismissed';
});
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text('Triggered Action: ${action?.actionPayload} (${action?.actionType})'),
behavior: SnackBarBehavior.floating,
backgroundColor: isApprove
? const Color(0xFF00B074)
: const Color(0xFFEF4444),
),
);
},
);
},
),
);
}
}