From e47472596545dfef9869d87e2c34d635685f67c9 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Sun, 14 Mar 2021 17:50:45 +0100 Subject: [PATCH] Create specific client for Flutter Web --- lib/helpers/serialization/base_serialization_helper.dart | 8 ++++++++ lib/main_dev.dart | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/helpers/serialization/base_serialization_helper.dart b/lib/helpers/serialization/base_serialization_helper.dart index b49fcee..01ef5ad 100644 --- a/lib/helpers/serialization/base_serialization_helper.dart +++ b/lib/helpers/serialization/base_serialization_helper.dart @@ -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 { Future _loadCache() async { if (_cache != null) return; + if (isWeb) { + _cache = []; + return; + } + try { final file = await _getFilePath(); @@ -55,6 +61,8 @@ abstract class BaseSerializationHelper { /// Save the cache to the persistent memory Future _saveCache() async { + if (isWeb) return; + final file = await _getFilePath(); await file.writeAsString(jsonEncode( _cache.map((e) => e.toJson()).toList().cast>())); diff --git a/lib/main_dev.dart b/lib/main_dev.dart index be84057..a89f357 100644 --- a/lib/main_dev.dart +++ b/lib/main_dev.dart @@ -2,6 +2,7 @@ import 'dart:io'; import 'package:comunic/main.dart'; import 'package:comunic/models/config.dart'; +import 'package:comunic/utils/flutter_utils.dart'; /// Dev (internal) build configuration for the project /// @@ -23,7 +24,7 @@ void main() { apiServerName: "192.168.1.9:3000", apiServerUri: "/", apiServerSecure: false, - clientName: "ComunicFlutter", + clientName: isWeb ? "FlutterWeb" : "ComunicFlutter", )); HttpOverrides.global = new MyHttpOverride();