Adding a resource
List, detail, create and edit are generic. A new resource is a schema entry, not four new screens.
1. Describe it
In lib/features/resources/resource_schema.dart:
'invoices': ResourceSpec(
name: 'invoices',
singular: 'Invoice',
titleField: 'number', // names the record in headings and breadcrumbs
statuses: ['Draft', 'Sent', 'Paid', 'Overdue'],
fields: [
FieldSpec('number', 'Invoice', ColKind.text, editable: false),
FieldSpec('client', 'Client', ColKind.text),
FieldSpec('amount', 'Amount', ColKind.money),
FieldSpec('due', 'Due', ColKind.text),
FieldSpec('status', 'Status', ColKind.select,
options: ['Draft', 'Sent', 'Paid', 'Overdue']),
FieldSpec('notes', 'Notes', ColKind.longText, inList: false),
],
),
2. Route it
Add the name to the loop in lib/core/router/app_router.dart:
for (final resource in const ['orders', 'customers', 'products', 'invoices'])
That generates /invoices, /invoices/new,
/invoices/:id and /invoices/:id/edit. Then add a
NavItem in routes.dart.
What you get for free
| From the spec | Drives |
|---|---|
inList | Which fields become table columns |
ColKind | Column type, alignment, formatting, and the edit control |
editable | Whether the field appears in the create/edit form |
statuses | The filter chips on the list toolbar |
titleField | Page heading, breadcrumb, delete confirmation, drawer title |
options | The select's choices, and its validation |
Field kinds
| ColKind | List column | Edit control | Validation |
|---|---|---|---|
text | Text, start-aligned | KiteInput | Not empty |
number | Number, end-aligned | Numeric input | Parses as a number |
money | Currency, end-aligned, numeric sort preserved | Numeric input | Parses as a number |
email | Text | Email keyboard | Contains @ |
select | Text, tone-coded badge on detail | KiteSelect | A choice was made |
longText | Usually inList: false | KiteTextarea | Optional |
Currency columns keep their numeric value. They render as
$1,264.55 via TrinaColumnType.currency while
sorting numerically. Formatting the value into a string instead would sort
$9.00 after $1,264.55.
When the generic screens are not enough
They are a starting point, not a cage. If invoices need a line-item editor,
write lib/features/invoices/ and route it directly — the schema
approach earns its keep on the resources that are genuinely CRUD, and gets out
of the way on the ones that are not.