halkyon/halkyon_learn_flutter/test/support/fake_file_saver.dart
Tizian 「ティツィアーン」 882b669c3e
feat(app): export a studyset as Markdown
Export content, in the studyset's options, writes the studyset and
everything inside it as one readable Markdown document (decided
2026-10-08: no re-importable archive before the public tier's release
files): its title, secondary title, description and licence, then its
flashcards (answers below their questions, choices as task lists),
notes, learning paths (steps with their kinds, answers, feedback and
sources), PDFs and bibliography, then each sub-studyset a level deeper.
Rich text keeps its formatting; formulas go between dollars, callouts
become quotes, spoilers HTML details, YouTube videos links. With files
(images, sounds, PDFs) it keeps a .zip of the document and them under
files/; a file this device can't have is named and counted.

Saving goes through a FileSaver: file_selector's dialog on the desktop,
file_picker's (Android's Storage Access Framework) on phones, a direct
dependency now at the version the editor already brings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MMm7usAo6q9ZZRoPkWjoxi
Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
2026-10-09 18:09:20 +02:00

26 lines
673 B
Dart

import 'dart:typed_data';
import 'package:halkyon_learn_flutter/src/core/files/file_saver.dart';
/// A [FileSaver] that keeps what it is given, unless [cancel] says the
/// person cancelled.
class FakeFileSaver() implements FileSaver {
/// Whether the next saves are cancelled.
bool cancel = false;
/// What was saved, in order.
final saved = <({String name, Uint8List bytes, String mimeType})>[];
@override
Future<bool> save({
required String name,
required Uint8List bytes,
required String mimeType,
}) async {
if (cancel) {
return false;
}
saved.add((name: name, bytes: bytes, mimeType: mimeType));
return true;
}
}