debugCheckCanResolveTextDirection function

bool debugCheckCanResolveTextDirection(
  1. TextDirection? direction,
  2. String target
)

Asserts that a given TextDirection is not null.

Used by painting library classes that require a TextDirection to resolve their properties, such as BorderRadiusDirectional.

Does nothing if asserts are disabled. Always returns true.

See also:

Implementation

bool debugCheckCanResolveTextDirection(TextDirection? direction, String target) {
  assert(() {
    if (direction == null) {
      throw FlutterError.fromParts(<DiagnosticsNode>[
        ErrorSummary('No TextDirection found.'),
        ErrorDescription(
          'To resolve $target properties, it must be provided with a TextDirection.',
        ),
        ErrorHint(
          'This error usually occurs when $target is used in a widget without '
          'a Directionality ancestor.',
        ),
        ErrorHint(
          'Typically, the Directionality widget is introduced by the MaterialApp '
          'or WidgetsApp widget at the top of your application widget tree. It '
          'determines the ambient reading direction and is used, for example, to '
          'determine how to lay out text, how to interpret "start" and "end" '
          'values, and to resolve EdgeInsetsDirectional, '
          'AlignmentDirectional, and other *Directional objects.',
        ),
      ]);
    }
    return true;
  }());
  return true;
}