mirror of
				https://gitlab.com/comunic/comunicmobile
				synced 2025-11-04 04:04:18 +00:00 
			
		
		
		
	Create specific client for Flutter Web
This commit is contained in:
		@@ -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>>()));
 | 
			
		||||
 
 | 
			
		||||
@@ -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();
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user