This proposal addresses the need for enhanced functionality in Flutter’s Canvas interface to support custom use cases such as Widget-to-SVG conversion. By exposing additional information in the Path
and Paragraph
classes, developers can implement more complex and meaningful custom operations in pure Dart.
Table of Contents
Introduction
Issue Overview
Issue Number: #148631
Opened by: mimbrown
Date Opened: Yesterday
Comments: 0
Use Case Description of Widget to SVG Conversion
I aim to develop a custom class that implements the Canvas interface, allowing me to create a Widget-to-SVG converter. However, the current Flutter classes lack some essential information needed for this implementation. Specifically, when implementing the drawPath
method, the provided Path
object does not allow access to the history of commands (such as lineTo
, moveTo
, etc.) that were used to define it. Similarly, the Paragraph
object passed to drawParagraph
does not seem to reveal the actual text content.

Proposal
Exposing Necessary Information
The core of my proposal is to modify the Path
and Paragraph
classes, among others in the dart:ui
library, to expose the necessary data for implementing meaningful custom operations in pure Dart. These classes currently serve as wrappers around native implementations, and additional information could be surfaced through these wrappers.
Example: Path Class for Widget to SVG Conversion
For instance, adding a method like getSegments()
to the Path
class, which outputs an array of the commands used to define the path, would greatly facilitate my project. This enhancement would provide the detailed history of path commands needed to accurately convert Widget drawings into SVG format.
Broader Implications
While my primary goal is to generate SVGs, this change could benefit other developers with different custom canvas use cases. Exposing these additional details would enable more flexible and powerful custom implementations across various projects.
Also read:
Will Gemini Replace Play Store and Android Apps?
Support for Excluding Flavors When Conditionally Defining Assets
Information in Table Format
Section | Details |
---|---|
Issue Overview | |
Issue Number | #148631 |
Opened by | mimbrown |
Date Opened | Yesterday |
Comments | 0 |
Use Case Description | I aim to develop a custom class that implements the Canvas interface, allowing me to create a Widget-to-SVG converter. However, the current Flutter classes lack some essential information needed for this implementation. |
Specifically, when implementing the drawPath method, the provided Path object does not allow access to the history of commands (such as lineTo , moveTo , etc.) that were used to define it. | |
Similarly, the Paragraph object passed to drawParagraph does not seem to reveal the actual text content. | |
Proposal | |
Exposing Necessary Information | The core of my proposal is to modify the Path and Paragraph classes, among others in the dart:ui library, to expose the necessary data for implementing meaningful custom operations in pure Dart. These classes currently serve as wrappers around native implementations, and additional information could be surfaced through these wrappers. |
Example: Path Class | For instance, adding a method like getSegments() to the Path class, which outputs an array of the commands used to define the path, would greatly facilitate my project. |
This enhancement would provide the detailed history of path commands needed to accurately convert Widget drawings into SVG format. | |
Broader Implications | While my primary goal is to generate SVGs, this change could benefit other developers with different custom canvas use cases. Exposing these additional details would enable more flexible and powerful custom implementations across various projects. |
Conclusion | To summarize, the request is to enhance the Path and Paragraph classes, along with other relevant dart:ui types, to expose the necessary information for custom implementations. This would allow developers to undertake more complex and meaningful tasks within their Flutter applications. |
Conclusion
To summarize, the request is to enhance the Path
and Paragraph
classes, along with other relevant dart:ui
types, to expose the necessary information for custom implementations. This would allow developers to undertake more complex and meaningful tasks within their Flutter applications.
Join Our Whatsapp Group
Join Telegram group
FAQs on Enabling Custom Canvas Use Cases: Widget to SVG Conversion
What is the main issue being addressed?
Issue Number: #148631
Opened by: mimbrown
Date Opened: Yesterday
Comments: 0
The main issue is the lack of necessary information in Flutter’s current Canvas implementation to develop custom classes for specific use cases, such as converting Widget drawings to SVG format.
What is the primary use case described?
The primary use case involves creating a custom class that implements the Canvas interface to convert Widget drawings into SVG format. However, current Flutter classes do not provide the required data, such as the history of path commands and the actual text content in paragraphs, which are essential for this implementation.
Why can’t the current Flutter classes be used directly for the Widget-to-SVG converter?
The current Flutter classes, particularly the Path
and Paragraph
classes, do not expose the necessary details required for converting Widget drawings to SVG. For instance, the Path
class does not allow access to the command history (like lineTo
, moveTo
), and the Paragraph
class does not provide the actual text content.
What changes are being proposed to address this issue?
The proposal suggests modifying the Path
and Paragraph
classes, as well as other related dart:ui
types, to expose the necessary data for custom implementations. This would involve surfacing additional information through the existing wrappers around native implementations.
Can you provide an example of the proposed changes?
An example of the proposed change is adding a getSegments()
method to the Path
class. This method would output an array of commands used to define the path, which would enable the accurate conversion of Widget drawings into SVG format.
How will these changes benefit other developers?
While the primary goal is to generate SVGs, exposing additional details in these classes would allow other developers to undertake various custom canvas use cases. This would enable more flexible and powerful custom implementations, enhancing the overall capabilities of Flutter applications.
Join Our Whatsapp Group
Join Telegram group
What is the main conclusion of the proposal?
The main conclusion is that enhancing the Path
and Paragraph
classes, along with other relevant dart:ui
types, to expose necessary information will allow developers to perform more complex and meaningful tasks within their Flutter applications. This would significantly benefit projects requiring detailed and custom canvas implementations.
Thanks for sharing. I read many of your blog posts, cool, your blog is very good.
Can you be more specific about the content of your article? After reading it, I still have some doubts. Hope you can help me.