Skip to content

Commit

Permalink
Update version to 1.0.8
Browse files Browse the repository at this point in the history
  • Loading branch information
vietdq2701 committed Nov 25, 2020
1 parent 76e285c commit 4b33738
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.0.8

* fix issue on iOS

## 1.0.7

* update readme
Expand Down
22 changes: 16 additions & 6 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'dart:io';
import 'package:device_info/device_info.dart';
import 'package:flutter/material.dart';
import 'package:flutter_nearby_connections/flutter_nearby_connections.dart';
import 'package:flutter_udid/flutter_udid.dart';
import 'package:fluttertoast/fluttertoast.dart';

void main() {
Expand Down Expand Up @@ -105,6 +106,10 @@ Future<String> _getId() async {
}
}

Future<String> _getDeviceID() async {
return await FlutterUdid.udid;
}

class _DevicesListScreenState extends State<DevicesListScreen> {
List<Device> devices = [];
List<Device> connectedDevices = [];
Expand Down Expand Up @@ -294,11 +299,12 @@ class _DevicesListScreenState extends State<DevicesListScreen> {
}

void init() async {
String deviceId = await _getId();
nearbyService = NearbyService();
await nearbyService.init(
serviceType: 'mp-connection',
strategy: Strategy.P2P_CLUSTER,
callback: (isRunning) async{
callback: (isRunning) async {
if (isRunning) {
if (widget.deviceType == DeviceType.browser) {
await nearbyService.stopBrowsingForPeers();
Expand All @@ -315,14 +321,18 @@ class _DevicesListScreenState extends State<DevicesListScreen> {
subscription =
nearbyService.stateChangedSubscription(callback: (devicesList) {
devicesList?.forEach((element) {
if(element.state == SessionState.connected){
nearbyService.stopBrowsingForPeers();
}else{
nearbyService.startBrowsingForPeers();
}
print(
" deviceId: ${element.deviceId} | deviceName: ${element.deviceName} | state: ${element.state}");

if (Platform.isAndroid) {
if (element.state == SessionState.connected) {
nearbyService.stopBrowsingForPeers();
} else {
nearbyService.startBrowsingForPeers();
}
}
});

setState(() {
devices.clear();
devices.addAll(devicesList);
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: flutter_nearby_connections
description: Flutter plugin supports peer-to-peer connectivity and discovers nearby devices for Android and IOS
version: 1.0.7
version: 1.0.8
author: [email protected]
homepage: https://github.com/VNAPNIC/flutter_nearby_connections

Expand Down

0 comments on commit 4b33738

Please sign in to comment.