ganki 1.0.0 copy "ganki: ^1.0.0" to clipboard
ganki: ^1.0.0 copied to clipboard

A Dart library to programmatically create and manage Anki decks (.apkg). Compatible with Dart CLI and Flutter (mobile & desktop).

example/example.dart

import 'package:ganki/ganki.dart';

void createDeck() async {
  // 1. Criar o Deck
  final deck = Deck(deckId: 20231121, name: "Meu Deck Flutter");

  // 2. Adicionar Notas
  deck.addNote(Note(
    model: basicModel,
    fields: ["O que é Flutter?", "Um framework UI do Google."],
  ));

  deck.addNote(Note(
    model: basicModel,
    fields: ["Qual linguagem usa?", "Dart"],
  ));

  // 3. Se tiver imagens (carregadas de assets ou rede)
  // final imageBytes = await rootBundle.load('assets/logo.png');
  // final media = [
  //    AnkiMedia(name: "logo.png", data: imageBytes.buffer.asUint8List())
  // ];

  // 4. Gerar o Pacote
  final ankiPackage =
      AnkiPackage(deck: deck); // adicione mediaFiles: media se houver

  try {
    final apkgBytes = await ankiPackage.generateBytes();

    // 5. Salvar
    // Opção A: Flutter Universal (usando package file_saver)
    // await FileSaver.instance.saveFile(
    //   name: 'meu_deck',
    //   ext: 'apkg',
    //   bytes: apkgBytes,
    // );

    // Opção B: Apenas Mobile/Desktop (dart:io)
    // final file = File('meu_deck.apkg');
    // await file.writeAsBytes(apkgBytes);

    print("Sucesso! Tamanho: ${apkgBytes.length} bytes");
  } catch (e) {
    print("Erro: $e");
  }
}
1
likes
140
points
38
downloads

Documentation

Documentation
API reference

Publisher

unverified uploader

Weekly Downloads

A Dart library to programmatically create and manage Anki decks (.apkg). Compatible with Dart CLI and Flutter (mobile & desktop).

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

archive, crypto, mustache_template, path, sqlite3

More

Packages that depend on ganki