1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2025-06-19 00:05:16 +00:00

Create specific client for Flutter Web

This commit is contained in:
2021-03-14 17:50:45 +01:00
parent 4a905174bf
commit e474725965
2 changed files with 10 additions and 1 deletions

View File

@ -2,6 +2,7 @@ import 'dart:convert';
import 'dart:io';
import 'package:comunic/constants.dart';
import 'package:comunic/utils/flutter_utils.dart';
import 'package:path/path.dart' as path;
import 'package:path_provider/path_provider.dart';
@ -38,6 +39,11 @@ abstract class BaseSerializationHelper<T extends SerializableElement> {
Future<void> _loadCache() async {
if (_cache != null) return;
if (isWeb) {
_cache = [];
return;
}
try {
final file = await _getFilePath();
@ -55,6 +61,8 @@ abstract class BaseSerializationHelper<T extends SerializableElement> {
/// Save the cache to the persistent memory
Future<void> _saveCache() async {
if (isWeb) return;
final file = await _getFilePath();
await file.writeAsString(jsonEncode(
_cache.map((e) => e.toJson()).toList().cast<Map<String, dynamic>>()));