readJsonAs<T> static method

Future<T> readJsonAs<T>(
  1. String filePath,
  2. T fromJson(
    1. Map<String, dynamic>
    )
)

读取JSON文件(泛型)

Implementation

static Future<T> readJsonAs<T>(
    String filePath, T Function(Map<String, dynamic>) fromJson) async {
  try {
    final json = await readJson(filePath);
    return fromJson(json);
  } catch (e) {
    throw Exception('Failed to read JSON as type: $e');
  }
}