Closed JamesSwag closed 4 years ago
did u try setState?
** onPressed: () {
_streamRanging.cancel();
setState(() {
regions.removeLast();
regions.add(Region(
identifier: null,
proximityUUID: '98173b7d-2444-424a-bed9-7acf4bf97a50'));
_streamRanging = flutterBeacon
.ranging(regions)
.listen((RangingResult result) {
print(result.region);
});
});
},**
or
_streamRanging.cancel();
final newRegions = <Region>[
Region(
identifier: null,
proximityUUID: '98173b7d-2444-424a-bed9-7acf4bf97a50'),
];
_streamRanging = flutterBeacon
.ranging(newRegions)
.listen((RangingResult result) {
print(result.region);
});
setState(() {
regions = newRegions;
});
Let me test it out then I will get back to you
No unfortunately it does not work.
@JamesSwag
sorry, im wrong. flutterBeacon is caching FlutterEventChannel
stream in flutterBeacon instance.
https://github.com/alann-maulana/flutter_beacon/blob/master/lib/flutter_beacon.dart#L137
I don't have any plan that fix this issue, cuz im not owner this plugin. One of user XD But, you can fork this repository and fix these files if you need it.
pubspec.yml
flutter_beacon:
git:
url: git@github.com:[your account]/flutter_beacon.git
flutter_beacon.dart
Stream<RangingResult> ranging(List<Region> regions) {
- if (_onRanging == null) {
final list = regions.map((region) => region.toJson).toList();
_onRanging = _rangingChannel
.receiveBroadcastStream(list)
.map((dynamic event) => RangingResult.from(event));
- }
return _onRanging;
}
I don't know anything about the inner workings of the plugin, so I wouldn't even know where to start. However does the plugin work for you? Are you able to stream for new uuids?
This plugin can't restart different uuid. but you can fork and fix code. Try change it yourself.
But I don't know how to.
Hello,
Sorry a lot of busy lately on my office projects 😁
I have been solving this "caching FlutterEventChannel
" for both ranging and monitoring some days ago. I hope I can commit and push it soon
Hello, I seem to have a problem where I can't range new regions with new uuids. It ranges only for the initial uuid I set. I have tried canceling the stream then adding a new region to the list then subscribing again however it does not work and it only reacts to the initial uuid. I have my code below. As you can see the ranging method starts the stream. Then in the onPressed property of the second button I first Cancel the stream then remove the first uuid region and then add a new region before starting the stream again.