akismet 4.1.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 50

Akismet for Dart #

Runtime Release License Coverage Build

Prevent comment spam using the Akismet service, in Dart.

Documentation #

Development #

License #

Akismet for Dart is distributed under the MIT License.

Changelog #

Version 4.1.0 #

  • Updated the documentation.
  • Updated the package dependencies.

Version 4.0.1 #

  • Fixed the issue #1: the recheck_reason field is not sent.

Version 4.0.0 #

  • Breaking change: starting to use and support the Dart 2 SDK.
  • Added support for the X-akismet-pro-tip HTTP header.
  • Added the CheckResult enumeration.
  • Added the ClientException class.
  • Added the Comment.recheckReason property.
  • Added a user guide based on MkDocs.
  • Added an example code.
  • Using optional const and new.
  • Updated the package dependencies.

Version 3.2.0 #

  • Added support for browser platform.

Version 3.1.0 #

  • Updated the package dependencies.

Version 3.0.0 #

  • Breaking change: changed the signature of most class constructors.
  • Breaking change: most class properties are now final.
  • Breaking change: raised the required Dart version.
  • Breaking change: removed the toJson() and toString() methods from the Client class.
  • Breaking change: the version property is now private.
  • Added new values to the CommentType enumeration.
  • Changed licensing for the MIT License.
  • Updated the package dependencies.

Version 2.1.0 #

  • Updated the package dependencies.

Version 2.0.0 #

  • Breaking change: changed the signature of all constructors.
  • Breaking change: raised the required Dart version.
  • Breaking change: renamed the Client.serviceUrl constant to defaultEndPoint.
  • Added the Client.endPoint property.
  • Added the version constant.
  • Updated the package dependencies.

Version 1.0.0 #

  • Breaking change: changed the Blog.language string property for the languages list property.
  • Breaking change: dropped the dart:html client.
  • Breaking change: dropped the embedded server and the command line interface.
  • Breaking change: merged all the libraries (e.g. core, html and io) into the sole akismet one.
  • Breaking change: most of the constructors are now using optional named parameters.
  • Breaking change: removed the DEFAULT_SERVICE constant, serviceUrl property and queryService() method from the Client class.
  • Breaking change: removed the EndPoints and HttpHeaders enumerations.
  • Breaking change: removed the VERSION constant.
  • Breaking change: using lowercase for all constant names.
  • Added the Client.toJson() method.
  • Added the onRequest and onResponse event streams to the Client class.
  • The parameters of the Client constructor are now optional.
  • Added support for the Travis CI continuous integration.
  • Changed the build system for Grinder.
  • Changed the documentation system for Dartdoc.
  • Changed the licensing for the Apache License Version 2.0.
  • Dropped the development dependencies based on Node.js.
  • Removed the info suffix from the Dart version number in the Client.userAgent property.
  • Updated the package dependencies.

Version 0.6.1 #

  • Fixed bugs in async/await implementation.
  • Fixed bugs in JSON serialization.

Version 0.6.0 #

  • Added the role property to Author class.
  • Added the isTest property to Client class.
  • Added the date and postModified properties to Comment class.
  • Moved the Future API to async and await.

Version 0.5.1 #

Version 0.5.0 #

  • Breaking change: renamed Server.start() method to bind.
  • Added Server.bindSecure() method to support SSL protocol.
  • Updated the package dependencies.

Version 0.4.0 #

  • Moved most methods and properties of Client child classes to the base abstract class.
  • Added Blog class to support the latest Akismet APIs.
  • Added Server events: you can listen to onClose, onError, onListening and onRequest streams.
  • Added --silent option to server CLI.
  • Breaking change: renamed Server.stop() method to close.
  • Breaking change: renamed HTTPHeaders constants by using X_ as prefix.
  • Breaking change: removed Client.useSecureRequests property.

Version 0.3.2 #

  • Migrated build system and tools to ShellJS.
  • Migrated documentation comments to YUIDoc.
  • Using DocGen.js to generate the API reference.

Version 0.3.1 #

  • Added unit tests of the HTML client.
  • The Server class and CLI now use port 3000 as default.

Version 0.3.0 #

  • Removed obsolete build scripts (build.dart and tool/generate_docs.dart).

Version 0.2.1 #

  • Added new properties and methods to Server class.
  • Added utility scripts in tool folder.
  • Changed the package layout.
  • Breaking change: renamed Server.secureRequests property to useSecureRequests.

Version 0.2.0 #

  • Added client implementation based on dart:html.
  • Added server implementation used to proxy requests from HTML clients to Akismet service.
  • Breaking change: Uri in constructors can no longer be specified as String.
  • Breaking change: removed Client.encoding property.

Version 0.1.1 #

  • Added EndPoints class providing the URLs of the Akismet service end points.

Version 0.1.0 #

  • Initial release: client implementation based on dart:io.


// ignore_for_file: avoid_print
import 'package:akismet/akismet.dart';

/// Queries the Akismet service.
Future<void> main() async {
  try {
    final blog = Blog(Uri.https('www.yourblog.com', '/'), charset: 'UTF-8', languages: ['fr']);
    final client = Client('123YourAPIKey', blog);

    // Key verification.
    final isValid = await client.verifyKey();
    print(isValid ? 'The API key is valid.' : 'The API key is invalid.');

    // Comment check.
    final author = Author(
      'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0',
      email: 'john.doe@domain.com',
      name: 'John Doe',
      role: 'guest'

    final comment = Comment(
      content: 'The user comment',
      date: DateTime.now(),
      type: CommentType.contactForm

    final result = await client.checkComment(comment);
    print(result == CheckResult.isHam ? 'The comment is ham.' : 'The comment is spam.');

    // Submit spam / ham.
    await client.submitSpam(comment);
    print('Spam submitted.');

    await client.submitHam(comment);
    print('Ham submitted.');

  on Exception catch (err) {
    print('An error occurred: $err');
    if (err is ClientException) print('From: ${err.uri}');

Use this package as a library

1. Depend on it

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

  akismet: ^4.1.0

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter pub get

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

3. Import it

Now in your Dart code, you can use:

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

We analyzed this package on May 23, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.1
  • pana: 0.13.8-dev

Health suggestions

Fix lib/src/client.dart. (-1 points)

Analysis of lib/src/client.dart reported 2 hints:

line 94 col 9: DO use curly braces for all flow control structures.

line 96 col 9: DO use curly braces for all flow control structures.

Fix lib/src/comment.dart. (-0.50 points)

Analysis of lib/src/comment.dart reported 1 hint:

line 60 col 7: DO use curly braces for all flow control structures.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.0 <3.0.0
http ^0.12.0 0.12.1
json_annotation ^3.0.1 3.0.1
Transitive dependencies
charcode 1.1.3
collection 1.14.12
http_parser 3.1.4
meta 1.1.8
path 1.7.0
pedantic 1.9.0
source_span 1.7.0
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
Dev dependencies
build_runner ^1.8.1
build_test ^1.0.0
build_version ^2.0.1
coverage ^0.13.9
coveralls ^5.7.0
grinder ^0.8.4
json_serializable ^3.3.0
test ^1.14.2