diff --git a/lib/src/editor/editor_component/service/renderer/block_component_widget.dart b/lib/src/editor/editor_component/service/renderer/block_component_widget.dart index 60e44ee06..cebd3d424 100644 --- a/lib/src/editor/editor_component/service/renderer/block_component_widget.dart +++ b/lib/src/editor/editor_component/service/renderer/block_component_widget.dart @@ -84,17 +84,21 @@ mixin NestedBlockComponentStatefulWidgetMixin< Directionality.maybeOf(context) ?? TextDirection.ltr; if (node.children.isNotEmpty) { final firstChild = node.children.first; - final currentState = - firstChild.key.currentState as BlockComponentTextDirectionMixin?; - if (currentState != null) { - final lastDirection = currentState.lastDirection; - direction = calculateNodeDirection( - node: firstChild, - layoutDirection: direction, - defaultTextDirection: editorState.editorStyle.defaultTextDirection, - lastDirection: lastDirection, - ); + + if (firstChild.key.currentState is! BlockComponentTextDirectionMixin) { + return EdgeInsets.zero; } + + final currentState = + firstChild.key.currentState as BlockComponentTextDirectionMixin; + + final lastDirection = currentState.lastDirection; + direction = calculateNodeDirection( + node: firstChild, + layoutDirection: direction, + defaultTextDirection: editorState.editorStyle.defaultTextDirection, + lastDirection: lastDirection, + ); } return configuration.indentPadding(node, direction); }