Posts

Showing posts from August, 2021

Nullable types Version change example - isEmpty

 As you work with Dart, you may find that minor things stop working. For example: stdout . write ( 'Enter your name : ' );   String ? str1 = stdin . readLineSync ();   str1 . isEmpty ? stderr . write ( 'Name is empty!!' ) : stdout . write ( 'Good Morning $str1' );   Error : Property 'isEmpty' cannot be accessed on 'String?' because it is potentially null .   Try accessing using ?. instead .   str1 . isEmpty Dart is both great and irritating because of this... Dart is rapidly evolving, and each new version introduces a slew of minor changes that might damage your code. Depending on the version of Dart you're running, you may never run across this problem or it may appear at any time. Always check your version's online Dart documentation, as well as the updated Github code attached to each lesson. This specific example is a change to NullSafety: https://dart.dev/null-safety/understanding-null-safety https://stackoverflow.com/qu