Skip to content

[flutter_svg] Text offset in y direction #158758

Closed
flutter/packages
#13388

Description

@stuartmorgan-g

Imported from dnfield/flutter_svg#959

Original report by @Huber1 on Jul 7, 2023

When i am using SvgPicture.file() for the following svg, it doesn't render the text in the correct location. Like you can see it is offset in y-direction

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="Ebene_1" viewBox="0 0 1000 500" xml:space="preserve"><script xmlns=""/> 
<rect fill="#C79514" width="1000" height="500"/> 
<text text-anchor="middle" x="50%" y="50%" dy=".35em" font-family="Arial, sans-serif" font-weight="bold" font-size="425px" fill="#ffffff">21</text> 
<style xmlns="" class="darkreader darkreader--fallback">html, body, body :not(iframe) {
    background-color: #232425 !important;
    border-color: #777067 !important;
    color: #dddcd9 !important;
}</style></svg>

Location: https://www.mvv-muenchen.de/fileadmin/lines/02021.svg

Screenshot_20230627-112424

The Text is not, as expected centered vertically and horizontally, but only centered horizontally

Is it a coincidence that the bottom line of the text is centered?

The Image is not cropped. I put it inside a Center on a blank screen to make sure it is completely visible

Activity

  1. added
    p: flutter_svgThe Flutter SVG drawing packages
    packageflutter/packages repository. See also p: labels.
    on Nov 13, 2024
  2. added
    P3Issues that are less important to the Flutter project
    on Nov 20, 2024
  3. darshankawar commented on Jul 23, 2025

    @darshankawar
    Member

    Verified with latest stable and plugin version:

    Image
  4. github-actions commented on Nov 12, 2026

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  5. locked as resolved and limited conversation to collaborators on Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projectfound in release: 3.32Found to occur in 3.32has reproducible stepsThe issue has been confirmed reproducible and is ready to work onp: flutter_svgThe Flutter SVG drawing packagespackageflutter/packages repository. See also p: labels.team-engineOwned by Engine teamtriaged-engineTriaged by Engine team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions