I have created two dropdown boxes one selects game and other servers. image of app
All i want to do is to know if there is a way to ping a server and get the latency, probably something like this in dart/flutter.
Edit: just installed the dart_ping lib and ran this code.
void main() {
runApp(const MyApp());
pingIt();
}
void pingIt() {
var ping = Ping('google.com', count: 5);
print('Running command: ${ping.command}');
ping.stream.listen((event) {
print("response : $event");
});
print("$ping");
}
It runs without any error, but the console says there are no responses from the server.
I/flutter (13831): Running command: ping -O -n -W 2 -i 1 -t 255 -c 5 google.com
I/flutter (13831): Instance of 'PingLinux'.
I/flutter (13831): response : PingError(response:PingResponse(seq:1), error:RequestTimedOut)
I/flutter (13831): response : PingError(response:PingResponse(seq:2), error:RequestTimedOut)
I/flutter (13831): response : PingError(response:PingResponse(seq:3), error:RequestTimedOut)
I/flutter (13831): response : PingError(response:PingResponse(seq:4), error:RequestTimedOut)
I/flutter (13831): response : PingSummary(transmitted:5, received:0), time: 4102 ms, Errors: [RequestTimedOut, RequestTimedOut, RequestTimedOut, RequestTimedOut, NoReply]
So what should i do now and how can i know how many responses were received and how many were lost. How do i actually get ping does the lib contain a method that returns the ping or is there another way to do so.
By the way, I'm testing it in an android emulator.