isValid method

  1. @override
bool isValid(
  1. ImageInput input
)
override

Returns the input is support or not.

Implementation

@override
bool isValid(ImageInput input) {
  final length = input.length;

  for (final header in headerAndFooter.mutipleStartBytesList) {
    for (final footer in headerAndFooter.mutipleEndBytesList) {
      final fileHeader = input.getRange(
        0,
        header.length,
      );
      final fileFooter = input.getRange(
        length - footer.length,
        length,
      );

      final headerEquals = compareTwoList(
        header,
        fileHeader,
      );
      final footerEquals = compareTwoList(
        footer,
        fileFooter,
      );
      if (headerEquals && footerEquals) {
        return true;
      }
    }
  }

  return false;
}