---
title: Use the is! operator instead of negating is
description: Datadog, the leading service for cloud-scale monitoring.
breadcrumbs: >-
  Docs > Datadog Security > Code Security > Static Code Analysis (SAST) > SAST
  Rules > Use the is! operator instead of negating is
---

> For the complete documentation index, see [llms.txt](https://docs.datadoghq.com/llms.txt).

# Use the is! operator instead of negating is

{% callout %}
# Important note for users on the following Datadog sites: app.ddog-gov.com, us2.ddog-gov.com

{% alert level="danger" %}
This product is not supported for your selected [Datadog site](https://docs.datadoghq.com/getting_started/site.md). ({% placeholder "user-datadog-site-name" /%}).
{% /alert %}

{% /callout %}

## Metadata{% #metadata %}

**ID:** `dart-code-quality/prefer-is-not-operator`

**Language:** Dart

**Severity:** Notice

**Category:** Code Style

## Description{% #description %}

Negating a type test with !(x is T) is harder to read than the dedicated x is! T operator. Prefer the is! operator, which expresses the negated type check directly and improves readability.

## Non-Compliant Code Examples{% #non-compliant-code-examples %}

```dart
void main() {
  var x = 'a';
  var value = 1;
  if (!(x is String)) {}
  var b = !(value is int);
}
```

## Compliant Code Examples{% #compliant-code-examples %}

```dart
void main() {
  var x = 'a';
  var a = 1;
  var b = 2;
  var flag = true;

  if (x is! String) {}
  if (x is String) {}
  if (!(a == b)) {}
  if (!flag) {}
}
```
  Seamless integrations. Try Datadog Code SecurityDatadog Code Security 
{% icon name="icon-external-link" /%}
 