From 9b656e9cbe3c7584a9c084eb46424e5a35044bd0 Mon Sep 17 00:00:00 2001 From: Jan Romann Date: Mon, 28 Mar 2022 17:08:38 +0200 Subject: [PATCH] refactor: refactor initialization of CoapUDPChannel --- lib/src/channel/coap_udp_channel.dart | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/lib/src/channel/coap_udp_channel.dart b/lib/src/channel/coap_udp_channel.dart index 5ef7204c..505ce160 100644 --- a/lib/src/channel/coap_udp_channel.dart +++ b/lib/src/channel/coap_udp_channel.dart @@ -10,14 +10,13 @@ part of coap; /// Channel via UDP protocol. class CoapUDPChannel extends CoapIChannel { /// Initialise with a specific address and port - CoapUDPChannel(this._address, this._port, - {required String namespace, required this.config}) { - _eventBus = CoapEventBus(namespace: namespace); - final socket = CoapNetworkManagement.getNetwork( - address!, _port, CoapConstants.uriScheme, - namespace: namespace, config: config); - _socket = socket; - } + CoapUDPChannel(CoapInternetAddress? address, this._port, + {required String namespace, required this.config}) + : _address = address, + _eventBus = CoapEventBus(namespace: namespace), + _socket = CoapNetworkManagement.getNetwork( + address!, _port, CoapConstants.uriScheme, + namespace: namespace, config: config); final int _port; @@ -29,11 +28,11 @@ class CoapUDPChannel extends CoapIChannel { @override CoapInternetAddress? get address => _address; - late CoapINetwork _socket; + final CoapINetwork _socket; final typed.Uint8Buffer _buff = typed.Uint8Buffer(); - late final CoapEventBus _eventBus; + final CoapEventBus _eventBus; @override Future start() async {