Leave room support, persist last room, fixes

This commit is contained in:
Henry Hiles 2025-12-03 16:16:30 -05:00
commit 7dfd47a404
No known key found for this signature in database
17 changed files with 312 additions and 136 deletions

View file

@ -0,0 +1,30 @@
import "package:flutter_riverpod/flutter_riverpod.dart";
import "package:nexus/controllers/shared_prefs_controller.dart";
class KeyController extends Notifier<String?> {
final String key;
KeyController(this.key);
static const String spaceKey = "space";
static const String roomKey = "room";
@override
String? build() =>
ref.watch(SharedPrefsController.provider).requireValue.getString(key);
Future<void> set(String? id) async {
final prefs = ref.watch(SharedPrefsController.provider).requireValue;
state = id;
if (id == null) {
prefs.remove(key);
} else {
prefs.setString(key, id);
}
}
static final provider =
NotifierProvider.family<KeyController, String?, String>(
KeyController.new,
);
}