ModifiableSnapshotView class Null safety

Base class for data classes that can be changed

Example use:

mixin AddressMixin {

  String get city => get('city');

  set city(String v) => set('city',v);
}

class Address = ModifiableSnapshotView with AddressMixin;

This will create an Address class containing the getters and setters (and possibly other methods) defined in AddressMixin and with a fromJson constructor and toJson method.

ModifiableSnapshotViews should be used with care as changes will not flow upstream. For example, consider the following code:

var snapshot = ModifiableSnapshotView.fromJson({
  'firstname': 'John',
  'address': {
    'addressLine1': 'Mainstreet 1',
    'city': 'London'
  }
});
var address = snapshot.get<Address>('address');
address.city = 'New York';
print(snapshot.get('address/city')); // prints 'London'
print(snapshot.get<Address>('address').city); // prints 'New York'
Mixed in types
Available Extensions

Constructors

ModifiableSnapshotView.fromJson(dynamic json, {SnapshotDecoder? decoder})
ModifiableSnapshotView.fromStream(Stream<Snapshot> stream)

Properties

hashCode int
The hash code for this object.
read-onlyinherited
isDisposed bool
read-only
runtimeType Type
A representation of the runtime type of the object.
read-onlyinherited

Methods

dispose() Future<void>
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed.
inherited
toJson() → dynamic
Returns the JSON representation of the snapshot
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited