ConnectionState class sealed

Represents the various states of an MCP connection

Annotations
  • @immutable

Constructors

ConnectionState.connected(ServerInfo serverInfo)
The connection is established and ready
const
factory
ConnectionState.connecting()
The connection is in the process of connecting
const
factory
ConnectionState.disconnected()
The connection is disconnected
const
factory
ConnectionState.disconnecting()
The connection is in the process of disconnecting
const
factory
ConnectionState.error(Object error, StackTrace? stackTrace)
The connection has failed with an error
const
factory

Properties

error Object?
Returns the error if in error state, null otherwise
no setter
hasError bool
Returns true if the connection has an error
no setter
hashCode int
The hash code for this object.
no setterinherited
isConnected bool
Returns true if the connection is ready for use
no setter
isTransitioning bool
Returns true if the connection is in a transitional state
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
serverInfo ServerInfo?
Returns the server info if connected, null otherwise
no setter

Methods

map<T>({required T onDisconnected(), required T onConnecting(), required T onConnected(ServerInfo serverInfo), required T onDisconnecting(), required T onError(Object error, StackTrace? stackTrace)}) → T
Maps the state to a value using the provided functions
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited