Skip to content

Commit

Permalink
fix: force unwrap error (#847)
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasXu0 authored Jul 22, 2024
1 parent e0d673a commit 89eee5d
Showing 1 changed file with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 89eee5d

Please sign in to comment.