Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions site/src/content/docs/concepts.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ final class Product extends AppRoute {
}
```

:::tip[On Dart 3.13 or later?]
Primary constructors shrink a variant to its header:
`final class const Home() extends AppRoute;`. See
[Getting started](/getting-started/) for the full form.
:::

Two consequences fall out immediately. Routes have **equality**
(`Product('42') == Product('42')`), so the router can diff, dedupe, and
restore them. And routes are **exhaustively matchable** — a `switch` over
Expand Down
19 changes: 18 additions & 1 deletion site/src/content/docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ your screens are an exhaustive `switch`, and the navigation stack is a plain
flutter pub add kaisel
```

kaisel supports Flutter 3.24+ and requires Dart 3.
kaisel requires Dart 3.10 or later, which ships with Flutter 3.38.

## 1. Declare your route type

Expand All @@ -36,6 +36,23 @@ final class ProductDetail extends AppRoute {
No-field variants get equality automatically (`Home() == Home()`). Variants
with fields override `props`.

:::tip[On Dart 3.13 or later?]
Primary constructors fold the constructor and its fields into the class
header. If your package's SDK constraint is `^3.13.0` or higher, the same
routes can read:

```dart
final class const Home() extends AppRoute;

final class const ProductDetail(final String id) extends AppRoute {
@override
List<Object?> get props => [id];
}
```

kaisel needs nothing extra for this. Equality still comes from `props`.
:::

## 2. Wire it up

Bundle the router into a `KaiselRouterConfig` and hand it to
Expand Down
22 changes: 22 additions & 0 deletions skills/kaisel/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,28 @@ final class ProductDetail extends AppRoute {
unequal and the stack will treat them as distinct entries.
- Sealed type at the root. Pattern matching downstream depends on
exhaustiveness, which requires the base to be `sealed`.
- Match the project's language version. Check the `environment: sdk:`
lower bound in the user's `pubspec.yaml`. At `^3.13.0` or higher, write
route variants with primary constructors; below that they fail to
compile, so use the classic form above. Don't mix the two forms in one
route file, and don't raise the user's SDK constraint just to use them.

```dart
// sdk: ^3.13.0 or higher
final class const Home() extends AppRoute;

final class const ProductList({final String? category}) extends AppRoute {
@override
List<Object?> get props => [category];
}

final class const ProductDetail(final String id) extends AppRoute {
@override
List<Object?> get props => [id];
}
```

Primary constructors don't generate `==`, so `props` is still required.

## 2. Wiring up the router

Expand Down
Loading