Mastersam07 / Mastersam07/kaisel
feat: allow KaiselRoute to be implemented, so data-less route families can be enums
Nobody has claimed this yet.
- Dominant language
- Dart
- Stars
- 69
- Forks
- 2
- Avg merge
- 18m
- Merged PRs (30d)
- 9
Description
`KaiselRoute` is an `abstract class` with a const constructor, so every route must `extend` it. A sealed family whose variants carry no data is exactly an enum — but a Dart enum cannot `extend` a class, only `implement` interfaces and apply mixins.
```dart
// what you want
enum SettingsTab implements KaiselRoute { profile, security, about }
// what you must write
sealed class SettingsRoute extends KaiselRoute { const SettingsRoute._(); }
final class Profile extends SettingsRoute { const Profile() : super._(); }
final class Security extends SettingsRoute { const Security() : super._(); }
final class About extends SettingsRoute { const About() : super._(); }
```
## Scale
In one 371-route app, **11 of 41** route families had no data on any variant. Those are pure enums expressed as sealed hierarchies — more code, and a lint (`prefer_enum_over_sealed_class` in that projects house rules) firing on each, requiring an ignore comment per file with an explanation of why the advice is impossible to follow.
## Suggestion
Make `KaiselRoute` implementable — an `abstract interface class`, or a mixin providing `props` / `routeName` defaults — so `enum Tab implements KaiselRoute { ... }` is legal.
The pieces look compatible: `props` and `routeName` are both instance members with defaults, and enums can override both. The blocker is only the const constructor implied by `extends`.
Worth noting a workaround that is arguably better anyway, and could be documented either way: carry the enum as a field on a single route class.
```dart
final class Tab extends KaiselRoute {
const Tab(this.value);
final TabValue value;
@override
List get props => [value];
}
```
Exhaustiveness then comes from switching on the enum rather than the sealed type, which is equivalent for the builder.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the KaiselRoute declaration and inspect how its props, routeName, and const-constructor requirements are used by route implementations. Check the existing test suite before evaluating whether enums can implement the route contract without breaking sealed route families. Done means the requested enum form is supported or the documented single-route-class workaround is clearly established, with existing routing behavior preserved.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart, flutter
- Domain
- mobile
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100