Files
sweet_chat_app/lib/utils/sp_utils.dart
2026-06-19 21:10:03 +08:00

23 lines
613 B
Dart

import 'package:shared_preferences/shared_preferences.dart';
class SpUtil {
static late SharedPreferences _sp;
static Future<void> init() async {
_sp = await SharedPreferences.getInstance();
}
static Future<bool> setString(String key, String value) =>
_sp.setString(key, value);
static String? getString(String key) => _sp.getString(key);
static Future<bool> setInt(String key, int value) =>
_sp.setInt(key, value);
static int? getInt(String key) => _sp.getInt(key);
static Future<bool> remove(String key) => _sp.remove(key);
static Future<bool> clear() => _sp.clear();
}