createSnapshot method
Creates a snapshot of the current state.
The snapshot captures the current value and timestamp, and can include additional metadata.
Implementation
@override
StateSnapshot<T> createSnapshot() {
if (_isDisposed) throw StateError('MockState has been disposed');
if (_shouldThrowOnSnapshot) {
throw _customException ?? Exception('Mock snapshot error');
}
return StateSnapshot(
_value,
timestamp: DateTime.now(),
metadata: {
'mockState': true,
'changeCount': _changeHistory.length,
'listenerCount': _listeners.length,
},
);
}