Skip to main content

pilot_ui 0.0.2 copy "pilot_ui: ^0.0.2" to clipboard
pilot_ui: ^0.0.2 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/pilot_ui.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": 17,
      "event_type": "rts",
      "title": "Driver Aaron Pouncy RTS Request - 50 Undeliverables",
      "description": "Driver Aaron Donald Pouncy (ID: 2) has requested to return to the station early, stating a need to leave earlier. There are currently 50 packages still pending delivery.",
      "severity": "warning",
      "ai_diagnosis": "Driver Aaron Donald Pouncy's request to return to station early due to a personal need to leave earlier is not sufficient given the 50 pending undeliverable packages. The primary objective is to complete deliveries. Recommend rejecting this RTS request and instructing the driver to continue their route.",
      "action_type": "APPROVE_RTS",
      "action_label": "❌ Reject Return to Station",
      "action_payload": {
        "user_id": 3,
        "driver_id": 2,
        "status": "rejected",
        "reason": "The reason provided is not sufficient to justify returning with 50 pending undeliverable packages. Please complete your assigned deliveries."
      },
      "actions": [
        {
          "action_type": "APPROVE_RTS",
          "action_label": "⚡ Approve Return to Station",
          "action_payload": {
            "user_id": 3,
            "driver_id": 2,
            "status": "approved",
            "reason": "Acknowledging personal circumstances. Please ensure all critical deliveries are completed before returning to the station."
          }
        },
        {
          "action_type": "APPROVE_RTS",
          "action_label": "❌ Reject Return to Station",
          "action_payload": {
            "user_id": 3,
            "driver_id": 2,
            "status": "rejected",
            "reason": "The reason provided is not sufficient to justify returning with 50 pending undeliverable packages. Please complete your assigned deliveries."
          }
        }
      ],
      "status": "pending",
      "created_at": "2026-08-28T06:17:51.860860Z"
    },
    {
      "id": 2,
      "event_type": "rts",
      "title": "Driver RTS Request - Aaron Donald Pouncy",
      "description": "Driver Aaron Donald Pouncy (ID: 2) has requested to return to station with 5000 undeliverable items, citing a highly...",
      "severity": "critical",
      "ai_diagnosis": "Driver Aaron Donald Pouncy submitted an RTS request with a concerning reason: 'I am going to sell them...'",
      "status": "resolved",
      "created_at": "2026-08-26T10:33:46.000000Z",
      "actions": []
    },
    {
      "id": 3,
      "event_type": "rts",
      "title": "Critical: Driver RTS Request with Theft Intent",
      "description": "Driver Aaron Donald Pouncy (ID: 2) has requested to return to station after reporting missing packages...",
      "severity": "critical",
      "ai_diagnosis": "High risk flag detected. Intent to sell items declared by driver in reason field.",
      "status": "pending",
      "created_at": "2026-08-26T10:30:40.000000Z",
      "actions": [
        {
          "action_type": "APPROVE_RTS",
          "action_label": "⚡ Approve Return to Station",
          "action_payload": {"status": "approved"}
        },
        {
          "action_type": "REJECT_RTS",
          "action_label": "❌ Reject",
          "action_payload": {"status": "rejected"}
        }
      ]
    },
    {
      "id": 4,
      "event_type": "rts",
      "title": "Dismissed: Package Access Warning",
      "description": "Driver Aaron Donald Pouncy (ID: 2) flagged access code expired for gate 4B.",
      "severity": "warning",
      "ai_diagnosis": "Gate access issue manually handled and resolved via dispatch phone call.",
      "status": "dismissed",
      "created_at": "2026-08-26T10:15:10.000000Z",
      "actions": []
    },
    {
      "id": 5,
      "event_type": "rts",
      "title": "Routine Route Telemetry Update",
      "description": "Telemetry feed indicates driver has completed 80% of route on schedule.",
      "severity": "info",
      "ai_diagnosis": "No anomalies detected. Pace aligns with expected ETA windows.",
      "status": "informational",
      "created_at": "2026-08-26T10:00:00.000000Z",
      "actions": []
    }
  ];

  @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,
            onButtonTap: (action) {
              ScaffoldMessenger.of(context).showSnackBar(
                SnackBar(
                  content: Text('Triggered Action: ${action.actionPayload} (${action.actionType})'),
                  behavior: SnackBarBehavior.floating,
                  backgroundColor: action.actionLabel.contains('Approve')
                      ? const Color(0xFF00B074)
                      : const Color(0xFFEF4444),
                ),
              );
            },
          );
        },
      ),
    );
  }
}
1
likes
0
points
533
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