Skip to content

Commit ecbbb3c

Browse files
committed
refactor: make _api property non-nullable
1 parent f2ff311 commit ecbbb3c

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

lib/state/connection/connection_cubit.dart

+5-4
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class ConnectionCubit extends Cubit<ConnectionState> {
4646

4747
final String _key = '${UniqueKey()}';
4848

49-
late final BaseAPI? _api;
49+
late final BaseAPI _api;
5050

5151
/// Enables debug mode.
5252
///
@@ -86,7 +86,8 @@ class ConnectionCubit extends Cubit<ConnectionState> {
8686
/// Stream subscription for connectivity.
8787
StreamSubscription<ConnectivityResult>? connectivitySubscription;
8888

89-
BaseAPI get api => _api as BinaryAPI;
89+
/// Getter for [BaseAPI] implementation class.
90+
BaseAPI get api => _api;
9091

9192
/// Reconnect to Websocket.
9293
Future<void> reconnect({
@@ -111,7 +112,7 @@ class ConnectionCubit extends Cubit<ConnectionState> {
111112
emit(const ConnectionConnectingState());
112113

113114
try {
114-
await _api!.disconnect().timeout(_pingTimeout);
115+
await _api.disconnect().timeout(_pingTimeout);
115116
} on Exception catch (e) {
116117
dev.log('$runtimeType disconnect exception: $e', error: e);
117118

@@ -120,7 +121,7 @@ class ConnectionCubit extends Cubit<ConnectionState> {
120121
return;
121122
}
122123

123-
await _api!.connect(
124+
await _api.connect(
124125
_connectionInformation,
125126
printResponse: enableDebug && printResponse,
126127
onOpen: (String key) {

0 commit comments

Comments
 (0)