setLayoutDirection method

Future<void> setLayoutDirection (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 UIView. View id: $id');

  if (layoutDirection == _layoutDirection)
    return;

  assert(layoutDirection != null);
  _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('setDirection', <String, dynamic> {
    'id': id,
    'direction': _getAndroidDirection(layoutDirection),
  });
}