Leave room support, persist last room, fixes
This commit is contained in:
parent
f7c6c3bb6a
commit
7dfd47a404
17 changed files with 312 additions and 136 deletions
30
lib/controllers/key_controller.dart
Normal file
30
lib/controllers/key_controller.dart
Normal 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,
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue