NearbyService class

Constructors

NearbyService()

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

dataReceivedSubscription({required DataReceivedCallback callback}) StreamSubscription
The dataReceivedSubscription helps you listen when a peer sends you text messages. and it returns you a object Data. It returns a StreamSubscription so you can cancel listening at any time. see DataReceivedCallback
disconnectPeer({required String? deviceID}) FutureOr
Disconnects the local peer from the session. the deviceID is current Device
init({required String serviceType, required Strategy strategy, String? deviceName, required Function callback}) Future
The class NearbyService supports the discovery of services provided by nearby devices and supports communicating with those services through message-based data, streaming data, and resources (such as files). In iOS, the framework uses infrastructure Wi-Fi networks, peer-to-peer Wi-Fi, and Bluetooth personal area networks for the underlying transport. param serviceType max length 15 character, need to be defined in Info.plist
invitePeer({required String deviceID, String? deviceName}) FutureOr
Invites a discovered peer to join a nearby connections session. the deviceID is current Device
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
sendMessage(String deviceID, String message) FutureOr
Sends a message encapsulated in a Data instance to nearby peers.
startAdvertisingPeer() FutureOr
Begins advertising the service provided by a local peer. The startAdvertisingPeer publishes an advertisement for a specific service that your app provides through the flutter_nearby_connections plugin and notifies its delegate about invitations from nearby peers.
startBrowsingForPeers() FutureOr
Starts browsing for peers. Searches (by serviceType) for services offered by nearby devices using infrastructure Wi-Fi, peer-to-peer Wi-Fi, and Bluetooth or Ethernet, and provides the ability to easily invite those Device to a earby connections session SessionState.
stateChangedSubscription({required StateChangedCallback callback}) StreamSubscription
stateChangedSubscription helps you listen to the changes of peers with the circumstances: find a new peer, a peer is invited, a peer is disconnected, a peer is invited to connect by another peer, or 2 peers are connected. stateChangedSubscription will return you a list of Device. see StateChangedCallback
stopAdvertisingPeer() FutureOr
Stops advertising this peer device for connection.
stopBrowsingForPeers() FutureOr
Stops browsing for peers.
toString() String
A string representation of this object.
inherited

Operators

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