Browse Source

remove cache isolate

master
Pascal Abresch 2 years ago
parent
commit
1f0a6db8a3
  1. 21
      lib/cache.dart
  2. 3
      lib/cachemanager.dart
  3. 6
      lib/main.dart

21
lib/cache.dart

@ -1,21 +0,0 @@
import 'dart:isolate';
class CacheServer {
static void start_cache_server(SendPort sendPort) async {
var recPort = new ReceivePort();
sendPort.send(recPort.sendPort);
main_loop(sendPort, recPort);
}
static void main_loop(SendPort sendPort, ReceivePort recPort) async {
await for (var data in recPort) {
print(data);
//much easier to use one timer isolate to ping us to sync anew than trying to do sync timing here aswell
//sync data for stuff that was requested
}
}
}

3
lib/cachemanager.dart

@ -0,0 +1,3 @@
class CacheServer {
}

6
lib/main.dart

@ -5,18 +5,12 @@ import 'package:shared_preferences/shared_preferences.dart';
import 'page/login';
import 'page/roomlist';
import 'cache.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized(); // for settings
var settings = await SharedPreferences.getInstance();
var recPort = new ReceivePort();
await Isolate.spawn(CacheServer.start_cache_server, recPort.sendPort);
SendPort sendPort = await recPort.first;
var _home;
if (settings.getBool("logged_in") ?? false) {
_home = MyHomePage(settings: settings);