shallowReadonly<T> function

ShallowReadonly<T> shallowReadonly<T>(
  1. Object source
)

Creates a shallow readonly wrapper.

Only root-level access is readonly. Nested properties can still be mutated.

Example:

final state = shallowReadonly(ref({'foo': 1, 'nested': {'bar': 2}}));

// Reading works
state.value; // {'foo': 1, 'nested': {'bar': 2}}

// Nested mutation still works
state.value['nested']['bar'] = 3;

Implementation

ShallowReadonly<T> shallowReadonly<T>(Object source) =>
    ShallowReadonly<T>(source);