init method

Future<Map<String, Object>> init(
  1. Plugin plugin,
  2. Map<String, Object> request
)

init method used to answer to configure the plugin with the core lightning configuration.

Implementation

Future<Map<String, Object>> init(
    Plugin plugin, Map<String, Object> request) async {
  var opts = Map.from(json.decode(json.encode(request['options'])));
  opts.forEach((optsName, optValue) {
    if (!options.containsKey(optsName)) {
      throw Exception(
          "Option with name `$optsName` not register in the plugin options");
    }
    options[optsName]!.value = optValue;
  });
  configuration =
      Map.from(json.decode(json.encode(request['configuration'])));
  return await _onInit(plugin);
}