Code simplified since Dart Issue 3197 is fixed.