Skip to content

Commit 7e0395b

Browse files
xsahil03xclaude
andauthored
refactor(ui): replace thumblr with stream_thumbnail on desktop (#2948)
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 37ea912 commit 7e0395b

6 files changed

Lines changed: 34 additions & 35 deletions

File tree

melos.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,12 @@ command:
105105
streaming_shared_preferences: ^2.0.0
106106
svg_icon_widget: ^0.0.1
107107
stream_core_flutter: ^0.5.1
108-
stream_thumbnail: ^0.1.0
108+
stream_thumbnail:
109+
git:
110+
url: https://github.com/GetStream/stream-core-flutter.git
111+
ref: 2aea1413997af886ee951921d71e6b8cb8c5cfbb
112+
path: packages/stream_thumbnail
109113
synchronized: ^3.4.0
110-
thumblr: ^0.0.4
111114
url_launcher: ^6.3.2
112115
uuid: ^4.5.3
113116
video_player: ^2.11.1

packages/stream_chat_flutter/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
## Upcoming
22

3+
⚠️ Changed
4+
5+
- Video thumbnails now use `stream_thumbnail` on every platform, and the `thumblr`
6+
dependency is gone.
7+
- Linux builds now need the FFmpeg and libwebp development packages — on Debian/Ubuntu:
8+
`libavcodec-dev libavformat-dev libavutil-dev libswscale-dev libwebp-dev`.
9+
310
🐞 Fixed
411

512
- Fixed `StreamAttachmentHandler` throwing `UnimplementedError` on WebAssembly builds.

packages/stream_chat_flutter/example/linux/flutter/generated_plugins.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ list(APPEND FLUTTER_PLUGIN_LIST
77
file_selector_linux
88
record_linux
99
sqlite3_flutter_libs
10+
stream_thumbnail
1011
url_launcher_linux
1112
)
1213

packages/stream_chat_flutter/example/windows/flutter/generated_plugins.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ list(APPEND FLUTTER_PLUGIN_LIST
1010
record_windows
1111
share_plus
1212
sqlite3_flutter_libs
13-
thumblr_windows
13+
stream_thumbnail
1414
url_launcher_windows
1515
)
1616

packages/stream_chat_flutter/lib/src/video/video_service.dart

Lines changed: 7 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
import 'dart:async';
2-
import 'dart:ui' as ui;
32

43
import 'package:flutter/services.dart';
54
import 'package:stream_thumbnail/stream_thumbnail.dart';
6-
import 'package:thumblr/thumblr.dart' as thumblr;
7-
8-
import '../../stream_chat_flutter.dart';
9-
import '../utils/device_segmentation.dart';
105

116
///
127
// ignore: prefer-match-file-name
@@ -18,20 +13,18 @@ class _IVideoService {
1813

1914
/// Generates a thumbnail image data in memory as UInt8List.
2015
///
21-
/// The video source can be a local video file or a URL.
22-
///
23-
/// Thumbnails are not supported on Web at this time.
16+
/// The video source can be a local video file or a URL, on every platform.
2417
///
2518
/// If no [video] path is supplied, or if a thumbnail cannot be generated,
2619
/// returns [generatePlaceholderThumbnail]. A stock placeholder image.
2720
///
28-
/// For desktop, you can specify the position of the video to generate
29-
/// the thumbnail.
21+
/// Use [timeMs] to pick the frame, and [maxHeight]/[maxWidth] to bound the
22+
/// size or `0` to keep the source resolution. A lower [quality] reduces
23+
/// image quality, but it gets ignored for PNG format.
3024
///
31-
/// For mobile, you can specify the maximum height or width for the thumbnail
32-
/// or 0 for same resolution as the original video. The lower quality value
33-
/// creates lower quality of the thumbnail image, but it gets ignored for
34-
/// PNG format.
25+
/// [headers] are sent when fetching a remote video, except on Windows, which
26+
/// cannot attach them. Windows also has no WebP encoder, so
27+
/// [StreamThumbnailFormat.webp] fails there.
3528
Future<Uint8List?> generateVideoThumbnail({
3629
String? video,
3730
Map<String, String>? headers,
@@ -45,22 +38,6 @@ class _IVideoService {
4538
if (video == null) return generatePlaceholderThumbnail();
4639

4740
try {
48-
// If the device is a desktop, use thumblr to generate the thumbnail.
49-
if (isDesktopDevice) {
50-
final thumbnail = await thumblr.generateThumbnail(filePath: video);
51-
final byteData = await thumbnail.image.toByteData(
52-
format: ui.ImageByteFormat.png,
53-
);
54-
55-
final bytesList = byteData?.buffer.asUint8List();
56-
if (bytesList != null && bytesList.isNotEmpty) {
57-
return bytesList;
58-
}
59-
60-
return await generatePlaceholderThumbnail();
61-
}
62-
63-
// Otherwise, use the stream_thumbnail plugin to generate the thumbnail.
6441
return await StreamThumbnail.thumbnailData(
6542
video: video,
6643
headers: headers,

packages/stream_chat_flutter/pubspec.yaml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,22 @@ dependencies:
5656
shimmer: ^3.0.0
5757
stream_chat_flutter_core: ^10.4.0
5858
stream_core_flutter: ^0.5.1
59-
stream_thumbnail: ^0.1.0
59+
stream_thumbnail:
60+
# The ignore below silences `invalid_dependency` because we occasionally
61+
# pin stream_thumbnail to a git ref to iterate on it alongside this
62+
# SDK between its releases.
63+
#
64+
# **Note:** Before publishing stream_chat_flutter, this MUST be swapped
65+
# back to a pub version constraint — git deps are not allowed on pub.dev
66+
# and will block the release.
67+
# ignore: invalid_dependency
68+
git:
69+
url: https://github.com/GetStream/stream-core-flutter.git
70+
ref: 2aea1413997af886ee951921d71e6b8cb8c5cfbb
71+
path: packages/stream_thumbnail
6072
svg_icon_widget: ^0.0.1
6173
synchronized: ^3.4.0
6274
theme_extensions_builder_annotation: ^7.1.0
63-
thumblr: ^0.0.4
6475
url_launcher: ^6.3.2
6576
video_player: ^2.11.1
6677

0 commit comments

Comments
 (0)