|
@@ -2,6 +2,12 @@ import 'package:flutter/material.dart';
|
|
|
import '../document/node.dart';
|
|
|
import 'node_widget_builder.dart';
|
|
|
|
|
|
+class NodeWidgetContext {
|
|
|
+ BuildContext buildContext;
|
|
|
+ Node node;
|
|
|
+ NodeWidgetContext({required this.buildContext, required this.node});
|
|
|
+}
|
|
|
+
|
|
|
typedef NodeWidgetBuilderF<T extends Node, A extends NodeWidgetBuilder> = A
|
|
|
Function({
|
|
|
required T node,
|
|
@@ -28,13 +34,15 @@ class RenderPlugins {
|
|
|
nodeWidgetBuilders.removeWhere((key, _) => key == name);
|
|
|
}
|
|
|
|
|
|
- Widget buildWidgetWithNode(Node node) {
|
|
|
- final nodeWidgetBuilder = _nodeWidgetBuilder(node.type);
|
|
|
- return nodeWidgetBuilder(node: node, renderPlugins: this)();
|
|
|
+ Widget buildWidget(NodeWidgetContext context) {
|
|
|
+ final nodeWidgetBuilder = _nodeWidgetBuilder(context.node.type);
|
|
|
+ return nodeWidgetBuilder(node: context.node, renderPlugins: this)(
|
|
|
+ context.buildContext);
|
|
|
}
|
|
|
|
|
|
NodeWidgetBuilderF _nodeWidgetBuilder(String name) {
|
|
|
- assert(nodeWidgetBuilders.containsKey(name));
|
|
|
+ assert(nodeWidgetBuilders.containsKey(name),
|
|
|
+ 'Could not query the builder with this $name');
|
|
|
return nodeWidgetBuilders[name]!;
|
|
|
}
|
|
|
}
|