withMapValue static method

PersistentMap<String, Map<String, dynamic>> withMapValue(
  1. File file, {
  2. bool create = false,
  3. bool comparator(
    1. Map<String, dynamic>,
    2. Map<String, dynamic>
    )?,
})

Create a PersistentMap with strings for keys and maps for values, with file being the database file, and create specifying whether to create a new file if it doesn't exist. If file already exists, the file will not be overwritten, but rather opened. If file contains and incompatible database, behavior is unspecified. Note that the value must be convertible using the json functions in dart:convert

Implementation

static PersistentMap<String, Map<String, dynamic>> withMapValue(
    final File file,
    {bool create = false,
    bool Function(Map<String, dynamic>, Map<String, dynamic>)? comparator}) {
  return make<String, Map<String, dynamic>>(
      file,
      (key) => convert.utf8.encoder.convert(key),
      (bytes) => convert.utf8.decode(bytes),
      (value) => convert.utf8.encoder.convert(convert.json.encode(value)),
      (bytes) => convert.json.decode(convert.utf8.decode(bytes)),
      create: create,
      comparator: comparator);
}