Skip to content

PalestineDevelopers/connection

Repository files navigation

palestine_connection

Lightweight internet connection test, lookup any domain/domainList.

License Pub Example

PUB GitHub release GitHub stars GitHub forks

Build Status

Table Of Contents

Features

  • Periodic internet connection tests
  • monitor domains
  • dispose

Getting started

To start, import package

import 'package:palestine_connection/palestine_connection.dart';

Usage

Just as easy as this

final PalConnection connection = PalConnection();
connection.initialize(
    domain: PalDomain.random, // Domain To Test On (optional)
    periodicInSeconds: 3, // 3 seconds
    onConnectionLost: () {
      // No Internet
    },
    onConnectionRestored: () {
      // Internet is back
    },
);

It could get more easier actually

PalConnection().initialize(
    periodicInSeconds: 3, // 3 seconds
    onConnectionLost: () {
      // No Internet
    },
    onConnectionRestored: () {
      // Internet is back
    },
);

Then you could dispose it

connection.dispose();

To monitor a list of domains Just as easy as this

final PalConnection connection = PalConnection();
connection.initializeMulti(
    domains: [PalDomain.random, PalDomain.random, 'bad.do.main'],
    periodicInSeconds: 3,
    onConnectionLost: (domain) {
        // domain is down
    },
    onConnectionRestored: (domain) {
        // domain is now up
    },
);

Contributors

Contributors