Skip to content

Conversation

@InesaFitsner
Copy link
Contributor

@InesaFitsner InesaFitsner commented Feb 1, 2026

Description

Test Code

# Test code for the review of this PR

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist

  • I signed the CLA.
  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • New and existing tests pass locally with my changes
  • I have made corresponding changes to the documentation (if applicable)

Screenshots

Additional details

Summary by Sourcery

Add a new flet-color-picker extension package providing multiple Flutter-based color picker controls and integrate it into the Flet client and Python SDK.

New Features:

  • Introduce ColorPicker, SlidePicker, HueRingPicker, MaterialPicker, BlockPicker, and MultipleChoiceBlockPicker controls backed by flutter_colorpicker.
  • Expose Python APIs and examples for the new color picker controls, including event callbacks and configuration options.
  • Generate screenshots and golden-based integration tests for the new color picker controls.

Enhancements:

  • Wire the flet-color-picker Flutter extension into the Flet client so the new controls are available at runtime.
  • Register the flet-color-picker package in the Python workspace configuration and dependency lists.
  • Add MkDocs documentation pages for the new color picker controls and index them in the controls navigation.

Build:

  • Add Flutter and Python packaging configuration for the new flet-color-picker extension package.

Documentation:

  • Document the new color picker extension and its controls with usage guides, examples, and configuration reference.

Tests:

  • Add integration and documentation screenshot tests covering all new color picker controls.

