Skip to content

[flutter_svg] Add support for path onClick listener #177082

@mohitchouhan-aripra

Description

@mohitchouhan-aripra

Use case

Hi Team i'm working on a project where i need to get SVG click (SVG made up with multiple path and each path represent a Part), for this i need the support for SVG onClink listener

Proposal

Sample SVG String

<svg width="320" height="60" xmlns="http://www.w3.org/2000/svg">
  <rect onclick='onClick.postMessage("button_1_clicked");' id="leftButton" x="0" y="0" width="150" height="50" rx="10" ry="10" fill="#4CAF50" />
  <text x="75" y="30" font-family="Arial" font-size="16" fill="white" text-anchor="middle" alignment-baseline="middle">
    Left
  </text>
  <rect onclick='onClick.postMessage("button_2_clicked");' id="rightButton" x="170" y="0" width="150" height="50" rx="10" ry="10" fill="#2196F3" />
  <text x="245" y="30" font-family="Arial" font-size="16" fill="white" text-anchor="middle" alignment-baseline="middle">
    Right
  </text>
</svg>

here from the plugin i need

onElementClick: (event) {
                print("Event===>$event");
 }

OutPut

Event===>button_1_clicked

Event===>button_2_clicked

we have a plugin that use flutter_web_view but it does not have other properties

Thanks in advance Team.

Metadata

Metadata

Assignees

No one assigned

    Labels

    c: new featureNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to Flutterp: flutter_svgThe Flutter SVG drawing packagespackageflutter/packages repository. See also p: labels.team-engineOwned by Engine team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions