forked from Nexus/nexus
treewide(refactor): rename files to follow the same style
This commit is contained in:
parent
15d441e4c4
commit
7992f0e815
81 changed files with 167 additions and 167 deletions
30
lib/controllers/key.dart
Normal file
30
lib/controllers/key.dart
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
import "package:flutter_riverpod/flutter_riverpod.dart";
|
||||
import "package:nexus/controllers/shared_prefs.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? value) async {
|
||||
final prefs = ref.watch(SharedPrefsController.provider).requireValue;
|
||||
state = value;
|
||||
|
||||
if (value == null) {
|
||||
prefs.remove(key);
|
||||
} else {
|
||||
prefs.setString(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
static final provider =
|
||||
NotifierProvider.family<KeyController, String?, String>(
|
||||
KeyController.new,
|
||||
);
|
||||
}
|
||||
Loading…
Reference in a new issue