init static method

Future<void> init()

初始化*

Implementation

static Future<void> init() async {
  //获取当前日志文件索引
  currentLogFileIndex=await SharedPreferencesUtil.getInt("CurrentLogFileIndex", 0);
  i(tag, "init:currentLogFileIndex:"+currentLogFileIndex.toString());

  LogUtil.init(isDebug: true,tag: "flutter_smart_ptt");

  //日志文件目录
  logDir=(await getApplicationDocumentsDirectory()).path.toString();

  //android使用/sdcard/Android/data/包名/files
  if(Platform.isAndroid){
    Directory? directory = await getExternalStorageDirectory();
    if (directory != null) {
      //不存在则创建
      if (!await directory.exists()) {
        await directory.create(recursive: true);
      }
      logDir=directory.path;
    }
  }
  i(tag, "init:logDir:"+logDir);

  startTimer();
}