Introduce a new flet-color-picker extension (v0.1.0). Adds a Python package (src/flet_color_picker) with control implementation, pyproject, README, LICENSE, and CHANGELOG, plus a Flutter wrapper (src/flutter/flet_color_picker) and pubspec. Includes example (examples/controls/color_picker/example_1.py) and docs (docs/color_picker). Integrates the package into the client by adding the dependency to client/pubspec.yaml, importing the package in client/lib/main.dart, and registering its Extension(). Also updates workspace python metadata (sdk/python/pyproject.toml), mkdocs navigation, and lockfile entries (adds package and transitive flutter_colorpicker).
Introduce a new HueRingPicker LayoutControl for the flet-color-picker extension and expose it from the package __init__. Added an example (sdk/python/examples/controls/color_picker/example_2.py) demonstrating usage and a documentation page (sdk/python/packages/flet/docs/color_picker/hue_ring_picker.md). Updated mkdocs.yml to include the new doc in the ColorPicker section.
Add two new color picker controls (MaterialPicker and SlidePicker) to the flet-color-picker package and export them from __init__.py. Add corresponding control implementations, usage docs, and examples (example_3.py, example_4.py); update existing examples to call ft.run instead of ft.app. Register the new docs in mkdocs.yml and include an integration test plus a golden image for color picker screenshots.
Introduce BlockPicker and MultipleChoiceBlockPicker controls to the flet-color-picker package. Adds control implementations (block_picker.py, multiple_choice_block_picker.py), updates package exports (__init__.py), and provides usage examples (example_5.py, example_6.py). Also adds documentation pages for both pickers and updates mkdocs navigation to include them. Handlers expose on_color_change/on_colors_change events returning selected color(s) as hex strings.
Add macOS golden images for multiple color picker variants and extend the integration tests to cover them. Update test_color_picker.py to import specific picker classes (HueRingPicker, SlidePicker, MaterialPicker, BlockPicker, MultipleChoiceBlockPicker) and add screenshot-based tests that assert rendering for each picker with example colors.
Add several new configurable properties to the ColorPicker control to improve customization: color_history (list of colors), display_thumb_color (bool), enable_alpha (bool), hex_input_bar (bool), and label_text_style (TextStyle). Each property includes a short docstring. Update the example to disable the thumb color and increase the picker width (display_thumb_color=False, color_picker_width=420). These changes allow toggling UI elements and providing a color history palette.
Introduce ColorLabelType enum and expose it from package root; add label_types and on_history_change properties to ColorPicker (with updated docstrings). Update example to demonstrate color_history, label_types, and an on_history_change handler; adjust a few picker defaults (disable alpha/hex input in example). This enables configurable color label formats and notification when the history palette changes.
Introduce a PaletteType enum with various palette variants (HSV/HSL/RGB and hue wheel), export it from the package, and add an optional palette_type attribute to ColorPicker with documentation. Update the example to import PaletteType and demonstrate using palette_type=PaletteType.RGB_WITH_BLUE. This enables choosing different picker area layouts for the color picker control.
Introduce an optional picker_area_border_radius (ft.BorderRadiusValue) property to the ColorPicker control to allow customizing the picker area's corner radius. Added a docstring for the new property and updated the example (sdk/python/examples/controls/color_picker/example_1.py) to demonstrate usage with picker_area_border_radius=ft.BorderRadius.all(20).
Introduce a new optional property picker_area_height_percent on ColorPicker (Optional[ft.Number]) to control the picker area's height as a percentage of the picker width. Update the color picker example to demonstrate usage by setting picker_area_height_percent=0.3.
Add a new picker_hsv_color property to ColorPicker to store the currently selected HSV color (dict with keys: alpha, hue, saturation, value). Also add an on_hsv_color_change event handler which receives the HSV values via Event.data. This complements the existing on_color_change (hex values) and lets consumers work with HSV data directly.
Introduce a new Flutter extension package flet_color_picker for the Flet Python SDK. Adds multiple picker controls (ColorPicker, HueRingPicker, SlidePicker, MaterialPicker, BlockPicker, MultipleChoiceBlockPicker) with an Extension entrypoint and wiring to Flet Control properties/events (picker_color, picker_hsv_color, color_history, picker_colors and events like color_change, hsv_color_change, history_change, colors_change). Includes parsing helpers, label/palette mapping, and a .gitignore for the package.
Add runtime logging and HSV support to the color picker example: print selected color on change, enable the history change handler, and introduce on_hsv_color_change to log HSV data (reads picker_hsv_color). Also set an initial picker_hsv_color dict to demonstrate HSV initialization.
Remove unused imports and consolidate numerous conditional ColorPicker constructions into a single, unified instantiation. Add sensible defaults (colorPickerWidth defaults to 300.0, paletteType defaults to PaletteType.hsvWithHue) and introduce labelTypesArg fallback when rawLabelTypes is not a List. Also apply minor formatting changes (split long call, align variable parsing) and reduce code duplication for a smaller, clearer build method.
Refactor ColorPicker to use the shared parseEnum helper: add import of flet/src/utils/enums.dart and replace the custom _parseLabelType and _parsePaletteType implementations with calls to parseEnum (supporting an optional defaultValue). This centralizes enum parsing and removes duplicated switch logic. Also update the Python example to use PaletteType.HSV_WITH_HUE instead of RGB_WITH_BLUE.
Expose configurable color swatches and dialog behavior for BlockPicker. Added available_colors (list) and use_in_show_dialog (bool) to the Python control API, updated the example to provide a default color list and enable the dialog display, and implemented parsing/handling in the Flutter control: import parseColor utility, convert raw color values to Flutter Color objects, and pass availableColors/useInShowDialog into the underlying BlockPicker. Falls back to the default picker when no available_colors are provided.
Change example to host BlockPicker inside an AlertDialog and open it with a Button instead of embedding the picker directly in the page. Remove the deprecated use_in_show_dialog property from the Python BlockPicker API and stop reading/passing that flag in the Flutter wrapper. Note: this removes the use_in_show_dialog option (breaking change) and consolidates dialog usage to the example.
Expose several configurable options for the HueRingPicker across Python and Flutter layers: color_picker_height, enable_alpha, hue_ring_stroke_width, picker_area_border_radius, and portrait_only. The example was updated to demonstrate these options (larger height, disabled alpha, wider hue ring, square picker area, portrait-only). The Flutter control now reads these properties from the control with sensible defaults and passes them into the underlying HueRingPicker widget.
Expose primary color changes and layout/label options for MaterialPicker. Added enable_label and portrait_only properties and an on_primary_change event handler in the Python control API. The Flutter control now forwards enable_label and portrait_only to the picker and triggers a "primary_change" event (hex color) via onPrimaryChanged. Updated example to handle on_primary_change and demonstrate portrait_only/enable_label usage.
Expose an available_colors property for MultipleChoiceBlockPicker so callers can provide a custom palette. Added the available_colors attribute and docstring to the Python control class, updated the Flutter control state to parse raw available_colors from the control into a List<Color> and pass it into the picker (with fallback to the previous constructor when none provided). Also updated the example to demonstrate supplying an available_colors list.
Add ColorModel enum and multiple new SlidePicker configuration options across Python and Flutter bindings. Expose ColorModel in package __init__.py. slide_picker.py defines ColorModel and many optional properties (color_model, display_thumb_color, enable_alpha, indicator alignment/size/radius, label text/style/types, show_indicator/label/params/slider_text, slider_size/text_style) and keeps on_color_change. Update Dart control to parse these new fields (import enums, parse color model and label types, forward args to Flutter SlidePicker). Update example to demonstrate new options and print color changes.
Update slide picker example and internals: tweak example_3 defaults (indicator alignments, indicator_size increased, show_indicator enabled) to improve indicator positioning/visibility. Improve Python docstrings for indicator_alignment_begin/end with clearer wording and usage examples. Simplify Dart color-change handler by removing local setState and property update; now it only emits the color_change event with the hex value to avoid redundant state updates.
Add documentation and assets for the ColorPicker extension: new docs page (color_picker.md) with usage and example link, an example package stub (sdk/python/examples/controls/color_picker/__init__.py), and a screenshot image used for docs. Include an integration test (test_color_picker_examples.py) that renders the ColorPicker for documentation screenshots. Update color_picker index to list available pickers and update mkdocs navigation to include the new ColorPicker doc.
Update sdk/python/packages/flet/docs/color_picker/color_picker.md to use ../test-images/examples/... for example_images instead of ../../integration_tests/examples/... to reflect the relocated test image assets and correct the relative path.
Add example_images references and embedded class_summary screenshots to color picker docs (BlockPicker, HueRingPicker, MaterialPicker, MultipleChoiceBlockPicker, SlidePicker). Add golden macOS PNGs for each picker under integration_tests/examples/color_picker/golden/macos/color_picker_examples. Expand integration tests (test_color_picker_examples.py): import individual picker classes and add visual snapshot tests (assert_control_screenshot) for hue ring, slide, material, block, and multiple-choice block pickers. Also adjust the SlidePicker example_images frontmatter path.
Update example_images frontmatter in color_picker docs to use ../test-images/examples/color_picker/golden/macos/color_picker_examples instead of the old ../../integration_tests path. Applies to BlockPicker, HueRingPicker, MaterialPicker, and MultipleChoiceBlockPicker to reflect reorganization of image assets.
Streamline the color picker example files by removing the separate swatch and selected Text controls and replacing in-UI updates with simple console logging of color events. Clean up imports, remove many optional styling/behavior properties, and adjust a few defaults (e.g. border radii, stroke widths). Replace open-dialog Buttons with compact IconButtons; in example_6 create an AlertDialog that hosts the MultipleChoiceBlockPicker. Overall cleanup to make the demos leaner and focused on the picker controls.
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've reviewed this pull request using the Sourcery rules engine

