OutputLog class
An immutable, bounded log of captured output entries.
OutputLog is designed for use inside immutable Model classes. Because models must be immutable, mutating methods like add and clear return new OutputLog instances instead of modifying this one in place.
Entries beyond maxEntries are dropped from the front (oldest first), making this behave like a ring buffer.
Example
class MyModel extends Model implements CapturedOutputModel {
final OutputLog outputLog;
MyModel({this.outputLog = const OutputLog()});
@override
MyModel withOutputLog(OutputLog log) =>
MyModel(outputLog: log);
// ...
}
Constructors
-
OutputLog({int maxEntries = 500, List<
OutputLogEntry> entries = const []}) -
Creates an empty output log.
const
Properties
-
entries
→ List<
OutputLogEntry> -
The log entries, oldest first.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- isEmpty → bool
-
Whether the log contains no entries.
no setter
- isNotEmpty → bool
-
Whether the log contains at least one entry.
no setter
- length → int
-
The number of entries currently in the log.
no setter
- maxEntries → int
-
The maximum number of entries retained in this log.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
add(
OutputLogEntry entry) → OutputLog -
Returns a new OutputLog with
entryappended. -
addMessage(
CapturedOutputMsg msg) → OutputLog - Returns a new OutputLog with a CapturedOutputMsg appended.
-
clear(
) → OutputLog - Returns a new empty OutputLog with the same maxEntries.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited