isUniqueConstraintError method

bool isUniqueConstraintError([
  1. String? field
])

True if the exception is a unique constraint error

Implementation

bool isUniqueConstraintError([String? field]) {
  if (_message != null) {
    var expected = 'UNIQUE constraint failed: ';
    if (field != null) {
      expected += field;
    }
    return _message.toLowerCase().contains(expected.toLowerCase());
  }
  return false;
}