style.dart
1.12 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
import '../options.dart';
import '../syntax_tree.dart';
/// Node to denote all kinds of style changes.
class StyleNode extends TransparentNode {
final List<GreenNode> children;
/// The difference of [MathOptions].
final OptionsDiff optionsDiff;
StyleNode({
required this.children,
required this.optionsDiff,
});
@override
List<MathOptions> computeChildOptions(MathOptions options) =>
List.filled(children.length, options.merge(optionsDiff), growable: false);
@override
bool shouldRebuildWidget(MathOptions oldOptions, MathOptions newOptions) =>
false;
@override
ParentableNode<GreenNode> updateChildren(List<GreenNode> newChildren) =>
copyWith(children: newChildren);
@override
Map<String, Object?> toJson() => super.toJson()
..addAll({
'children': children.map((e) => e.toJson()).toList(growable: false),
'optionsDiff': optionsDiff.toString(),
});
StyleNode copyWith({
List<GreenNode>? children,
OptionsDiff? optionsDiff,
}) =>
StyleNode(
children: children ?? this.children,
optionsDiff: optionsDiff ?? this.optionsDiff,
);
}