-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Expand file tree
/
Copy pathtutorial_outline.dart
More file actions
51 lines (45 loc) · 1.42 KB
/
tutorial_outline.dart
File metadata and controls
51 lines (45 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Copyright 2025 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:jaspr/dom.dart';
import 'package:jaspr/jaspr.dart';
import 'package:jaspr_content/jaspr_content.dart';
import '../../markdown/markdown_parser.dart';
import '../../models/tutorial_model.dart';
class TutorialOutline extends CustomComponentBase {
const TutorialOutline();
@override
Pattern get pattern => 'TutorialOutline';
@override
Component apply(
String name,
Map<String, String> attributes,
Component? child,
) {
return Builder(
builder: (context) {
final model = switch (context.page.data['tutorial']) {
final Map<Object?, Object?>? tutorialData when tutorialData != null =>
TutorialModel.fromMap(tutorialData),
_ => throw Exception('No tutorial data found.'),
};
return div(classes: 'tutorial-outline', [
ol([
for (final unit in model.units)
li([
.text(unit.title),
ol([
for (final chapter in unit.chapters)
li([
a(href: chapter.url, [
DashMarkdown(content: chapter.title, inline: true),
]),
]),
]),
]),
]),
]);
},
);
}
}