PersistentString class

The PersistentString is meant to be used to store a value of type String.

This class extends the PersistentValue, so that, every time a new value is set, this is both stored in the database (if the flag continuousSave is set to true ) and sent to the stream to drive a StreamBuilder or a ValueBuilder to update the UI.

  • table is set by default to 'kvp', so that if not specified, all the instances of a PersistentValue derived class, will store their values to the same table.

  • persistentKey is the key associated to the PersistentValue derived entity.

  • initialData is used when no record is found in the database to make an insert with the first key/value pair having as key the argument passed to the persistentKey parameter and for value the argument passed to the initialData parameter.

  • continuousSave is set by default to true, so that every time to the persistentString is given a new value, the record in the db will be updated. If set to false, to update the record in the db, it is necessary to call the save method.

Inheritance

Constructors

PersistentString({@required String persistentKey, String table: 'kvp', String initialData, bool continuousSave: true})

Properties

continuousSave → bool
This flag indicates if the new value needs to be saved on every update. If set to false, it is necessary to call the save method to store the value to the database. By default is true.
final, inherited
hashCode → int
The hash code for this object.
read-only, inherited
initialData ↔ String
The initial event of the stream
read / write, inherited
inStream → Function
Sink for the stream
read-only, inherited
onError → Function
Callback to handle the errors
final, inherited
outStream → Stream<String>
Stream getter
read-only, inherited
persistentKey → String
final, inherited
runtimeType → Type
A representation of the runtime type of the object.
read-only, inherited
stream BehaviorSubject<String>
Stream of type BehaviorSubject in order to emit the last event to every new listener.
read / write, inherited
table → String
final, inherited
timesUpdated ↔ int
timesUpdate shows how many times the stream got updated
read / write, inherited
value ↔ String
Getter for the last value emitted by the stream
read / write, inherited

Methods

debugMode() → void
To enable the debug mode
inherited
dispose() → void
inherited
init({DbProvider dbProvider}) → Future<void>
This method takes as a parameter an initialiazed instance of a DbProvider, initialize the KeyValueProvider that creates the table in which they key/value pairs are stored. [...]
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed.
inherited
onChange(dynamic onDataChanged(String data)) → void
To set a function that will be called every time the stream updates.
inherited
refresh() → void
Method to refresh the stream (e.g to use when the type it is not a basic type, and a property of an object has changed).
inherited
save() → Future<void>
This method needs to be used whern continuousSave is set to false, to store update the value in the database.
inherited
toString() → String
Returns a string representation of this object.
inherited

Operators

operator ==(dynamic other) → bool
The equality operator.
inherited