write method

  1. @override
Future<void> write(
  1. State state
)
override

Write the state to the storage.

Implementation

@override
Future<void> write(State state) async {
  final file = await this.file();
  final tempFile = File(file.path + '.temp');

  if (!tempFile.existsSync()) {
    await tempFile.create(recursive: true);
  }
  final json = jsonEncode(converter.toJson(state));
  await tempFile.writeAsString(json);

  await tempFile.rename(file.path);
}