load static method

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

Public factory

Implementation

static Future<CapabilityProfile> load({String name = 'default'}) async {
  final content = await rootBundle
      .loadString('packages/esc_pos_utils/resources/capabilities.json');
  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);
}