Language: [NNBD] Provide a way to check if a type is nullable

Created on 13 Oct 2020  路  1Comment  路  Source: dart-lang/language

I'm not sure if this currently exist but I didn't found anything by looking at the docs. Also not sure if here is the right place for this proposal!

In Kotlin we are able to check whether a type is nullable or not.
Wondering if currently there is a way of doing that and if not we can consider this as a proposal.

In Kotlin we can achieve this by using reflections:
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.reflect/-k-type/is-marked-nullable.html

We can have TypeMirror.isNullable or isMarkedNullable which is true if the type was declared with a question mark (nullable) or false otherwise.

feature

Most helpful comment

If I understand correctly, you're asking about reflective support in dart:mirrors for nullable types? Note that for non-reflective uses null is T works for this.

>All comments

If I understand correctly, you're asking about reflective support in dart:mirrors for nullable types? Note that for non-reflective uses null is T works for this.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

moneer-muntazah picture moneer-muntazah  路  3Comments

panthe picture panthe  路  4Comments

eernstg picture eernstg  路  5Comments

leonsenft picture leonsenft  路  4Comments

mit-mit picture mit-mit  路  3Comments