/*
 * @author lsy
 * @date   2019-09-04
 **/
//import 'package:mmkv_flutter/mmkv_flutter.dart';
//TODO
import 'package:shared_preferences/shared_preferences.dart';

class MmKvUtil {

//  static MmkvFlutter _mmkv;
  static MmKvUtil mmKvUtil;
  static SharedPreferences _mmkv;

  //MmkvFlutter mmkv
  MmKvUtil._(mmkv) {
    _mmkv = mmkv;
  }

  static Future<MmKvUtil> getInstance() async {
    if (mmKvUtil == null) {
      final SharedPreferences _mmkv = await SharedPreferences.getInstance();
//      final MmkvFlutter _mmkv = await MmkvFlutter.getInstance();
//      _mmkv
      mmKvUtil = new MmKvUtil._(_mmkv);
    }
    return mmKvUtil;
  }

  Future saveBoolKv(String key, bool value) async {
    return await _mmkv.setBool(key, value);
  }

  Future saveStringKv(String key, String value) async {
    return await _mmkv.setString(key, value);
  }

  Future saveDoubleKv(String key, double value) async {
    return await _mmkv.setDouble(key, value);
  }

  Future<bool> saveIntKv(String key, int value) async {
    return await _mmkv.setInt(key, value);
  }

  Future<String> getStringKv(String key) async {
    return await _mmkv.getString(key);
  }

  Future<bool> getBoolKv(String key) async {
    return await _mmkv.getBool(key);
  }

  Future<int> getIntKv(String key) async {
    return await _mmkv.getInt(key);
  }

  Future<double> getDoubleKv(String key) async {
    return await _mmkv.getDouble(key);
  }

  Future<bool> clearKv() async {
    return await _mmkv.clear();
  }
}
