fix: correct super_clipboard getFile API call signature
getFile requires two positional args: format and callback. Wrapped in Completer for async/await usage. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
5f28605e13
commit
cfc0a97da7
|
|
@ -1,3 +1,4 @@
|
||||||
|
import 'dart:async';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
@ -209,20 +210,27 @@ class _ChatPageState extends ConsumerState<ChatPage> {
|
||||||
// Try PNG first, then JPEG
|
// Try PNG first, then JPEG
|
||||||
for (final format in [Formats.png, Formats.jpeg]) {
|
for (final format in [Formats.png, Formats.jpeg]) {
|
||||||
if (item.canProvide(format)) {
|
if (item.canProvide(format)) {
|
||||||
final completer = item.getFile(format);
|
final completer = Completer<List<int>>();
|
||||||
if (completer != null) {
|
item.getFile(format, (file) async {
|
||||||
final file = await completer;
|
try {
|
||||||
final bytes = await file.readAll();
|
final bytes = await file.readAll();
|
||||||
final mediaType = format == Formats.png ? 'image/png' : 'image/jpeg';
|
completer.complete(bytes);
|
||||||
setState(() {
|
} catch (e) {
|
||||||
_pendingAttachments.add(ChatAttachment(
|
completer.completeError(e);
|
||||||
base64Data: base64Encode(bytes),
|
}
|
||||||
mediaType: mediaType,
|
}, onError: (e) {
|
||||||
fileName: 'clipboard.${format == Formats.png ? "png" : "jpg"}',
|
if (!completer.isCompleted) completer.completeError(e);
|
||||||
));
|
});
|
||||||
});
|
final bytes = await completer.future;
|
||||||
return;
|
final mediaType = format == Formats.png ? 'image/png' : 'image/jpeg';
|
||||||
}
|
setState(() {
|
||||||
|
_pendingAttachments.add(ChatAttachment(
|
||||||
|
base64Data: base64Encode(bytes),
|
||||||
|
mediaType: mediaType,
|
||||||
|
fileName: 'clipboard.${format == Formats.png ? "png" : "jpg"}',
|
||||||
|
));
|
||||||
|
});
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue