Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Want to know the meaning of this operator ?. in dart?

I want to know the meaning of ?. operator in dart , if any one can explain it ? , thank you .
for example :
final length=names?.length;

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

That means that you are accessing a property that may be null. When you declare a variable but never set it, you do this:

String? testString; // the ? operator means that the variable can be null

This was added to prevent your program from crashing by null pointer exceptions.

I suggest you read Michael Horns comment which includes the documentation for null safety in Dart.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading