Dart is null safe so you can't have a function that sometimes returns a nullable but sometimes a non-nullable.