Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion melos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ command:
# upper bounds once FlutterFire ships a fixed release.
firebase_crashlytics: '>=5.2.0 <5.2.5'
firebase_messaging: '>=16.0.0 <16.4.2'
file_picker: ^11.0.0
file_picker: '>=12.0.0 <14.0.0'
file_selector: ^1.1.0
app_badge_plus: ^1.3.2
flutter_local_notifications: ^21.0.0
Expand Down
8 changes: 8 additions & 0 deletions packages/stream_chat_flutter/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## Upcoming

🛑️ Breaking

- `PlatformFileX.toAttachmentFile` and `PlatformFileX.toAttachment` are now asynchronous, returning `Future<AttachmentFile>` and `Future<Attachment>`. `file_picker` 12 removed `PlatformFile`'s eagerly-loaded `bytes` and `size` getters, so the content is read on demand; this matches the existing `XFileX` extensions. Any `PlatformFile` you hold came from `FilePicker.pickFiles()`, whose return type also changed in `file_picker` 12, so that call site needs rewriting anyway and the added `await` goes in the same edit.

✅ Added

- Added `StreamMessageItem.semanticsLabel`, which replaces the announcement composed for a message row, and `StreamMessageItem.excludeFromSemantics`, which leaves the row unlabeled so the bubble and footer announce their own parts.
Expand All @@ -8,6 +12,9 @@

⚠️ Changed

- Bumped `file_picker` to `>=12.0.0 <14.0.0`.
- Deprecated `withData` and `withReadStream` on `StreamAttachmentHandler.pickFile` and `StreamFilePicker`. Content is now read on demand, so both are ignored.
- Android apps built from a Flutter template older than 3.44 must add `subprojects { project.evaluationDependsOn(":app") }` to their root `android/build.gradle`. Without it the build fails with `cannot find symbol: class FilePickerPlugin`, an error that says nothing about its cause.
- Video thumbnails now use `stream_thumbnail` on every platform, and the `thumblr`
dependency is gone.
- Linux builds now need the FFmpeg and libwebp development packages — on Debian/Ubuntu:
Expand All @@ -17,6 +24,7 @@

🐞 Fixed

- Fixed `StreamAttachmentHandler.pickFile` throwing when the picker returned an empty selection: it took `.files.first` unconditionally. It now returns `null`.
- Fixed `StreamAttachmentHandler` throwing `UnimplementedError` on WebAssembly builds.
- Improved the screen-reader experience in the message list: each message is announced as a single phrase naming the sender, the body, the time, the edited marker and the delivery status, while the attachments, reaction chips, quoted message and replies row stay reachable one level deeper.
- Fixed the message body being announced as its markdown source, so link and emphasis syntax is no longer read aloud.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ abstract class StreamAttachmentHandlerBase {
List<String>? allowedExtensions,
Function(FilePickerStatus)? onFileLoading,
int compressionQuality = 0,
bool withData = true,
bool withReadStream = false,
@Deprecated('Content is read on demand; this no longer has any effect.') bool withData = true,
@Deprecated('Content is read on demand; this no longer has any effect.') bool withReadStream = false,
bool lockParentWindow = true,
}) {
throw UnimplementedError('pickFile is not implemented');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,22 @@ class StreamAttachmentHandler extends StreamAttachmentHandlerBase {
List<String>? allowedExtensions,
Function(FilePickerStatus)? onFileLoading,
int compressionQuality = 0,
bool withData = true,
bool withReadStream = false,
@Deprecated('Content is read on demand; this no longer has any effect.') bool withData = true,
@Deprecated('Content is read on demand; this no longer has any effect.') bool withReadStream = false,
bool lockParentWindow = true,
}) async {
final result = await FilePicker.pickFiles(
final result = await FilePicker.pickFile(
dialogTitle: dialogTitle,
initialDirectory: initialDirectory,
type: type,
allowedExtensions: allowedExtensions,
onFileLoading: onFileLoading,
compressionQuality: compressionQuality,
withData: withData,
withReadStream: withReadStream,
lockParentWindow: lockParentWindow,
windowsOptions: WindowsOptions(lockParentWindow: lockParentWindow),
linuxOptions: LinuxOptions(lockParentWindow: lockParentWindow),
);

return result?.files.first.toAttachment(type: type.toAttachmentType());
return await result?.toAttachment(type: type.toAttachmentType());
}

@override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,23 +131,22 @@ class StreamAttachmentHandler extends StreamAttachmentHandlerBase {
List<String>? allowedExtensions,
Function(FilePickerStatus)? onFileLoading,
int compressionQuality = 0,
bool withData = true,
bool withReadStream = false,
@Deprecated('Content is read on demand; this no longer has any effect.') bool withData = true,
@Deprecated('Content is read on demand; this no longer has any effect.') bool withReadStream = false,
bool lockParentWindow = true,
}) async {
final result = await FilePicker.pickFiles(
final result = await FilePicker.pickFile(
dialogTitle: dialogTitle,
initialDirectory: initialDirectory,
type: type,
allowedExtensions: allowedExtensions,
onFileLoading: onFileLoading,
compressionQuality: compressionQuality,
withData: withData,
withReadStream: withReadStream,
lockParentWindow: lockParentWindow,
windowsOptions: WindowsOptions(lockParentWindow: lockParentWindow),
linuxOptions: LinuxOptions(lockParentWindow: lockParentWindow),
);
Comment thread
coderabbitai[bot] marked this conversation as resolved.

return result?.files.first.toAttachment(type: type.toAttachmentType());
return await result?.toAttachment(type: type.toAttachmentType());
}

@override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ class StreamFilePicker extends StatelessWidget {
this.allowedExtensions,
this.onFileLoading,
this.compressionQuality = 0,
this.withData = false,
this.withReadStream = false,
@Deprecated('Content is read on demand; this no longer has any effect.') this.withData = false,
@Deprecated('Content is read on demand; this no longer has any effect.') this.withReadStream = false,
this.lockParentWindow = false,
});

