cynic 0.2.0

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 50

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');
  }
}

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

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or packages 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';
        
Version Uploaded Documentation Archive
0.2.0 Jun 11, 2017 Go to the documentation of cynic 0.2.0 Download cynic 0.2.0 archive
0.1.1 May 29, 2017 Go to the documentation of cynic 0.1.1 Download cynic 0.1.1 archive
0.1.0 May 27, 2017 Go to the documentation of cynic 0.1.0 Download cynic 0.1.0 archive

Analysis

This feature is new.
We welcome feedback.
More details: scoring.

We analyzed this package, and provided a score, details, and suggestions below.

  • completed on Feb 3, 2018
  • Dart: 2.0.0-dev.20.0
  • pana: 0.10.1

Scores

Popularity:
Describes how popular the package is relative to other packages. [more]
0 / 100
Health:
Code health derived from static analysis. [more]
99 / 100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100 / 100
Overall score:
Weighted score of the above. [more]
50

Platforms

Detected platforms: Flutter, other

Primary library: package:cynic/cynic.dart with components: io.

Suggestions

  • The description is too short.

    Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

  • Package is pre-v1 release.

    While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.22.0 <2.0.0
meta ^1.0.5 1.1.2
Dev dependencies
test