Port from Java to Dart, first version.