Skip to content

Commit 76fdb59

Browse files
committed
chore: update migration guide
1 parent b38b320 commit 76fdb59

File tree

2 files changed

+201
-0
lines changed

2 files changed

+201
-0
lines changed

migrations/v10-migration.md

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88

99
This guide includes breaking changes grouped by release phase:
1010

11+
### 🚧 v10.0.0-beta.8
12+
13+
- [customAttachmentPickerOptions](#-customattachmentpickeroptions)
14+
- [onCustomAttachmentPickerResult](#-oncustomattachmentpickerresult)
15+
1116
### 🚧 v10.0.0-beta.7
1217

1318
- [AttachmentFileUploader](#-attachmentfileuploader)
@@ -33,6 +38,141 @@ This guide includes breaking changes grouped by release phase:
3338

3439
---
3540

41+
## 🧪 Migration for v10.0.0-beta.8
42+
43+
### 🛠 customAttachmentPickerOptions
44+
45+
#### Key Changes:
46+
47+
- `customAttachmentPickerOptions` has been removed. Use `attachmentPickerOptionsBuilder` instead.
48+
- New builder pattern provides access to default options which can be modified, reordered, or extended.
49+
50+
#### Migration Steps:
51+
52+
**Before:**
53+
```dart
54+
StreamMessageInput(
55+
customAttachmentPickerOptions: [
56+
TabbedAttachmentPickerOption(
57+
key: 'custom-location',
58+
icon: const Icon(Icons.location_on),
59+
supportedTypes: [AttachmentPickerType.images],
60+
optionViewBuilder: (context, controller) {
61+
return CustomLocationPicker();
62+
},
63+
),
64+
],
65+
)
66+
```
67+
68+
**After:**
69+
```dart
70+
StreamMessageInput(
71+
attachmentPickerOptionsBuilder: (context, defaultOptions) {
72+
// You can now modify, filter, reorder, or extend default options
73+
return [
74+
...defaultOptions,
75+
TabbedAttachmentPickerOption(
76+
key: 'custom-location',
77+
icon: const Icon(Icons.location_on),
78+
supportedTypes: [AttachmentPickerType.images],
79+
optionViewBuilder: (context, controller) {
80+
return CustomLocationPicker();
81+
},
82+
),
83+
];
84+
},
85+
)
86+
```
87+
88+
**Example: Filtering default options**
89+
```dart
90+
StreamMessageInput(
91+
attachmentPickerOptionsBuilder: (context, defaultOptions) {
92+
// Remove poll option
93+
return defaultOptions.where((option) => option.key != 'poll').toList();
94+
},
95+
)
96+
```
97+
98+
**Example: Reordering options**
99+
```dart
100+
StreamMessageInput(
101+
attachmentPickerOptionsBuilder: (context, defaultOptions) {
102+
// Reverse the order
103+
return defaultOptions.reversed.toList();
104+
},
105+
)
106+
```
107+
108+
**Using with `showStreamAttachmentPickerModalBottomSheet`:**
109+
```dart
110+
final result = await showStreamAttachmentPickerModalBottomSheet(
111+
context: context,
112+
optionsBuilder: (context, defaultOptions) {
113+
return [
114+
...defaultOptions,
115+
TabbedAttachmentPickerOption(
116+
key: 'custom-option',
117+
icon: const Icon(Icons.star),
118+
supportedTypes: [AttachmentPickerType.images],
119+
optionViewBuilder: (context, controller) {
120+
return CustomPickerView();
121+
},
122+
),
123+
];
124+
},
125+
);
126+
```
127+
128+
> ⚠️ **Important:**
129+
> - The builder pattern gives you access to default options, allowing more flexible customization
130+
> - The builder works with both mobile (tabbed) and desktop (system) pickers
131+
132+
---
133+
134+
### 🛠 onCustomAttachmentPickerResult
135+
136+
#### Key Changes:
137+
138+
- `onCustomAttachmentPickerResult` has been removed. Use `onAttachmentPickerResult` which returns `FutureOr<bool>`.
139+
- Result handler can now short-circuit default behavior by returning `true`.
140+
141+
#### Migration Steps:
142+
143+
**Before:**
144+
```dart
145+
StreamMessageInput(
146+
onCustomAttachmentPickerResult: (result) {
147+
if (result is CustomAttachmentPickerResult) {
148+
final data = result.data;
149+
// Handle custom result
150+
}
151+
},
152+
)
153+
```
154+
155+
**After:**
156+
```dart
157+
StreamMessageInput(
158+
onAttachmentPickerResult: (result) {
159+
if (result is CustomAttachmentPickerResult) {
160+
final data = result.data;
161+
// Handle custom result
162+
return true; // Indicate we handled it - skips default processing
163+
}
164+
return false; // Let default handler process other result types
165+
},
166+
)
167+
```
168+
169+
> ⚠️ **Important:**
170+
> - `onAttachmentPickerResult` replaces `onCustomAttachmentPickerResult` and must return a boolean
171+
> - Return `true` from `onAttachmentPickerResult` to skip default handling
172+
> - Return `false` to allow the default handler to process the result
173+
174+
---
175+
36176
## 🧪 Migration for v10.0.0-beta.7
37177

38178
### 🛠 AttachmentFileUploader
@@ -610,6 +750,10 @@ StreamMessageWidget(
610750

611751
## 🎉 You're Ready to Migrate!
612752

753+
### For v10.0.0-beta.8:
754+
- ✅ Replace `customAttachmentPickerOptions` with `attachmentPickerOptionsBuilder` to access and modify default options
755+
- ✅ Replace `onCustomAttachmentPickerResult` with `onAttachmentPickerResult` that returns `FutureOr<bool>`
756+
613757
### For v10.0.0-beta.7:
614758
- ✅ Update custom `AttachmentFileUploader` implementations to include the four new abstract methods: `uploadImage`, `uploadFile`, `removeImage`, and `removeFile`
615759
- ✅ Update `MessageState` factory constructors to use `MessageDeleteScope` parameter

packages/stream_chat_flutter/CHANGELOG.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,60 @@
1+
## Upcoming Beta
2+
3+
🛑️ Breaking
4+
5+
- `onCustomAttachmentPickerResult` has been removed. Use `onAttachmentPickerResult` which returns `FutureOr<bool>` to indicate if the result was handled.
6+
```dart
7+
// Before
8+
StreamMessageInput(
9+
onCustomAttachmentPickerResult: (result) {
10+
// Handle custom location attachment
11+
final location = result.data['location'];
12+
sendLocationMessage(location);
13+
},
14+
)
15+
16+
// After
17+
StreamMessageInput(
18+
onAttachmentPickerResult: (result) {
19+
if (result is CustomAttachmentPickerResult) {
20+
// Handle custom location attachment
21+
final location = result.data['location'];
22+
sendLocationMessage(location);
23+
return true; // Skip default handling
24+
}
25+
return false; // Use default handling for built-in types
26+
},
27+
)
28+
```
29+
30+
- `customAttachmentPickerOptions` has been removed. Use `attachmentPickerOptionsBuilder` to modify, reorder, or extend default options.
31+
```dart
32+
// Before - could only add custom options
33+
StreamMessageInput(
34+
customAttachmentPickerOptions: [
35+
TabbedAttachmentPickerOption(
36+
key: 'location',
37+
icon: Icon(Icons.location_on),
38+
// ...
39+
),
40+
],
41+
)
42+
43+
// After - can now modify, filter, or extend default options
44+
StreamMessageInput(
45+
attachmentPickerOptionsBuilder: (context, defaultOptions) {
46+
return [
47+
...defaultOptions, // Keep all default options
48+
TabbedAttachmentPickerOption(
49+
key: 'location',
50+
icon: Icon(Icons.location_on),
51+
// ...
52+
),
53+
];
54+
},
55+
)
56+
```
57+
158
## 9.19.0
259

360
✅ Added

0 commit comments

Comments
 (0)