dart_ping_ios 4.0.2 copy "dart_ping_ios: ^4.0.2" to clipboard
dart_ping_ios: ^4.0.2 copied to clipboard

This package adds iOS support to the dart_ping package via plugin registration.

This package adds iOS support to the dart_ping package via registration.

The dart_ping package is required for use.

Created from templates made available by Stagehand under a BSD-style license.

Usage #

The key to using this package is to import it and call this method before you use dart_ping:

import 'package:dart_ping_ios/dart_ping_ios.dart';

void main() {
  // Register dart_ping_ios with dart_ping
  // You only need to call this once
  DartPingIOS.register();
}

You only need to call this once. I usually do this somewhere in my main method before my app runs.

Here is a simple but full example based on the Flutter counter app:

import 'package:dart_ping/dart_ping.dart';
import 'package:dart_ping_ios/dart_ping_ios.dart';
import 'package:flutter/material.dart';

void main() {
  // Register dart_ping_ios with dart_ping
  DartPingIOS.register();

  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'DartPing Flutter Demo',
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key? key}) : super(key: key);

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  // Create instance of DartPing
  Ping ping = Ping('google.com', count: 5);
  PingData? _lastPing;

  void _startPing() {
    ping.stream.listen((event) {
      setState(() {
        _lastPing = event;
      });
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('DartPing Flutter Demo'),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Text(
              _lastPing?.toString() ?? 'Push the button to begin ping',
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: _startPing,
        tooltip: 'Start Ping',
        child: Icon(Icons.radar_sharp),
      ), // This trailing comma makes auto-formatting nicer for build methods.
    );
  }
}

Features and bugs #

Please file feature requests and bugs at the issue tracker.

Credit #

This package contains code from flutter_icmp_ping by zuvola, used with permission.

9
likes
160
pub points
96%
popularity

Publisher

unverified uploader

This package adds iOS support to the dart_ping package via plugin registration.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

dart_ping, flutter, flutter_icmp_ping

More

Packages that depend on dart_ping_ios