mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-22 12:59:21 +00:00
Create specific client for Flutter Web
This commit is contained in:
parent
4a905174bf
commit
e474725965
@ -2,6 +2,7 @@ import 'dart:convert';
|
|||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:comunic/constants.dart';
|
import 'package:comunic/constants.dart';
|
||||||
|
import 'package:comunic/utils/flutter_utils.dart';
|
||||||
import 'package:path/path.dart' as path;
|
import 'package:path/path.dart' as path;
|
||||||
import 'package:path_provider/path_provider.dart';
|
import 'package:path_provider/path_provider.dart';
|
||||||
|
|
||||||
@ -38,6 +39,11 @@ abstract class BaseSerializationHelper<T extends SerializableElement> {
|
|||||||
Future<void> _loadCache() async {
|
Future<void> _loadCache() async {
|
||||||
if (_cache != null) return;
|
if (_cache != null) return;
|
||||||
|
|
||||||
|
if (isWeb) {
|
||||||
|
_cache = [];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final file = await _getFilePath();
|
final file = await _getFilePath();
|
||||||
|
|
||||||
@ -55,6 +61,8 @@ abstract class BaseSerializationHelper<T extends SerializableElement> {
|
|||||||
|
|
||||||
/// Save the cache to the persistent memory
|
/// Save the cache to the persistent memory
|
||||||
Future<void> _saveCache() async {
|
Future<void> _saveCache() async {
|
||||||
|
if (isWeb) return;
|
||||||
|
|
||||||
final file = await _getFilePath();
|
final file = await _getFilePath();
|
||||||
await file.writeAsString(jsonEncode(
|
await file.writeAsString(jsonEncode(
|
||||||
_cache.map((e) => e.toJson()).toList().cast<Map<String, dynamic>>()));
|
_cache.map((e) => e.toJson()).toList().cast<Map<String, dynamic>>()));
|
||||||
|
@ -2,6 +2,7 @@ import 'dart:io';
|
|||||||
|
|
||||||
import 'package:comunic/main.dart';
|
import 'package:comunic/main.dart';
|
||||||
import 'package:comunic/models/config.dart';
|
import 'package:comunic/models/config.dart';
|
||||||
|
import 'package:comunic/utils/flutter_utils.dart';
|
||||||
|
|
||||||
/// Dev (internal) build configuration for the project
|
/// Dev (internal) build configuration for the project
|
||||||
///
|
///
|
||||||
@ -23,7 +24,7 @@ void main() {
|
|||||||
apiServerName: "192.168.1.9:3000",
|
apiServerName: "192.168.1.9:3000",
|
||||||
apiServerUri: "/",
|
apiServerUri: "/",
|
||||||
apiServerSecure: false,
|
apiServerSecure: false,
|
||||||
clientName: "ComunicFlutter",
|
clientName: isWeb ? "FlutterWeb" : "ComunicFlutter",
|
||||||
));
|
));
|
||||||
|
|
||||||
HttpOverrides.global = new MyHttpOverride();
|
HttpOverrides.global = new MyHttpOverride();
|
||||||
|
Loading…
Reference in New Issue
Block a user