import 'package:flutter/material.dart'; import 'package:signalr_core/signalr_core.dart'; class SignalRHelper{ String hubBaseURL =""; String msg ="Elham"; HubConnection connection; SignalRHelper(){ connection = HubConnectionBuilder() .withUrl( hubBaseURL, HttpConnectionOptions( logging: (level, message) { msg = message; print("$message"); }, ) ).build(); } closeConnection(BuildContext context) async { if(connection.state == HubConnectionState.connected) { await connection.stop(); } } }