Skip to main content

pilot_ui 0.0.9 copy "pilot_ui: ^0.0.9" to clipboard
pilot_ui: ^0.0.9 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": 15,
      "action_label": null,
      "ui_schema": {
        "badge": "INFO",
        "category": "GENERAL_ALERT"
      },
      "event_type": "manual_alert",
      "action_payload": null,
      "severity": "info",
      "target_role": "admin",
      "title": "🌊 Wave 1 Pre-Launch Standup Ready",
      "target_user_id": null,
      "resolved_by": null,
      "is_deleted": false,
      "updated_by": null,
      "description": "All 24 drivers have completed attendance precheck. Pad staging is ready for morning standup.",
      "deleted_at": null,
      "created_by": 1,
      "ai_diagnosis": "• **Notice:** 🌊 Wave 1 Pre-Launch Standup Ready\n• **Details:** All 24 drivers have completed attendance precheck. Pad staging is ready for morning standup.",
      "status": "pending",
      "created_at": "2026-09-11T08:31:01.767918",
      "is_actionable": false,
      "expires_at": "2026-09-11T09:05:41.767783",
      "updated_at": "2026-09-11T08:31:01.767928",
      "action_type": null,
      "actions": null,
      "resolved_at": null,
      "expires_in_seconds": 600
    },
    {
      "id": 13,
      "action_label": null,
      "ui_schema": {
        "data": {
          "driver_id": 1,
          "under_90s": true,
          "vehicle_id": 1,
          "driver_name": "Test Driver",
          "media_count": 4,
          "vehicle_vin": "1FTNE3Y89PK12345",
          "vehicle_name": "Van #12",
          "inspection_id": 99,
          "daily_roster_id": 1,
          "inspection_type": "check_in",
          "duration_seconds": 42,
          "route_assignment_id": 1
        },
        "component_type": "DefaultActionCard"
      },
      "event_type": "vehicle_inspection",
      "action_payload": null,
      "severity": "warning",
      "target_role": "admin",
      "title": "⚠️ Rushed Vehicle Inspection (<90s): Van #12 (Test Driver)",
      "target_user_id": null,
      "resolved_by": null,
      "is_deleted": false,
      "updated_by": null,
      "description": "Test Driver completed the check-in inspection for Van #12 in just 42 seconds, raising concerns that critical safety checks may have been skipped.",
      "deleted_at": null,
      "created_by": null,
      "ai_diagnosis": "• **Driver:** Test Driver\n• **Vehicle:** Van #12\n• **Inspection Type:** Check-In\n• **Duration Flag:** Completed in under 90 seconds (Amazon DVIC Fast Inspection Warning)\n• **Safety & Operational Risk:** Critical vehicle defects, tire pressure issues, or body damages may have been missed during this extremely rapid 42-second check.\n• **Operational Recommendation:** Flag the vehicle for a secondary spot-check and remind the driver to prioritize thorough safety protocols over speed.",
      "status": "pending",
      "created_at": "2026-09-11T08:27:42.530881",
      "is_actionable": false,
      "expires_at": null,
      "updated_at": "2026-09-11T08:27:42.531006",
      "action_type": null,
      "actions": null,
      "resolved_at": null,
      "expires_in_seconds": null
    },
    {
      "id": 7,
      "action_label": "Message Driver",
      "ui_schema": {
        "badge": "CRITICAL",
        "category": "DRIVER_SAFETY",
        "entities": {
          "location": "Route CX-104",
          "route_code": "CX-104",
          "driver_name": "Marcus Vance",
          "vehicle_label": "Van #45"
        }
      },
      "event_type": "driver_safety",
      "action_payload": {
        "message": "URGENT SAFETY ALERT: Mobile phone use detected. Pull over safely immediately.",
        "route_code": "CX-104",
        "driver_name": "Marcus Vance"
      },
      "severity": "critical",
      "target_role": "admin",
      "title": "Critical Safety Alert: Mobile Phone Distraction - Van #45",
      "target_user_id": null,
      "resolved_by": null,
      "is_deleted": false,
      "updated_by": null,
      "description": "Netradyne ADAS system detected active mobile phone usage by driver Marcus Vance while operating Van #45 at 28mph on Route CX-104, creating an immediate safety risk.",
      "deleted_at": null,
      "created_by": 1,
      "ai_diagnosis": "• **Driver:** Marcus Vance\n• **Vehicle / Location:** Van #45 / Route CX-104 (28mph)\n• **Root Cause:** Active mobile phone distraction captured by Netradyne AI camera.\n• **Operational Impact & SLA Risk:** Severe safety compliance risk with immediate potential for collision.\n• **Operational Recommendation:** Immediately contact the driver via dispatch chat to halt phone usage and ensure safe vehicle operation.",
      "status": "pending",
      "created_at": "2026-09-11T07:53:03.425697",
      "is_actionable": true,
      "expires_at": null,
      "updated_at": "2026-09-11T07:53:03.425710",
      "action_type": "SEND_CHAT",
      "actions": [
        {
          "action_type": "SEND_CHAT",
          "action_label": "Message Driver",
          "action_payload": {
            "message": "URGENT SAFETY ALERT: Mobile phone use detected. Pull over safely immediately.",
            "route_code": "CX-104",
            "driver_name": "Marcus Vance"
          }
        },
        {
          "action_type": "ACKNOWLEDGE",
          "action_label": "Acknowledge Alert",
          "action_payload": {
            "incident_id": "NET-CX104-45"
          }
        }
      ],
      "resolved_at": null,
      "expires_in_seconds": null
    },
    {
      "id": 3,
      "action_label": null,
      "ui_schema": {
        "data": {
          "id": 71,
          "title": "Hard braking",
          "severity": "Severe",
          "driver_id": 1,
          "alert_type": "Hard braking",
          "route_code": "CX-104",
          "vehicle_id": null,
          "description": "Traffic Light sudden stop",
          "driver_name": "Test Driver",
          "vehicle_name": "Van #45"
        },
        "component_type": "DefaultActionCard"
      },
      "event_type": "route_alert",
      "action_payload": null,
      "severity": "critical",
      "target_role": "admin",
      "title": "🚨 Netradyne Alert: Hard braking - Van #45 (Test Driver)",
      "target_user_id": null,
      "resolved_by": null,
      "is_deleted": false,
      "updated_by": null,
      "description": "Test Driver recorded a severe hard braking event on route CX-104 while operating Van #45. Immediate safety review and driver check-in is required.",
      "deleted_at": null,
      "created_by": null,
      "ai_diagnosis": "• **Driver:** Test Driver\n• **Vehicle / Route:** Van #45 / Route CX-104\n• **Violation / Event Type:** Hard braking (Traffic Light sudden stop)\n• **Safety & Operational Risk:** High risk of rear-end collision, negative impact on safety scorecard, and potential cargo shift.\n• **Operational Recommendation:** Contact driver immediately to verify status and schedule mandatory post-shift coaching.",
      "status": "pending",
      "created_at": "2026-09-11T07:14:53.364955",
      "is_actionable": false,
      "expires_at": null,
      "updated_at": "2026-09-11T07:14:53.365084",
      "action_type": null,
      "actions": null,
      "resolved_at": null,
      "expires_in_seconds": null
    },
    {
      "id": 2,
      "action_label": "Message Driver",
      "ui_schema": {
        "badge": "CRITICAL",
        "category": "DRIVER_SAFETY",
        "entities": {
          "location": "20mph residential zone",
          "route_code": "TX-204",
          "driver_name": null,
          "vehicle_label": "Van #18"
        }
      },
      "event_type": "driver_safety",
      "action_payload": {
        "driver": "Unassigned",
        "message": "Safety alert: Please pull over immediately and cease mobile phone usage. Adhere to speed limits.",
        "vehicle": "Van #18"
      },
      "severity": "critical",
      "target_role": "admin",
      "title": "Critical Safety Violation: Distracted Driving & Speeding on Route TX-204",
      "target_user_id": null,
      "resolved_by": null,
      "is_deleted": false,
      "updated_by": null,
      "description": "Netradyne detected mobile phone usage while driving 32 mph in a 20 mph residential zone. Immediate dispatcher intervention is required to address this severe safety risk.",
      "deleted_at": null,
      "created_by": 1,
      "ai_diagnosis": "• **Driver:** Unassigned\n• **Vehicle / Location:** Van #18 / Route TX-204 (20mph residential zone)\n• **Root Cause:** Active mobile phone distraction combined with severe speeding infraction.\n• **Operational Impact & SLA Risk:** High safety liability and potential regulatory violation, increasing accident risk and compromising route compliance.\n• **Operational Recommendation:** Immediately message the driver to pull over safely and cease mobile usage, followed by a mandatory post-shift coaching session.",
      "status": "pending",
      "created_at": "2026-09-11T06:29:53.260427",
      "is_actionable": true,
      "expires_at": null,
      "updated_at": "2026-09-11T06:29:53.260444",
      "action_type": "SEND_CHAT",
      "actions": [
        {
          "action_type": "SEND_CHAT",
          "action_label": "Message Driver",
          "action_payload": {
            "message": "Safety alert: Please pull over immediately and cease mobile phone usage. Adhere to speed limits.",
            "vehicle": "Van #18"
          }
        },
        {
          "action_type": "ACKNOWLEDGE",
          "action_label": "Acknowledge Alert",
          "action_payload": {
            "alert_id": "NETRADYNE-TX-204-18"
          }
        }
      ],
      "resolved_at": null,
      "expires_in_seconds": null
    },
    {
      "id": 1,
      "action_label": "Message Driver",
      "ui_schema": {
        "badge": "CRITICAL",
        "category": "DRIVER_SAFETY",
        "entities": {
          "location": "Route CX-104",
          "route_code": "CX-104",
          "vehicle_label": "Van #12"
        }
      },
      "event_type": "driver_safety",
      "action_payload": {
        "message": "URGENT: Safety violation detected (distraction & speeding). Pull over immediately and contact dispatch.",
        "route_code": "CX-104",
        "vehicle_label": "Van #12"
      },
      "severity": "critical",
      "target_role": "admin",
      "title": "Critical Safety Violation: Distracted Driving & Speeding on Route CX-104",
      "target_user_id": null,
      "resolved_by": null,
      "is_deleted": false,
      "updated_by": null,
      "description": "Netradyne detected severe mobile phone distraction and a stop sign violation on Route CX-104, traveling 24mph in a 15mph zone.",
      "deleted_at": null,
      "created_by": 1,
      "ai_diagnosis": "• **Driver:** Unassigned\n• **Vehicle / Location:** Van #12 / Route CX-104\n• **Root Cause:** Mobile phone distraction leading to failure to stop and excessive speeding (24mph in a 15mph zone).\n• **Operational Impact & SLA Risk:** Extreme safety hazard and high liability risk requiring immediate intervention.\n• **Operational Recommendation:** Immediately contact the driver via chat to halt unsafe practices and consider route reassignment if compliance is not met.",
      "status": "pending",
      "created_at": "2026-09-11T06:28:12.366765",
      "is_actionable": true,
      "expires_at": null,
      "updated_at": "2026-09-11T06:28:12.366777",
      "action_type": "SEND_CHAT",
      "actions": [
        {
          "action_type": "SEND_CHAT",
          "action_label": "Message Driver",
          "action_payload": {
            "message": "URGENT: Safety violation detected (distraction & speeding). Pull over immediately and contact dispatch.",
            "route_code": "CX-104",
            "vehicle_label": "Van #12"
          }
        },
        {
          "action_type": "REASSIGN_ROUTE",
          "action_label": "Reassign Route",
          "action_payload": {
            "reason": "Severe safety infraction",
            "route_code": "CX-104"
          }
        },
        {
          "action_type": "ACKNOWLEDGE",
          "action_label": "Acknowledge Alert",
          "action_payload": {
            "incident": "Netradyne Safety Alert CX-104"
          }
        }
      ],
      "resolved_at": null,
      "expires_in_seconds": null
    }
  ];

  @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,
            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),
                ),
              );
            },
          );
        },
      ),
    );
  }
}
1
likes
0
points
477
downloads

Publisher

unverified uploader

Weekly Downloads

A dynamic, theme-aware JSON UI rendering engine for Flutter with extensible parsers, action handlers, and ready-to-use smart dispatch & RTS action components.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

cached_network_image, flutter

More

Packages that depend on pilot_ui