optimized avatar and linkify performance, refined navigation to preserve popups, implemented read marker caching, and added file size limits for saving, minor timetable details changes
This commit is contained in:
@@ -254,7 +254,26 @@ class _FileViewerState extends State<FileViewer> {
|
||||
break;
|
||||
case FileViewingActions.save:
|
||||
try {
|
||||
final bytes = await File(widget.path).readAsBytes();
|
||||
final source = File(widget.path);
|
||||
final size = await source.length();
|
||||
// Hard-cap to avoid loading the entire file into memory just to
|
||||
// hand it back to the platform's saveFile dialog. The package
|
||||
// currently has no streaming/path-based save path, so for big
|
||||
// media the user has to fall back to "Teilen" → save-to-files.
|
||||
// 200 MB peak is comfortable on modern mid-range devices and big
|
||||
// enough for typical school videos.
|
||||
const maxBytes = 200 * 1024 * 1024; // 200 MB
|
||||
if (size > maxBytes) {
|
||||
if (!mounted) return;
|
||||
InfoDialog.show(
|
||||
context,
|
||||
'Diese Datei ist zu groß (${(size / (1024 * 1024)).toStringAsFixed(0)} MB), '
|
||||
'um direkt gespeichert zu werden. Nutze stattdessen die Teilen-Funktion.',
|
||||
title: 'Speichern nicht möglich',
|
||||
);
|
||||
return;
|
||||
}
|
||||
final bytes = await source.readAsBytes();
|
||||
final saved = await FilePicker.saveFile(
|
||||
fileName: widget.path.split('/').last,
|
||||
bytes: bytes,
|
||||
|
||||
Reference in New Issue
Block a user