You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
***BREAKING CHANGE:** Refactored the plugin to use an `EventChannel` for color updates.
4
+
*`NativeIosColorPicker.showColorPicker()` is now `Future<void>` and only shows the picker.
5
+
* Added `NativeIosColorPicker.onColorChanged` stream (`Stream<Map<dynamic, dynamic>>`) which emits color updates (RGBA map) from the native picker in real-time.
6
+
* Fixed an issue where the picker might disappear immediately after selection by adopting a stream-based approach for color updates.
7
+
* Updated `README.md` with new usage instructions and API details reflecting the stream-based approach.
8
+
* Improved `ColorModel.fromMap` to handle dynamic map types safely from the stream.
Then, you can show the color picker using the static method `showColorPicker()`:
42
+
The color picker is shown using `NativeIosColorPicker.showColorPicker()`. Color changes are received via the `NativeIosColorPicker.onColorChanged` stream. You need to subscribe to this stream to get color updates.
41
43
42
44
```dart
43
-
try {
44
-
final colorValues = await NativeIosColorPicker.showColorPicker();
45
-
print('Selected color: $colorValues');
46
-
// colorValues contains:
47
-
// {
48
-
// 'red': 0.5, // value between 0.0 and 1.0
49
-
// 'green': 0.3, // value between 0.0 and 1.0
50
-
// 'blue': 0.7, // value between 0.0 and 1.0
51
-
// 'alpha': 1.0 // value between 0.0 and 1.0
52
-
// }
53
-
} catch (e) {
54
-
print('Error showing color picker: $e');
45
+
StreamSubscription? _colorSubscription;
46
+
Color _selectedColor = Colors.blue; // Initial color
Shows the native iOS/macOS color picker window. This method does not return the selected color directly. Color updates are sent via the `onColorChanged` stream.
133
+
134
+
#### `static Stream<Map<dynamic, dynamic>> get onColorChanged`
88
135
89
-
Shows the native iOS color picker and returns the selected color values as a map containing RGBA components (values between 0.0 and 1.0).
136
+
A broadcast stream that emits updates when the color is changed in the native picker. Each event is a `Map` containing RGBA components (keys: 'red', 'green', 'blue', 'alpha') with values between 0.0 and 1.0. You should subscribe to this stream to receive color updates.
Creates a ColorModel instance from a map containing RGBA values.
146
+
Creates a ColorModel instance from a map containing RGBA values (typically received from the `onColorChanged` stream). Handles potential null values and converts numeric types safely.
0 commit comments