dart-lang / dart-lang/language

Some improvements picked up from Kotlin language

Open
#1,408 4 comments 7 reactions 0 assignees View on GitHub
feature
Dominant language
TeX
Stars
2.9k
Forks
239
Avg merge
2d 18h
Merged PRs (30d)
14

Description

I'm currently migrating a music app from native Android (using Kotlin) to Flutter, and here are a few improvements that could be done:

- using the `switch` command without `break`, as it is done in Kotlin with the `when` command. The reason why it's very useful is that the `break` could lead to bugs that are very hard to find if you forget it (happened to me a few times and I struggled a lot):
```Dart
switch(myVariable)
1 -> doOneLineCommand()
2 -> {
doMultipleLineCommand()
doSomethingElseAndSoOn()
}
3, 4, 5 -> doSomethingForThoseMultipleCases()
default -> defaultCommand()
```
- using the `for` command as it is done in Kotlin. Again, repeating the variable name in the `for` command can lead to bugs if you copy/paste some code and you forget to rename the variable everywhere for example (happened again once):
```Dart
for (a in 1..10) {...}
for (a in 1..10 step 2) {...}
for (a in start until end step 3) {...}
for (a in start downTo end step 4) {...}
// and so on...
```
- also, just like Kotlin, can we get rid once for all of the `;` in the end of each line? That would be great!

Thanks.

Contributor guide

Open the contributing guide

Research direction

No files, tests, or entry points are identified. Start by reviewing the three proposed Dart language changes and their Kotlin examples; the work is complete only when the project decides whether these proposals should be pursued and defines their scope.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart, kotlin
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.