{"id":21593789,"url":"https://github.com/protoss78/nearby_connections","last_synced_at":"2026-05-19T11:09:43.328Z","repository":{"id":90318415,"uuid":"212992700","full_name":"Protoss78/nearby_connections","owner":"Protoss78","description":"A Flutter plugin for the Nearby Connections API","archived":false,"fork":false,"pushed_at":"2019-10-06T09:51:47.000Z","size":133,"stargazers_count":3,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-24T17:13:48.175Z","etag":null,"topics":["connections","flutter","nearby"],"latest_commit_sha":null,"homepage":null,"language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Protoss78.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-10-05T12:07:03.000Z","updated_at":"2022-10-27T03:35:33.000Z","dependencies_parsed_at":null,"dependency_job_id":"0b6b6b00-44b6-4789-af65-f7c455981d9b","html_url":"https://github.com/Protoss78/nearby_connections","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Protoss78%2Fnearby_connections","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Protoss78%2Fnearby_connections/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Protoss78%2Fnearby_connections/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Protoss78%2Fnearby_connections/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Protoss78","download_url":"https://codeload.github.com/Protoss78/nearby_connections/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244206694,"owners_count":20416086,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["connections","flutter","nearby"],"created_at":"2024-11-24T17:14:43.131Z","updated_at":"2026-05-19T11:09:43.273Z","avatar_url":"https://github.com/Protoss78.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"# nearby_connections\n\nA Flutter plugin for the Nearby Connections API. Inspired and partially forked from [nearby-connectivity](https://github.com/jozews/nearby-connectivity). \n\nIMPORTANT:\n- Only Android side is implemented so far.\n- Any help regarding an iOS adaptation would be very much appreciated.\n- Also FILE and STREAM payloads are not supported yet. Only BYTE payloads can be exchanged at the moment.\n\n## Getting Started\n\n### Import package\n```dart\nimport 'package:nearby_connections/nearby_connections.dart';\n```\n\n### Start advertising\n```dart\nNearbyConnections.startAdvertising(strategy: Strategy.P2P_CLUSTER, name: myName, idService: MY_SERVICE_ID);\n```\n\n### Listen for connection requests and auto accept them\n```dart\nNearbyConnections.getConnectionLifecycleStream().listen((connection) { \n  switch (advertise.type) {\n    case TypeLifecycle.initiated:\n      // accept connection here\n      NearbyConnections.acceptConnection(connection.lifecycle.idEndpoint);\n      break;\n    case TypeLifecycle.result:\n      break;\n    case TypeLifecycle.disconnected:\n      // you are now disconnected\n      break;\n  }\n});\nNearbyConnections.startAdvertising(strategy: Strategy.P2P_CLUSTER, name: myName, idService: MY_SERVICE_ID);\n```\n\n### Start discovery\n```dart\nNearbyConnections.startDiscovery(strategy: Strategy.P2P_CLUSTER, idService: MY_SERVICE_ID);\n```\n\n### Listen for discovered connections\n```dart\nNearbyConnections.getDiscoveryStream().listen((discovery) { \n  if (discovery.type == TypeDiscovery.found) {\n    // New advertiser discovered\n  } else if (discovery.type == TypeDiscovery.lost) {\n    // Advertised connection was lost\n  }\n});\n\n```\n\n### Reject a connection\n```dart\nNearbyConnections.rejectConnection(endpointId);\n```\n\n### Send a payload to a single endpoint\n```dart\nconst Utf8Encoder encoder = Utf8Encoder();\nNearbyConnections.sendPayloads(receiverEndpointId, encoder.convert(value.toString()));\n```\n\n### Send a payload to multiple endpoints\n```dart\nconst Utf8Encoder encoder = Utf8Encoder();\nNearbyConnections.sendPayloads(receiverEndpointIdList, encoder.convert(value.toString()));\n```\n\n### Handle incoming payloads\n```dart\nconst Utf8Decoder decoder = Utf8Decoder();\nNearbyConnections.getPayloadStream().listen((payload) {\n  String textValue = decoder.convert(payload.bytes);\n});\n```\n\n\n### Stop advertising\n```dart\nNearbyConnections.stopAdvertising();\n```\n\n\n### Stop discovery\n```dart\nNearbyConnections.stopDiscovery();\n```\n\n\n### Disconnect a single endpoint\n```dart\nNearbyConnections.disconnectFromEndpoint(endpointId);\n```\n\n### Stop all connections\n```dart\nNearbyConnections.stopAllEndpoints();\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprotoss78%2Fnearby_connections","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprotoss78%2Fnearby_connections","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprotoss78%2Fnearby_connections/lists"}