configure method

Future<void> configure(
  1. String appSecret, {
  2. required String service,
  3. required String deviceid,
  4. bool debug = false,
})

Implementation

Future<void> configure(String appSecret,
    {required String service,
    required String deviceid,
    bool debug = false}) async {
  this.appSecret = appSecret;
  this.service = service;
  this.deviceid = deviceid;
  this.debug = debug;
  if (debug) {
    Logger.level = Level.debug;
  } else {
    Logger.level = Level.info;
  }

  CanaryDio.instance().configure(service);

  var prefs = await SharedPreferences.getInstance();
  _mockOn = prefs.getBool('mockOn') ?? false;
  if (_mockOn) {
    channel.invokeMethod('enableMock', _mockOn);
  }
  var map =
      jsonDecode(prefs.getString('user') ?? "{}") as Map<String, dynamic>?;
  if (map != null && map.isNotEmpty) {
    user.value = User.fromJson(map);
  }

  MockManager.instance().update();

  channel.setMethodCallHandler(_callHandler);

  CanaryWebSocket.instance.configure(service, deviceid, appSecret);
}