unwrapFuture function

String unwrapFuture(
  1. String input
)

Implementation

String unwrapFuture(String input) {
  // Explanation:
  // ^Future<  : Must start with "Future<"
  // (.*)      : Greedy match - captures everything until the LAST ">"
  // >$        : Must end with ">"
  final regex = RegExp(r"^Future<(.*)>$");
  final match = regex.firstMatch(input.trim());

  if (match != null) {
    // This will now correctly return "List<Pet>?"
    return match.group(1)!;
  }
  return input;
}