-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Add a TODO function that can be assigned to all types. #60582
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
There are IDE extensions floating around to make custom TODO patterns. You could flag |
I'm pretty sure they know about that already. |
We could also add optional parameters like |
@rrousselGit Thank you for pointing out the IDE extensions; I'll look into them. However, I would still very much prefer this function to be in the standard Dart SDK, because now I have to ensure that every developer in the project is using it. Also, another problem that occurs now is that if this function is used, currently, the Dart compiler/linter marks everything after that as unreachable, which it is, but it shouldn't be marked like that if it is a TODO. To continue on @FMorschel, I think it would be a good idea indeed to add everything in the flutter_style_todos in the future. This would include:
But even without the username and issue URL, having this function in Dart would still be incredibly pleasant. I think we should first focus on having that inside Dart before we talk about adding Flutter-specific functionality. Because if we take the flutter_style_todos into account, the function signature needs to change depending on whether the |
I'd like to disagree here. We can make this lint trigger here if the TODO invocation doesn't have all of the required parameters. |
It's not so much a function that can be assigned to any type, but one whose return type can be used in any context. Even if the version of a Another option would be: @Deprecated("Implement this")
// ignore: non_constant_identifier_names
R TODO<R>([String? message = "TODO"]) {
throw UnimplementedError(message);
} This function should adapt its return type to the context's expectation, and the I don't know if this is a pattern that we'll want to endorse to the point where we add it to the platform libraries. It's sort-of nice, but I'd probably just write (Or use The case of "TODO" is obviously not lower-camel-case. Since it's intended to stand out, that could be argued to be working as intended. It could also be |
Sounds like a function that Flutter should be adding to their platform libraries, not one belonging on the Dart SDK, which does not have any recommendations for todos. If the Flutter recommendations for TODOs change, they would be in a position to update the function. On the other hand, if Flutter wants a different |
It would be great to be able to pass a todo() function as an argument to make the compiler happy while you're testing/working on something else.
Kotlin already has such a function.
I've created my own function that does this, but since it is not native, it is not integrated with any IDE features concerning the TODO's in code.
I don't have a strong opinion on whether the reason should be optional or mandatory, but I would prefer the mandatory variant.
Usage
I hope this can be implemented!
The text was updated successfully, but these errors were encountered: