debugAssertIsValid method

  1. @override
bool debugAssertIsValid ()
override

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

@override
bool debugAssertIsValid() {
  assert(() {
    if (children != null) {
      for (final InlineSpan child in children) {
        if (child == null) {
          throw FlutterError.fromParts(<DiagnosticsNode>[
            ErrorSummary('TextSpan contains a null child.'),
            ErrorDescription(
                'A TextSpan object with a non-null child list should not have any nulls in its child list.'),
            toDiagnosticsNode(name: 'The full text in question was',
                style: DiagnosticsTreeStyle.errorProperty),
          ]);
        }
        assert(child.debugAssertIsValid());
      }
    }
    return true;
  }());
  return super.debugAssertIsValid();
}