LocalValueImpl<T> constructor

const LocalValueImpl<T>({
  1. DocumentType? documentType,
  2. Map<String, dynamic> toJson(
    1. T
    )?,
  3. T fromJson(
    1. Map<String, dynamic>
    )?,
  4. List<String>? basePath,
  5. required Future<LocalDataContainer> localDataContainerCreator(
    1. DocumentType documentType,
    2. String fileName
    ),
})

Implementation

const LocalValueImpl({
  DocumentType? documentType,
  final Map<String, dynamic> Function(T)? toJson,
  final T Function(Map<String, dynamic>)? fromJson,
  final List<String>? basePath,
  required final Future<LocalDataContainer> Function(
          DocumentType documentType, String fileName)
      localDataContainerCreator,
})  : assert(
          (toJson == null && fromJson == null) ||
              (toJson != null && fromJson != null),
          'a toJson must have a corresponding fromJson and visa versa.'),
      assert(
          toJson != null ||
              (T == double ||
                  T == int ||
                  T == String ||
                  T == Map<String, dynamic>),
          'Must have custom toJson and fromJson if not using a json primative (int, double, string, or Map<String, dynamic>).'),
      _documentType = kIsWeb
          ? DocumentType.prefs
          : (documentType ?? DocumentType.document),
      _toJson = toJson,
      _fromJson = fromJson,
      _basePath = basePath ?? const [],
      _localDataContainerCreator = localDataContainerCreator;