Skip to content

Conversation

@ndonkoHenri
Copy link
Contributor

@ndonkoHenri ndonkoHenri commented Nov 10, 2025

Fix #5219

Continuation of #3611

Summary by Sourcery

Refactor chart event parsing for flet-charts to use a type-based resolver function instead of a string-keyed map, ensuring event types are correctly identified in minified builds.

Bug Fixes:

  • Fix event type resolution breakage under code minification by replacing runtimeType-to-string lookup.

Enhancements:

  • Introduce resolveFlTouchEventType function with explicit type checks for all FlTouchEvent variants.
  • Update all chart event data constructors to use the new resolver instead of the removed eventMap.

Chores:

  • Remove the obsolete eventMap constant.

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

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors event type resolution across all chart components by replacing a runtime type string lookup with direct type checking. The change improves type safety and performance by using Dart's type system instead of string-based runtime type resolution.

Key Changes:

  • Replaced the eventMap constant lookup with a new resolveFlTouchEventType() function that uses is type checks
  • Updated all chart event data factories (bar, candlestick, line, pie, radar, scatter) to use the new function

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
sdk/python/packages/flet-charts/src/flutter/flet_charts/lib/src/utils/charts.dart Removed eventMap constant and added resolveFlTouchEventType() function using type checks instead of string lookup
sdk/python/packages/flet-charts/src/flutter/flet_charts/lib/src/utils/bar_chart.dart Updated BarChartEventData.fromDetails() to call resolveFlTouchEventType()
sdk/python/packages/flet-charts/src/flutter/flet_charts/lib/src/utils/candlestick_chart.dart Updated CandlestickChartEventData.fromDetails() to call resolveFlTouchEventType()
sdk/python/packages/flet-charts/src/flutter/flet_charts/lib/src/utils/line_chart.dart Updated LineChartEventData.fromDetails() to call resolveFlTouchEventType()
sdk/python/packages/flet-charts/src/flutter/flet_charts/lib/src/utils/pie_chart.dart Updated PieChartEventData.fromDetails() to call resolveFlTouchEventType()
sdk/python/packages/flet-charts/src/flutter/flet_charts/lib/src/utils/radar_chart.dart Updated RadarChartEventData.fromDetails() to call resolveFlTouchEventType()
sdk/python/packages/flet-charts/src/flutter/flet_charts/lib/src/utils/scatter_chart.dart Updated ScatterChartEventData.fromDetails() to call resolveFlTouchEventType()

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Nov 10, 2025

Deploying flet-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 94bab6d
Status:⚡️  Build in progress...

View logs

@ndonkoHenri ndonkoHenri linked an issue Nov 10, 2025 that may be closed by this pull request
1 task
Corrected indentation for eventType parameter in the constructors of BarChartEventData, CandlestickChartEventData, PieChartEventData, and RadarChartEventData for improved code readability and consistency.
@FeodorFitsner FeodorFitsner merged commit 3280dfb into main Nov 10, 2025
22 of 23 checks passed
@FeodorFitsner FeodorFitsner deleted the fix-chart-types branch November 10, 2025 20:19
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.

FilePicker no funciona Using LineChart, on_chart_event return wrong LineChartEvent types

3 participants