Expand All @@ -46,9 +46,11 @@ class StreamFilePicker extends StatelessWidget {
final int compressionQuality;

/// Whether to include the file data in the [Attachment].
@Deprecated('Content is read on demand; this no longer has any effect.')
final bool withData;

/// Whether to include the file read stream in the [Attachment].
@Deprecated('Content is read on demand; this no longer has any effect.')
final bool withReadStream;

/// Whether to lock the parent window when the file picker is open.
Expand All @@ -69,8 +71,6 @@ class StreamFilePicker extends StatelessWidget {
allowedExtensions: allowedExtensions,
onFileLoading: onFileLoading,
compressionQuality: compressionQuality,
withData: withData,
withReadStream: withReadStream,
lockParentWindow: lockParentWindow,
);
});
Expand Down
11 changes: 7 additions & 4 deletions packages/stream_chat_flutter/lib/src/utils/extensions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -116,19 +116,22 @@ extension IterableExtension<T> on Iterable<T> {
/// Useful extension for [PlatformFile]
extension PlatformFileX on PlatformFile {
/// Converts the [PlatformFile] into [AttachmentFile]
AttachmentFile get toAttachmentFile {
///
/// Reads the file content on demand, so the result is asynchronous.
Future<AttachmentFile> get toAttachmentFile async {
final bytes = await readAsBytes();
return AttachmentFile(
// Path is not supported on web.
path: CurrentPlatform.isWeb ? null : path,
name: name,
size: bytes.length,
bytes: bytes,
size: size,
);
}

/// Converts the [PlatformFile] to a [Attachment].
Attachment toAttachment({required String type}) {
final file = toAttachmentFile;
Future<Attachment> toAttachment({required String type}) async {
Comment thread
bitgandtter marked this conversation as resolved.
final file = await toAttachmentFile;
final extraDataMap = <String, Object>{};

final mimeType = file.mediaType?.mimeType;
Expand Down
2 changes: 1 addition & 1 deletion packages/stream_chat_flutter/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ dependencies:
diacritic: ^0.1.6
dio: ^5.11.0
ezanimation: ^0.6.0
file_picker: ^11.0.0
Comment thread
bitgandtter marked this conversation as resolved.
file_picker: '>=12.0.0 <14.0.0'
file_selector: ^1.1.0
flutter:
sdk: flutter
Expand Down
11 changes: 11 additions & 0 deletions sample_app/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,17 @@ subprojects {

}

// Plugin projects evaluate before `:app` by default, but the Flutter Gradle
// plugin only registers the `flutter` extension on them while `:app` is being
// configured. A plugin whose build script reads that extension at configuration
// time — android_file_picker, pulled in by file_picker 12 — fails without this.
// Present in the current Flutter app template; this module predates it. Kept in
// its own block, after the one above: forcing evaluation from inside that block
// would run `:app` before its `afterEvaluate` is registered.
subprojects {
project.evaluationDependsOn(":app")
}

tasks.register("clean", Delete) {
delete rootProject.layout.buildDirectory
}
Loading