Skip to content

[flutter_markdown] Fix WidgetSpan Support in MarkdownElementBuilder #6225

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 24 commits into from
Mar 5, 2024

Conversation

pzierahn
Copy link
Contributor

This pull request addresses a critical issue identified in the flutter_markdown package, specifically relating to the handling of WidgetSpan elements within Text.rich elements when utilized inside MarkdownElementBuilders. Prior to this fix, the inclusion of WidgetSpan instances within markdown content led to casting issues, disrupting the normal rendering flow of the markdown content.

Key Changes:

  • Resolved casting problems associated with using WidgetSpan inside Text.rich elements by refining the type handling and span merging logic within the affected functions.
  • Thoroughly commented and cleaned up the code within the error-prone functions to enhance readability and maintainability, ensuring that future modifications can be made more easily.
  • Adjusted existing tests to align with the newly introduced span merging logic, which is now more efficient and produces more predictable outcomes.
  • Introduced new tests specifically designed to cover scenarios where WidgetSpan elements are included within markdown content, ensuring that this issue does not resurface in future updates.

The adjustments made in this pull request ensure that developers utilizing the flutter_markdown package can now seamlessly incorporate WidgetSpan elements within their markdown content without encountering the previously observed casting issues. This fix not only improves the package's robustness but also expands its flexibility, allowing for richer text compositions within markdown.

This pull request closes issue #144383, effectively addressing the reported bug and enhancing the overall functionality of the flutter_markdown package.

I'm welcoming feedback and suggestions for improvement.

Fixed issues:

@domesticmouse
Copy link
Contributor

PTAL @stuartmorgan

@stuartmorgan-g
Copy link
Contributor

This will need to pass CI; please see the failing checks for details.

@stuartmorgan-g
Copy link
Contributor

(In the future, please don't remove the checklist from the PR description; it's there for a reason.)

@pzierahn
Copy link
Contributor Author

pzierahn commented Mar 2, 2024

@stuartmorgan All checks pass now

@pzierahn
Copy link
Contributor Author

pzierahn commented Mar 4, 2024

@domesticmouse I have implemented the parent child style matching.

Copy link
Contributor

@domesticmouse domesticmouse left a comment

Choose a reason for hiding this comment

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

Copy link
Contributor

@tarrinneal tarrinneal left a comment

Choose a reason for hiding this comment

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

one quick change

Copy link
Contributor

@tarrinneal tarrinneal left a comment

Choose a reason for hiding this comment

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

thanks!

@tarrinneal tarrinneal added the autosubmit Merge PR when tree becomes green via auto submit App label Mar 5, 2024
@auto-submit auto-submit bot merged commit 5fed047 into flutter:main Mar 5, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 5, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 5, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 5, 2024
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Mar 5, 2024
flutter/packages@0625827...2aa6e3f

2024-03-05 [email protected] [in_app_purchase_storekit] Fix type of error code returned from native code in `SKReceiptManager.retrieveReceiptData` (flutter/packages#6265)
2024-03-05 [email protected] [video_player] Fix typo in readme (flutter/packages#6264)
2024-03-05 [email protected] [pigeon] Separates message call code generation into separate methods in the SwiftGenerator (flutter/packages#5959)
2024-03-05 [email protected] [flutter_markdown] Fix WidgetSpan Support in MarkdownElementBuilder (flutter/packages#6225)
2024-03-04 [email protected] [webview_flutter] Make WebKitWebViewWidget unit tests stateless (flutter/packages#6228)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages-flutter-autoroll
Please CC [email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
LouiseHsu pushed a commit to LouiseHsu/packages that referenced this pull request Mar 7, 2024
…lutter#6225)

This pull request addresses a critical issue identified in the `flutter_markdown` package, specifically relating to the handling of `WidgetSpan` elements within `Text.rich` elements when utilized inside `MarkdownElementBuilder`s. Prior to this fix, the inclusion of `WidgetSpan` instances within markdown content led to casting issues, disrupting the normal rendering flow of the markdown content.

Key Changes:
- Resolved casting problems associated with using `WidgetSpan` inside `Text.rich` elements by refining the type handling and span merging logic within the affected functions.
- Thoroughly commented and cleaned up the code within the error-prone functions to enhance readability and maintainability, ensuring that future modifications can be made more easily.
- Adjusted existing tests to align with the newly introduced span merging logic, which is now more efficient and produces more predictable outcomes.
- Introduced new tests specifically designed to cover scenarios where `WidgetSpan` elements are included within markdown content, ensuring that this issue does not resurface in future updates.

The adjustments made in this pull request ensure that developers utilizing the `flutter_markdown` package can now seamlessly incorporate `WidgetSpan` elements within their markdown content without encountering the previously observed casting issues. This fix not only improves the package's robustness but also expands its flexibility, allowing for richer text compositions within markdown.

This pull request closes issue [#144383](flutter/flutter#144383), effectively addressing the reported bug and enhancing the overall functionality of the `flutter_markdown` package.

I'm welcoming feedback and suggestions for improvement.

Fixed issues:
* [#144383](flutter/flutter#144383)
arc-yong pushed a commit to Arctuition/packages-arc that referenced this pull request Jun 14, 2024
…lutter#6225)

This pull request addresses a critical issue identified in the `flutter_markdown` package, specifically relating to the handling of `WidgetSpan` elements within `Text.rich` elements when utilized inside `MarkdownElementBuilder`s. Prior to this fix, the inclusion of `WidgetSpan` instances within markdown content led to casting issues, disrupting the normal rendering flow of the markdown content.

Key Changes:
- Resolved casting problems associated with using `WidgetSpan` inside `Text.rich` elements by refining the type handling and span merging logic within the affected functions.
- Thoroughly commented and cleaned up the code within the error-prone functions to enhance readability and maintainability, ensuring that future modifications can be made more easily.
- Adjusted existing tests to align with the newly introduced span merging logic, which is now more efficient and produces more predictable outcomes.
- Introduced new tests specifically designed to cover scenarios where `WidgetSpan` elements are included within markdown content, ensuring that this issue does not resurface in future updates.

The adjustments made in this pull request ensure that developers utilizing the `flutter_markdown` package can now seamlessly incorporate `WidgetSpan` elements within their markdown content without encountering the previously observed casting issues. This fix not only improves the package's robustness but also expands its flexibility, allowing for richer text compositions within markdown.

This pull request closes issue [#144383](flutter/flutter#144383), effectively addressing the reported bug and enhancing the overall functionality of the `flutter_markdown` package.

I'm welcoming feedback and suggestions for improvement.

Fixed issues:
* [#144383](flutter/flutter#144383)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autosubmit Merge PR when tree becomes green via auto submit App p: flutter_markdown
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants