load static method

Future<CapabilityProfile> load({
  1. String name = 'default',
})

Public factory

Implementation

static Future<CapabilityProfile> load({String name = 'default'}) async {
  final content =
      await Resource('package:esc_pos_dart/resources/capabilities.json')
          .readAsString();
  Map capabilities = json.decode(content);

  var profile = capabilities['profiles'][name];

  if (profile == null) {
    throw Exception("The CapabilityProfile '$name' does not exist");
  }

  List<CodePage> list = [];
  profile['codePages'].forEach((k, v) {
    list.add(CodePage(int.parse(k), v));
  });

  // Call the private constructor
  return CapabilityProfile._internal(name, list);
}