debugAssertIsValid method

bool debugAssertIsValid ()

In checked mode, throws an exception if the object is not in a valid configuration. Otherwise, returns true.

This is intended to be used as follows:

assert(myTextSpan.debugAssertIsValid());

Implementation

bool debugAssertIsValid() {
  assert(() {
    if (!visitTextSpan((TextSpan span) {
      if (span.children != null) {
        for (TextSpan child in span.children) {
          if (child == null)
            return false;
        }
      }
      return true;
    })) {
      throw FlutterError(
        'TextSpan contains a null child.\n'
        'A TextSpan object with a non-null child list should not have any nulls in its child list.\n'
        'The full text in question was:\n'
        '${toStringDeep(prefixLineOne: '  ')}'
      );
    }
    return true;
  }());
  return true;
}