Markdown screens
content: on a screen names Markdown resources of lib/resources/: one file, or a folder for a path ending in {*name}, where the rest of the address plus .md is the file. RouteContentView shows it with the theme, through MarkdownView. A link to another Markdown file of the folder opens its screen, so a folder of Markdown is a site.
Why
Documentation, help and legal pages are files, not widgets. One screen with a {*path} route shows a whole folder, each file at its own address, with links between them that work as on a web page. The same files become HTML pages for search engines with spring.flutter.web.seo.from-routes. The site you are reading is built this way.
Example
@ScreenRoute('/docs/{*path}', title: 'Docs', content: 'resources:content/docs/')
class DocPage extends StatelessWidget {
const DocPage({super.key});
@override
Widget build(BuildContext context) =>
const SingleChildScrollView(child: RouteContentView());
}
| Address | File |
|---|---|
/docs |
lib/resources/content/docs/index.md |
/docs/core/beans |
lib/resources/content/docs/core/beans.md |
/docs/guides |
lib/resources/content/docs/guides/index.md (a folder's own page) |
/ja/docs/core/beans |
lib/resources/content/docs/core/beans.ja.md, or beans.md without a translation (with languages: [en, ja]) |
A relative link in a file is relative to its own folder, index.md included, for a folder of any root (resources: or asset:). A link to a Markdown file of the site opens its screen; any other link goes to onLink.
RouteContentView
| Parameter | Default | Meaning |
|---|---|---|
onLink |
none | Called with a link to no Markdown file of the site (an https address) |
selectable |
true |
Whether the text can be selected |
outline |
none | A MarkdownOutline that gets the page's headings, for an "On this page" list |
scrollToTop |
true |
Another page of the route starts at the top of the scrollable it is in, as a browser opens a page; the position goes back the theme's way (motion.scroll-to-top, 400ms ease-out-cubic by default, none to jump). An #anchor scrolls to its heading instead, and a translation of the same page keeps the position |
- Another page of the same screen keeps the screen and its scroll view; the content changes the theme's way (
motion.content-change), without collapsing to nothing for a frame. - The address's
#anchor(/docs/core/beans#scopes) scrolls to its heading. RouteContentView.fileOfsays which file an address shows (the folder'sindex.md, the language's translation).- Code blocks, tables, callouts and headings take the theme's
styles.*(see MarkdownView).
A page list for a menu
The site reads its menus from contents.md files of the folders. Keep them out of the pages for search engines with spring.flutter.web.seo.exclude: ['**/contents*.md'].