point-source / dart_ping

Multi-platform network ping utility for Dart
30 stars 13 forks source link

Support for non-stream single ping #39

Closed r3a1d3a1 closed 1 year ago

r3a1d3a1 commented 1 year ago

Hello,

It'd be great not to rely on a stream if one needs to do a single Ping.

Thank you!

point-source commented 1 year ago

You can just grab the first ping like this:

import 'package:dart_ping/dart_ping.dart';

void main() async {
  // Create ping object with desired args
  final ping = Ping('google.com', count: 1);
  final result = await ping.stream.first;
}

Even shorter: final result = await Ping('google.com', count: 1).stream.first;

r3a1d3a1 commented 1 year ago

That's good enough for me; Thank you!

point-source commented 1 year ago

I've added this to the documentation for the future. Thanks

r3a1d3a1 commented 1 year ago

Excellent 👍