LayrzProtocolHttp constructor

LayrzProtocolHttp({
  1. required String ident,
  2. String password = '',
  3. required String server,
  4. LayrzProtocolVersion version = LayrzProtocolVersion.v2,
  5. @visibleForTesting Dio? testDio,
})

LayrzProtocolHttp is the class that contains the methods to interact with the Layrz ecosystem.

All of the methods are asynchronous and return a Future<void> that is a list of Command. Also, all of them may throw an exception if something goes wrong:

Implementation

LayrzProtocolHttp({
  required this.ident,
  this.password = '',
  required this.server,
  this.version = LayrzProtocolVersion.v2,
  @visibleForTesting Dio? testDio,
}) : assert(ident.isNotEmpty) {
  _baseUrl = server;
  _dio =
      testDio ??
      Dio(
        BaseOptions(
          baseUrl: baseUrl,
          headers: headers,
          responseDecoder: (bytes, options, responseBody) => utf8.decode(bytes, allowMalformed: true),
          requestEncoder: (data, options) => utf8.encode(data),
        ),
      );
}