Infinite loop fixed in Dart class hierarchy