cynic 0.2.0

cynic #

Utilities for offline-first development.

Warning: This is not an official Google or Dart project.

Usage #

This library works in Flutter and the standalone Dart VM.

dependencies:
  cynic: ^0.2.0

Determine online status #

import 'package:cynic/cynic.dart';

main() async {
  print('Connected: ${await isOnline()}');
}

Create and monitor a list of reachable services #

import 'package:cynic/cynic.dart';

final microServices = const [
  Reachable.googleDns, // 99.9% uptime helper
  const Reachable.ip('172.217.19.227', name: 'My API Server'),
];

final mirrors = const [
  const Reachable.ip('216.58.204.131', name: 'My CDN A'),
  const Reachable.ip('5.5.5.5', name: 'My CDN B'), // not online
];

main() async {
  var all = await Reachable.all(microServices);
  if (all) {
    print('All servers are online');
  }
  var any = await Reachable.any(mirrors);
  if (any) {
    print('At least one server is online');
  }
}

0.2.0 #

  • Rename Service to Reachable.
  • Expose the default service as Reachable.googleDns.
  • Added Reachable.any|all.

0.1.1 #

  • Added a Service class, that represents something online or offline:
final servers = const [
  const Service.ipAddress('256.257.258.1', name: 'Server A'),
  const Service.ipAddress('256.257.258.2', name: 'Server B'),
  const Service.ipAddress('256.257.258.3', name: 'Server C'),
];

main() async {
  print(await Service.allOnline(servers));
}

0.1.0 #

  • Initial commit with the isOnline() method:
import 'package:cynic/cynic.dart';

main() async {
  print('Connected: ${await isOnline()}');
}

example/main.dart

import 'dart:async';

import 'package:cynic/cynic.dart';

final microServices = const [
  Reachable.googleDns, // 99.9% uptime helper
  const Reachable.ip('172.217.19.227', name: 'My API Server'),
];

final mirrors = const [
  //const Reachable.ip('216.58.204.131', name: 'My CDN A'),
  const Reachable.ip('5.5.5.5', name: 'My CDN B'), // not online
];

Future<Null> main() async {
  final all = await Reachable.all(microServices);
  if (all) {
    print('All servers are online');
  }
  final any = await Reachable.any(mirrors);
  if (any) {
    print('At least one server is online');
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  cynic: ^0.2.0

2. Install it

You can install packages from the command line:

with pub:


$ pub get

Alternatively, your editor might support pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:cynic/cynic.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
--
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
--
Overall:
Weighted score of the above. [more]
0
Learn more about scoring.

The package version is not analyzed, because it does not support Dart 2. Until this is resolved, the package will receive a health and maintenance score of 0.

Analysis issues and suggestions

Support Dart 2 in pubspec.yaml.

The SDK constraint in pubspec.yaml doesn't allow the Dart 2.0.0 release. For information about upgrading it to be Dart 2 compatible, please see https://dart.dev/dart-2#migration.

Maintenance issues and suggestions

Make sure dartdoc successfully runs on your package's source files. (-10 points)

Dependencies were not resolved.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.22.0 <2.0.0

Admin