qrerrors.dart 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * QR.Flutter
  3. * Copyright (c) 2019 the QR.Flutter authors.
  4. * See LICENSE for distribution and usage details.
  5. */
  6. import 'package:flutter/widgets.dart';
  7. import 'package:flyinsonolite/controls/qrcode/qrversions.dart';
  8. /// An exception that is thrown when an invalid QR code version / type is
  9. /// requested.
  10. class QrUnsupportedVersionException implements Exception {
  11. /// Create a new QrUnsupportedVersionException.
  12. factory QrUnsupportedVersionException(int providedVersion) {
  13. final message =
  14. 'Invalid version. $providedVersion is not >= ${QrVersions.min} '
  15. 'and <= ${QrVersions.max}';
  16. return QrUnsupportedVersionException._internal(providedVersion, message);
  17. }
  18. QrUnsupportedVersionException._internal(this.providedVersion, this.message);
  19. /// The version you passed to the QR code operation.
  20. final int providedVersion;
  21. /// A message describing the exception state.
  22. final String message;
  23. @override
  24. String toString() => 'QrUnsupportedVersionException: $message';
  25. }
  26. /// An exception that is thrown when something goes wrong with the
  27. /// [ImageProvider] for the embedded image of a QrImageView or QrPainter.
  28. class QrEmbeddedImageException implements Exception {
  29. /// Create a new QrEmbeddedImageException.
  30. factory QrEmbeddedImageException(String message) {
  31. return QrEmbeddedImageException._internal(message);
  32. }
  33. QrEmbeddedImageException._internal(this.message);
  34. /// A message describing the exception state.
  35. final String message;
  36. @override
  37. String toString() => 'QrEmbeddedImageException: $message';
  38. }