ConnectivityState class

Represents the current connectivity state of the device

Constructors

ConnectivityState.new({required List<ConnectivityResult> networkTypes, required bool hasNetworkConnection, required bool hasInternetAccess, required ConnectionSpeed connectionSpeed, required DateTime? lastChecked, String? error, StackTrace? stackTrace})
Constructor for the connectivity state
const
ConnectivityState.connected({required List<ConnectivityResult> networkTypes, required ConnectionSpeed connectionSpeed})
Factory constructor for connected state
factory
ConnectivityState.error({required String error, List<ConnectivityResult>? networkTypes, StackTrace? stackTrace})
Factory constructor for error state
factory
ConnectivityState.networkWithoutInternet({required List<ConnectivityResult> networkTypes})
Factory constructor for network available but no internet
factory
ConnectivityState.noConnection()
Factory constructor for no connection state
factory

Properties

connectionSpeed ConnectionSpeed
The estimated connection speed/quality
final
error String?
Any error that occurred during connectivity check
final
hashCode int
The hash code for this object.
no setterinherited
hasInternetAccess bool
Whether the device has actual internet access (can reach external servers)
final
hasNetworkButNoInternet bool
Whether the device has network but no internet access
no setter
hasNetworkConnection bool
Whether the device is connected to any network
final
isConnected bool
Whether the device has a usable internet connection
no setter
isEthernetConnection bool
Whether the connection is on Ethernet
no setter
isMeteredConnection bool
Whether the connection might be metered (mobile data)
no setter
isMobileConnection bool
Whether the connection is on a mobile network
no setter
isOffline bool
Whether the device is completely offline
no setter
isWiFiConnection bool
Whether the connection is on WiFi
no setter
lastChecked DateTime?
When this state was last updated
final
networkTypes List<ConnectivityResult>
The types of network connections currently available
final
primaryConnectionType → ConnectivityResult
The primary connection type
no setter
props List<Object?>
The list of properties that will be used to determine whether two instances are equal.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
stackTrace StackTrace?
The stack trace of the error
final
stringify bool?
If set to true, the toString method will be overridden to output this instance's props.
no setterinherited

Methods

copyWith({List<ConnectivityResult>? networkTypes, bool? hasNetworkConnection, bool? hasInternetAccess, ConnectionSpeed? connectionSpeed, DateTime? lastChecked, String? error}) ConnectivityState
Create a copy with updated values
fromJson(String json) ConnectivityState
Converts the object from a JSON string representation.
inherited
fromMap(Map<String, dynamic> map) ConnectivityState
Converts the object from a Map representation.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toJson() String
Converts the object to a JSON string representation.
inherited
toMap() Map<String, dynamic>
Converts the BaseDataModel object to a Map representation.
toString() String
A string representation of this object.
inherited

Operators

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