DiagnosticsProperty<T>.lazy constructor

DiagnosticsProperty<T>.lazy(String name, ComputePropertyValueCallback<T> computeValue, { String description, String ifNull, String ifEmpty, bool showName: true, bool showSeparator: true, Object defaultValue: kNoDefaultValue, String tooltip, bool missingIfNull: false, DiagnosticsTreeStyle style: DiagnosticsTreeStyle.singleLine, DiagnosticLevel level: DiagnosticLevel.info })

Property with a value that is computed only when needed.

Use if computing the property value may throw an exception or is expensive.

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

The level argument is just a suggestion and can be overridden if if something else about the property causes it to have a lower or higher level. For example, if calling computeValue throws an exception, level will always return DiagnosticLevel.error.

Implementation

DiagnosticsProperty.lazy(
  String name,
  ComputePropertyValueCallback<T> computeValue, {
  String description,
  String ifNull,
  this.ifEmpty,
  bool showName: true,
  bool showSeparator: true,
  this.defaultValue: kNoDefaultValue,
  this.tooltip,
  this.missingIfNull: false,
  DiagnosticsTreeStyle style: DiagnosticsTreeStyle.singleLine,
  DiagnosticLevel level: DiagnosticLevel.info,
}) : assert(showName != null),
     assert(showSeparator != null),
     assert(defaultValue == kNoDefaultValue || defaultValue is T),
     assert(missingIfNull != null),
     assert(style != null),
     assert(level != null),
     _description = description,
     _valueComputed = false,
     _value = null,
     _computeValue = computeValue,
      _defaultLevel = level,
     ifNull = ifNull ?? (missingIfNull ? 'MISSING' : null),
     super(
       name: name,
       showName: showName,
       showSeparator: showSeparator,
       style: style,
     );