dolphinsr 4.0.0 copy "dolphinsr: ^4.0.0" to clipboard
dolphinsr: ^4.0.0 copied to clipboard

A spaced-repetition scheduling algorithm for Dart, based on Anki's SM-2 variant. Build flashcard and review systems for Flutter, web, or server.

pub package CI License: MIT

dolphinsr #

A spaced-repetition scheduling algorithm for Dart. Use it to build flashcard and review systems — for Flutter, the web, or the server — that decide which card to show next and when.

dolphinsr began as yodaiken's JavaScript spaced-repetition library and was ported to Dart by JobiJoba. This fork picks up that work — published to pub.flutter-io.cn under the shorter name dolphinsr — with the correctness and performance fixes described in the changelog. It is maintained on a best-effort basis, and issues and pull requests are welcome.

Algorithm #

DolphinSR implements spaced repetition in Dart. Specifically, it uses Anki's modifications to the SM-2 algorithm, including:

  • an initial mode for learning new cards
  • a mode for re-learning cards after forgetting them
  • reducing the number of self-assigned ratings from 6 to 4
  • factoring lateness into card scheduling
  • Anki's default configuration options

While DolphinSR is intentionally very similar to Anki's algorithm, it does deviate in a few ways:

  • improved support for adding reviews out of order (for example, due to network latency)
  • very different internal data structures (DolphinSR is largely written in a functional style to make testing and debugging easier, and does not rely on storing computed data or any SQL database)
  • only one kind of card

Installation #

dart pub add dolphinsr

Or add it to your pubspec.yaml manually:

dependencies:
  dolphinsr: ^4.0.0

Quick start #

import 'package:dolphinsr/dolphinsr.dart';

void main() {
  final dolphin = DolphinSR();

  // Register your cards. Each master has fields and one or more
  // combinations describing which fields are the front and which are the
  // back (here, both directions of a two-sided card).
  dolphin.addMasters([
    Master(id: '1', fields: ['คน', 'person'], combinations: [
      Combination(front: [0], back: [1]),
      Combination(front: [1], back: [0]),
    ]),
  ]);

  // A summary of how many cards are due / later / learning / overdue.
  final stats = dolphin.summary();
  print('${stats.due}-${stats.later}-${stats.learning}-${stats.overdue}');

  // Pull the next card to show, present it, then record how it went.
  final card = dolphin.nextCard()!;
  print('${card.front} -> ${card.back}');

  dolphin.addReviews([
    Review(
      master: card.master,
      combination: card.combination,
      ts: DateTime.now(),
      rating: Rating.Good, // Again, Hard, Good, or Easy
    ),
  ]);
}

See example/main.dart for a fuller run through a review session.

License #

MIT. Copyright (c) 2019 Baziret Johann and (c) 2026 Daniel Porteous.

0
likes
150
points
90
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A spaced-repetition scheduling algorithm for Dart, based on Anki's SM-2 variant. Build flashcard and review systems for Flutter, web, or server.

Repository (GitHub)
View/report issues

Topics

#spaced-repetition #flashcards #anki #srs

License

MIT (license)

Dependencies

equatable

More

Packages that depend on dolphinsr