Seems to be a good solution. Not sure about null safety.