Flutter Null Safety Unit Tests: Late for Tests

Dart added the late keyword as part of their null safety release and it is very useful, particularly for testing. As a quick review null safety means telling the compiler that some variables will never be null. Any variable declared without a question mark following the type declaration is null safe. So String name is null safe while String? name can be null. Given that the question mark is new syntax all code written before null safety was introduced now declares all variables as cannot be null. The new late keyword tells the compiler that although a variable is not [Read on…]

GO Obsolete Dependencies

This article refers to problems that would probably only be seen for those running older versions of GO. If you know all about module management and are running up to date versions of GO with modules then you probably won’t find anything useful here. Up until very recently I was running a pre-module GO version and that bit me. If like me, you haven’t made the switch to modules and some of your dependencies appear to be missing functionality that you’re sure is there, read on. Signs of Trouble It all started with a fairly innocuous error message from the [Read on…]

Null Safety firstWhere

The change to null safety in Dart is a good thing, however a common pattern I used firstWhere for got broken. The pattern is to search a collection and return null if the search returns nothing. The short answer is that you should use firstWhereOrNull instead in this case. Example of the Issue Before the null safe version of Dart the code would look like this: The naive conversion to null safety would be: But this conversion will show a warning that the test if ( null == val ) is not required because the value can’t be null. What’s [Read on…]