# Nullability in Dart | raywenderlich.com

**URL:** <https://forums.kodeco.com/t/nullability-in-dart-raywenderlich-com/96903>\
**Category:** 🎓 Courses & Articles\
**Created:** [February 4, 2020, 7:34am UTC](https://forums.kodeco.com/t/nullability-in-dart-raywenderlich-com/96903 "2020-02-04T07:34:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![macsimus](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/macsimus/32/109104_2.png) [@macsimus](https://forums.kodeco.com/u/macsimus)\
**Post date:** [February 4, 2020, 7:34am UTC](https://forums.kodeco.com/t/nullability-in-dart-raywenderlich-com/96903/1 "2020-02-04T07:34:07Z")

</div>

* * *
This is a companion discussion topic for the original entry at [https://www.raywenderlich.com/4921688-programming-in-dart-fundamentals/lessons/8](https://www.raywenderlich.com/4921688-programming-in-dart-fundamentals/lessons/8)

---

<div class="post-metadata">

**Author:** ![robmoorekinduct](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/robmoorekinduct/32/81494_2.png) [@robmoorekinduct](https://forums.kodeco.com/u/robmoorekinduct)\
**Post date:** [July 14, 2021, 8:39am UTC](https://forums.kodeco.com/t/nullability-in-dart-raywenderlich-com/96903/2 "2021-07-14T08:39:04Z")

</div>

Looks like it is not the case anymore in dart.  
Declaring the variable without initializing like this leads to compilation error:

```auto
  int age;
  print(age);

```

```auto
Error: Non-nullable variable 'age' must be assigned before it can be used.
  print(age);
        ^^^
Error: Compilation failed.

```

though this work:

`int? age;`

---

<div class="post-metadata">

**Author:** ![ulugo](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/ulugo/32/81494_2.png) [@ulugo](https://forums.kodeco.com/u/ulugo)\
**Post date:** [July 26, 2021, 1:11am UTC](https://forums.kodeco.com/t/nullability-in-dart-raywenderlich-com/96903/3 "2021-07-26T01:11:47Z")

</div>

Hi @robmoorekinduct, thank you.

Same here, I’m running: Dart SDK version: 2.13.4 (stable).

The official documentation has an explanation for this, but, for some reason if I try to add the link here, my post got hidden.

So, you can google it as: dart nullable int

Bye!

---

<div class="post-metadata">

**Author:** ![holdenhinkle](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/holdenhinkle/32/102075_2.png) [@holdenhinkle](https://forums.kodeco.com/u/holdenhinkle)\
**Post date:** [March 14, 2022, 7:28pm UTC](https://forums.kodeco.com/t/nullability-in-dart-raywenderlich-com/96903/4 "2022-03-14T19:28:36Z")

</div>

This doesn’t work:

```auto
void main() {
  String err;
  var error = err ?? "This is an error";
  print(error);
}

```

```auto
test.dart:3:15: Warning: Operand of null-aware operation '??' has type 'String' which excludes null.
  var error = err ?? "This is an error";
              ^
test.dart:3:15: Error: Non-nullable variable 'err' must be assigned before it can be used.
  var error = err ?? "This is an error";

```
