Croppable post image

This commit is contained in:
2024-11-11 21:48:50 +08:00
parent f23ffe61f5
commit b166a6e85c
8 changed files with 185 additions and 94 deletions

View File

@ -1,4 +1,5 @@
import 'dart:collection';
import 'dart:math' as math;
import 'dart:typed_data';
import 'package:dio/dio.dart';
@ -165,7 +166,10 @@ class SnAttachmentProvider {
for (final entry in chunks.entries) {
queue.add(() async {
final beginCursor = entry.value * chunkSize;
final endCursor = (entry.value + 1) * chunkSize;
final endCursor = math.min<int>(
(entry.value + 1) * chunkSize,
await file.length(),
);
final data = Uint8List.fromList(await file
.openRead(beginCursor, endCursor)
.expand((chunk) => chunk)