extract method

  1. @override
UICDetails? extract(
  1. String? input
)
override

Extracts an UIC number from input and splits it up into its UICDetails Returns null if input is null or if the resulting UIC number is invalid. Extracts details for 12-digit UIC numbers, otherwise UICDetails.descriptions is empty.

Implementation

@override
UICDetails? extract(String? input) {
  if (input == null) return null;
  final uic = _extractUICFromString(input);
  if (uic == null || uic.isEmpty) return null;

  final uicCategory = _uicDetailsService.determineCategory(uic);
  final uicType = _uicDetailsService.determineType(uic);
  final List<UICDescription> values =
      uicCategory != null ? _uicDetailsService.extractUICValues(uic, uicCategory) : [];

  return UICDetails(
    uicNumber: _uicDetailsService.formatUIC(
      uic,
      category: uicCategory,
      type: uicType,
    ),
    uicType: uicType,
    descriptions: values,
    uicCategory: uicCategory,
  );
}