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:io';
|
||||
import 'package:flutter/material.dart';
|
||||
|
|
@ -209,10 +210,18 @@ class _ChatPageState extends ConsumerState<ChatPage> {
|
|||
// Try PNG first, then JPEG
|
||||
for (final format in [Formats.png, Formats.jpeg]) {
|
||||
if (item.canProvide(format)) {
|
||||
final completer = item.getFile(format);
|
||||
if (completer != null) {
|
||||
final file = await completer;
|
||||
final completer = Completer<List<int>>();
|
||||
item.getFile(format, (file) async {
|
||||
try {
|
||||
final bytes = await file.readAll();
|
||||
completer.complete(bytes);
|
||||
} catch (e) {
|
||||
completer.completeError(e);
|
||||
}
|
||||
}, onError: (e) {
|
||||
if (!completer.isCompleted) completer.completeError(e);
|
||||
});
|
||||
final bytes = await completer.future;
|
||||
final mediaType = format == Formats.png ? 'image/png' : 'image/jpeg';
|
||||
setState(() {
|
||||
_pendingAttachments.add(ChatAttachment(
|
||||
|
|
@ -225,7 +234,6 @@ class _ChatPageState extends ConsumerState<ChatPage> {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
// Clipboard read failed
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue