Closed rainbowMehBerdaya closed 1 year ago
I guess its the time we work on network_tools_flutter package @guyluz11 . Since we cannot add dart_ping_ios in network_tools as a dependency
Cool, maybe there are some flutter-only packages that we can use to add new functionality to more stuff
Why can't you guys add dart_ping_ios
to the network_tools
package?
I tried running it with this code, and it worked, but I'm not sure if it's the most practical solution.
static Stream<ActiveHost> scanDevicesForSinglePort(
String subnet,
int port, {
int firstHostId = defaultFirstHostId,
int lastHostId = defaultLastHostId,
Duration timeout = const Duration(milliseconds: 2000),
ProgressCallback? progressCallback,
bool resultsInAddressAscendingOrder = true,
}) async* {
if (Platform.isIOS) {
DartPingIOS.register();
}
final int lastValidSubnet =
_validateAndGetLastValidSubnet(subnet, firstHostId, lastHostId);
final List<Future<ActiveHost?>> activeHostOpenPortList = [];
final StreamController<ActiveHost> activeHostsController =
StreamController<ActiveHost>();
for (int i = firstHostId; i <= lastValidSubnet; i++) {
final host = '$subnet.$i';
activeHostOpenPortList.add(
PortScanner.connectToPort(
address: host,
port: port,
timeout: timeout,
activeHostsController: activeHostsController,
),
);
}
if (!resultsInAddressAscendingOrder) {
yield* activeHostsController.stream;
}
int counter = firstHostId;
for (final Future<ActiveHost?> openPortActiveHostFuture
in activeHostOpenPortList) {
final ActiveHost? activeHost = await openPortActiveHostFuture;
if (activeHost != null) {
yield activeHost;
}
progressCallback?.call(
(counter - firstHostId) * 100 / (lastValidSubnet - firstHostId),
);
counter++;
}
}
dart_ping_ios
It looks like dart ping ios use flutter_icmp_ping as a dependency and it flutter only
One thing that is important to us is to keep this package support of dart native. In order to solve issues like yours we are thinking of opening a new package that supports only flutter use network_tools for most of the work and solves some of the problems that can only get resolved using a flutter package.
@rainbowMehBerdaya you add below code in your main class, it will work. Don't forget to add dart_ping_ios as dependency in your project until network_tools_flutter is published.
if (Platform.isIOS) {
DartPingIOS.register();
}
We stick to what @guyluz11 said
One thing that is important to us is to keep this package support of dart native.
Yes, I have already tried that and it's running well I have shared the code in my previous comment. Thank you.
Also, it's up to you guys if you want to close it. Cheers 🍻
We will keep this open to remind us in finishing network_tools_flutter package
@rainbowMehBerdaya network_tools_flutter package is now available for testing purpose - https://github.com/osociety/network_tools_flutter. Please try and give feedback by reopening this issue.
HostScanner.scanDevicesForSinglePort for iOS not working
From dependency documentation I think this should add this package
dart_ping_ios
as said in
dart_ping
docsThank you for the package!