DiagnosticsProperty<T> constructor Null safety

DiagnosticsProperty<T>(
  1. String? name,
  2. T? value,
  3. {String? description,
  4. String? ifNull,
  5. String? ifEmpty,
  6. bool showName = true,
  7. bool showSeparator = true,
  8. Object? defaultValue = kNoDefaultValue,
  9. String? tooltip,
  10. bool missingIfNull = false,
  11. String? linePrefix,
  12. bool expandableValue = false,
  13. bool allowWrap = true,
  14. bool allowNameWrap = true,
  15. DiagnosticsTreeStyle style = DiagnosticsTreeStyle.singleLine,
  16. DiagnosticLevel level = DiagnosticLevel.info}
)

Create a diagnostics property.

The showName, showSeparator, style, missingIfNull, and level arguments must not be null.

The level argument is just a suggestion and can be overridden if something else about the property causes it to have a lower or higher level. For example, if the property value is null and missingIfNull is true, level is raised to DiagnosticLevel.warning.

Implementation

DiagnosticsProperty(
  String? name,
  T? value, {
  String? description,
  String? ifNull,
  this.ifEmpty,
  super.showName,
  super.showSeparator,
  this.defaultValue = kNoDefaultValue,
  this.tooltip,
  this.missingIfNull = false,
  super.linePrefix,
  this.expandableValue = false,
  this.allowWrap = true,
  this.allowNameWrap = true,
  DiagnosticsTreeStyle super.style = DiagnosticsTreeStyle.singleLine,
  DiagnosticLevel level = DiagnosticLevel.info,
}) : assert(showName != null),
     assert(showSeparator != null),
     assert(style != null),
     assert(level != null),
     _description = description,
     _valueComputed = true,
     _value = value,
     _computeValue = null,
     ifNull = ifNull ?? (missingIfNull ? 'MISSING' : null),
     _defaultLevel = level,
     super(
       name: name,
    );