loadFromLocation static method

Future<Token?> loadFromLocation(
  1. Directory directory,
  2. String? filename
)

Implementation

static Future<Token?> loadFromLocation(
    Directory directory, String? filename) async {
  var file = File(directory.path + (filename ?? 'userData.json'));
  if (await file.exists()) {
    var data = await file.readAsString();

    try {
      Map<String, dynamic> json = jsonDecode(data);
      return Token.fromJson(json);
    } on Exception {
      return null;
    }
  }
  return null;
}