readJson<T extends Object> method

Future<T?> readJson<T extends Object>(
  1. String fileName
)

Reads a JSON value from app-private storage.

Returns null if the file is missing or contains invalid JSON.

Implementation

Future<T?> readJson<T extends Object>(String fileName) async {
  _validateFileName(fileName);
  final content = await NexoraSdkPlatform.instance.readFile(fileName);
  if (content == null) return null;
  try {
    final value = jsonDecode(content);
    return value is T ? value : null;
  } on FormatException {
    return null;
  }
}