Dart : Null


Dart provide many unique function compare to other language , therefore dart is popular language among the developer.
One of the unique function of dart in Unsafety, which means dart also support the Null value in variable.
Null safety make code safer and run faster.
in null safety we use two symbol " ? ! " .
Where " ? " indicate that we can assign the variable to null.
Here, I am providing the example of Null safety.
void main() { int? x; print(x); // null }
void main() { int? x; print(x); int y =x!; }
- In this we get the error like " Null check operator used on a null value " due to here x is nullable type where is notnullable type but we force to run this program by putting " ! ".
Subscribe to my newsletter
Read articles from Vinit Mepani directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Vinit Mepani
Vinit Mepani
"Hello World, I'm Vinit Mepani, a coding virtuoso driven by passion, fueled by curiosity, and always poised to conquer challenges. Picture me as a digital explorer, navigating through the vast realms of code, forever in pursuit of innovation. In the enchanting kingdom of algorithms and syntax, I wield my keyboard as a magical wand, casting spells of logic and crafting solutions to digital enigmas. With each line of code, I embark on an odyssey of learning, embracing the ever-evolving landscape of technology. Eager to decode the secrets of the programming universe, I see challenges not as obstacles but as thrilling quests, opportunities to push boundaries and uncover new dimensions in the realm of possibilities. In this symphony of zeros and ones, I am Vinit Mepani, a coder by passion, an adventurer in the digital wilderness, and a seeker of knowledge in the enchanting world of code. Join me on this quest, and let's create digital wonders together!"