build method

  1. @override
Widget build(
  1. BuildContext context
)
override

//////////// ////////////

Implementation

// III.C - Build Method
///////////////
@override
Widget build(BuildContext context) {
  debugPrint("[DEBUG] SpeedLimitBadge build called with speedLimit: $speedLimit at ${DateTime.now()}");

  if (speedLimit == null) {
    debugPrint("[DEBUG] SpeedLimitBadge - No speed limit available, not displaying badge");
    return const SizedBox.shrink();
  }

  // Format speed with appropriate units
  final String formattedSpeed = FormatUtils.formatSpeed(
    speedLimit!,
    useImperialUnits: useImperialUnits,
  );

  debugPrint("[DEBUG] SpeedLimitBadge - Displaying speed limit: $formattedSpeed ${useImperialUnits ? 'mph' : 'km/h'}");

  // Create redesigned speed limit UI: black 3px border, rounded corners (but not fully circular)
  // Following real-world speed sign design standards
  return Container(
    width: 45, // Slightly larger than before
    height: 36,
    decoration: BoxDecoration(
      color: Colors.white,
      borderRadius: BorderRadius.circular(8), // Rounded rectangular shape like real signs
      border: Border.all(color: Colors.black, width: 3), // Black 3px border as requested in requirements
      boxShadow: [RALIElevations.card[0]],
    ),
    child: Center(
      child: Text(
        formattedSpeed,
        style: RALITypography.titleSmall.copyWith(
          fontWeight: FontWeight.bold,
        ),
      ),
    ),
  );
}