import 'package:flutter/material.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:hub/shared/helpers/base_storage.dart';

class SecureStorage implements BaseStorage {
  SecureStorage._();

  static final SecureStorage instance = SecureStorage._();

  late final FlutterSecureStorage _secureStorage;

  @override
  Future<void> init() async {
    _secureStorage = const FlutterSecureStorage();
  }

  @override
  Future<String?> get(String key) async {
    return await _secureStorage.read(key: key);
  }

  @override
  Future<void> set(String key, String value) async {
    await _secureStorage.write(key: key, value: value);
  }

  @override
  Future<void> delete(String key) async {
    await _secureStorage.delete(key: key);
  }

  @override
  Future<void> clearAll() async {
    await _secureStorage.deleteAll();
  }
}
