setLayoutDirection method

Future<void> setLayoutDirection(
  1. TextDirection layoutDirection
)

Sets the layout direction for the Android view.

Implementation

Future<void> setLayoutDirection(TextDirection layoutDirection) async {
  assert(
    _state != _AndroidViewState.disposed,
    'trying to set a layout direction for a disposed Android view. View id: $viewId',
  );

  if (layoutDirection == _layoutDirection) {
    return;
  }

  _layoutDirection = layoutDirection;

  // If the view was not yet created we just update _layoutDirection and return, as the new
  // direction will be used in _create.
  if (_state == _AndroidViewState.waitingForSize) {
    return;
  }

  await SystemChannels.platform_views
      .invokeMethod<void>('setDirection', <String, dynamic>{
    'id': viewId,
    'direction': _getAndroidDirection(layoutDirection),
  });
}