LocalValue<T> constructor

const LocalValue<T>({
  1. DocumentType? documentType,
  2. T fromJson(
    1. Map<String, dynamic>
    )?,
  3. Map<String, dynamic> toJson(
    1. T
    )?,
  4. List<String>? basePath,
})

documentType specifies the storage path. see DocumentType. (NOTE: this value is ignored on web and always stores to DocumentType.prefs.) toJson and fromJson are required if storing a non-primative (NOT one of int, double, string, or Map<String, dynamic>). otherwise, defaults to identity functions. basePath specifies the path that the files are stored to. It is recommended to use this paramater, if only for style: This is because it is possible to polute the base directory & face collisions.

final localUsers = LocalValue<User>(
  fromJson: User.fromJson,
  toJson: (user) => user.toJson,
  basePath: ['users']
);

await localUsers.write(user.id, user);

Implementation

const LocalValue({
  DocumentType? documentType,
  T Function(Map<String, dynamic>)? fromJson,
  Map<String, dynamic> Function(T)? toJson,
  List<String>? basePath,
}) : super(
          documentType: documentType,
          fromJson: fromJson,
          toJson: toJson,
          basePath: basePath,
          localDataContainerCreator: LocalDataContainer.create);