Add the new flet-color-picker package to the CI workflow matrix and include flet_color_picker in the package iteration list so the package is tested and handled alongside other flet packages during CI/publishing.
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Feb 4, 2026

Deploying flet-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: b728a71
Status:🚫  Build failed.

View logs

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Feb 4, 2026

Deploying flet-examples with  Cloudflare Pages  Cloudflare Pages

Latest commit: b728a71
Status: ✅  Deploy successful!
Preview URL: https://9972f2c2.flet-examples.pages.dev
Branch Preview URL: https://inesa-color-picker.flet-examples.pages.dev

View logs

Use the shared parseDouble function to parse HSV map fields (alpha, hue, saturation, value) instead of the local _toDouble helper, and remove the now-unused _toDouble method. Null checks are preserved before constructing the HSVColor.
Move HSV parsing logic into a new utils file and update usages. Added src/utils/color_picker.dart with parseHsvColor(), removed the private _parseHsvColor() from color_picker.dart and imported the new utility. Updated the Python example to use picker_hsv_color (alpha/hue/saturation/value map) and commented out the old hex picker_color. This consolidates parsing logic for reuse and makes the example demonstrate HSV input.
move parsePalletteType to utils
Refactor picker widgets to inline widget.control.get* calls instead of creating many intermediate local variables. Applied changes in color_picker.dart, hue_ring_picker.dart, material_picker.dart, and slide_picker.dart, adding sensible inline defaults (e.g. color_picker_width: 300.0, color_picker_height: 250.0, const BorderRadius.all(Radius.zero), etc.). Also removed unused import 'package:flet/src/utils/enums.dart' from affected files. This simplifies the code, removes unused variables/imports, and centralizes default handling.
Refactor color picker utilities: rename utils/color_picker.dart to utils/color_pickers.dart, add parseColorModel(), and update imports in color_picker.dart and slide_picker.dart. Remove duplicated parsing helpers from SlidePicker and use shared parseLabelType/parseColorModel functions to centralize parsing logic and avoid duplication.
Rename several color_picker documentation files to use compact filenames (remove underscores) and update references. Files renamed: color_picker/*.md -> color_picker/*(no_underscore).md (color_picker, block_picker, hue_ring_picker, material_picker, multiple_choice_block_picker, slide_picker). Updated color_picker/index.md and sdk/python/packages/flet/mkdocs.yml nav entries to point to the new filenames for consistent docs linking.
Update picker class docstrings to be more descriptive and specific (BlockPicker, ColorPicker, HueRingPicker, MaterialPicker, MultipleChoiceBlockPicker, SlidePicker). Remove redundant introductory paragraphs and the repeated "Usage"/installation sections (uv/pip and flutter_colorpicker mentions) from the color picker docs, leaving the class summaries and examples. This cleans up documentation and standardizes descriptions across the color picker components.
Replace the old "## Description" sections and {{ class_all_options(class_name) }} with the unified {{ class_members(class_name) }} macro in color picker docs for consistency. Also tweak the index copy to "Multiple color picker controls built on Flutter's..." and rename the section to "Available color pickers" for clarity. Affected files: blockpicker.md, colorpicker.md, hueringpicker.md, materialpicker.md, multiplechoiceblockpicker.md, slidepicker.md, and index.md.
Move sdk/python/packages/flet/docs/color_picker/* to sdk/python/packages/flet/docs/colorpickers/* and update mkdocs.yml navigation entries to reference the new paths. Files renamed: blockpicker.md, colorpicker.md, hueringpicker.md, index.md, materialpicker.md, multiplechoiceblockpicker.md, slidepicker.md.
Refactor color picker API: rename picker_color/picker_colors to unified color/colors fields across pickers (ColorPicker, HueRingPicker, SlidePicker, MaterialPicker, BlockPicker, MultipleChoiceBlockPicker). Replace picker_hsv_color dict with a new HsvColor dataclass and expose it as hsv_color on ColorPicker; export HsvColor in the package __init__.py. Update example apps and integration tests to use the new parameter names. Note: this is a breaking API change — update callers to use color/colors and hsv_color (HsvColor) accordingly.
Rename the Python/Flutter extension package from flet-color-picker to flet-color-pickers and update all references. Moved/renamed package directories and Flutter library identifiers, added new src/flet_color_pickers/__init__.py and removed the old __init__.py. Updated imports in Python examples and tests (flet_color_picker -> flet_color_pickers), adjusted example usage (example_1: use color instead of hsv_color), and updated docs class_name entries. Updated client Flutter dependency path and main.dart import to use the new package name, and adjusted python workspace/config references to the new package.
Update package name from `flet-color-picker` to `flet-color-pickers` across the Python SDK. Changes include pyproject.toml for the package, README badges and install instructions, docs usage examples, and sdk/python/pyproject.toml dependency and workspace entries so the install commands and workspace mapping reflect the new package name.
Normalize property keys used by color picker controls: rename picker_color -> color, picker_hsv_color -> hsv_color, and picker_colors -> colors. Update all getters and updateProperties calls across BlockPicker, ColorPicker, HueRingPicker, MaterialPicker, SlidePicker, and MultipleChoiceBlockPicker. Remove unused import of package:flet/src/utils/colors.dart and tidy import ordering in extension.dart. This aligns property names across pickers for consistency with the control model and avoids mismatches between property updates and reads.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants