getData<T> method

Future<T>? getData<T>(
  1. String key,
  2. Future<T> parser(
    1. String value
    )
)

Retrieve an object of type, T, by its String value. Supply a parser function to process the operation. (See. Flutter's AssetBundle.loadStructuredData

Implementation

Future<T>? getData<T>(
    String key, Future<T> Function(String value) parser) async {
  assert(Assets._assets != null, 'Assets.init() must be called first.');
  Future<T>? data;
  try {
    data = Assets._assets!.loadStructuredData('$setPath(key)$key', parser);
  } catch (ex) {
    data = null;
  }
  return data!;
}