diff --git a/win_text_editor/lib/modules/template_parser/widgets/template_parser_view.dart b/win_text_editor/lib/modules/template_parser/widgets/template_parser_view.dart index 5dc4777..df2afd3 100644 --- a/win_text_editor/lib/modules/template_parser/widgets/template_parser_view.dart +++ b/win_text_editor/lib/modules/template_parser/widgets/template_parser_view.dart @@ -133,31 +133,31 @@ class _TemplateParserViewState extends State { final templateNode = node as TemplateNode; final isAttribute = node.depth > 0 && node.name.startsWith('@'); - return Padding( - padding: EdgeInsets.only(left: 12.0 * node.depth), // 动态缩进 - child: ListTile( - dense: true, - leading: - isAttribute - ? const Icon(Icons.code, size: 16, color: Colors.grey) - : const Icon(Icons.label_outline, size: 18, color: Colors.blue), - title: Text( - isAttribute ? templateNode.name.substring(1) : templateNode.name, - style: TextStyle( - color: isAttribute ? Colors.grey[600] : Colors.black, - fontWeight: isAttribute ? FontWeight.normal : FontWeight.w500, + return Consumer( + builder: (context, controller, _) { + return Padding( + padding: EdgeInsets.only(left: 12.0 * node.depth), // 动态缩进 + child: ListTile( + dense: true, + leading: + isAttribute + ? const Icon(Icons.code, size: 16, color: Colors.grey) + : const Icon(Icons.label_outline, size: 18, color: Colors.blue), + title: Text( + isAttribute ? templateNode.name.substring(1) : templateNode.name, + style: TextStyle( + color: isAttribute ? Colors.grey[600] : Colors.black, + fontWeight: isAttribute ? FontWeight.normal : FontWeight.w500, + ), + ), + trailing: + templateNode.isRepeated + ? const Text("(repeated)", style: TextStyle(color: Colors.grey)) + : null, + onTap: () => controller.selectTreeNode(templateNode), ), - ), - trailing: - templateNode.isRepeated - ? const Text("(repeated)", style: TextStyle(color: Colors.grey)) - : null, - onTap: - () => Provider.of( - context, - listen: false, - ).selectTreeNode(templateNode), - ), + ); + }, ); }