Question for Practice 7
Question For Practice 7
- What is the purpose of the ? operator in Dart null safety?
- Create a late variable named address, assign a US value to it and print it.
- How do you declare a nullable type in Dart null safety?
- Write a program in a dart to create an age variable and assign a null value to it using ?.
- Write a function that accepts a nullable int parameter and returns 0 if the value is null using null coalescing operator ??.
- Write a function named generateRandom() in dart that randomly returns 100 or null. Also, assign a return value of the function to a variable named status that can’t be null. Give status a default value of 0, if generateRandom() function returns null.