Skip to content

A SemanticsData object with label "My Label" had a null textDirection. #175532

Closed
flutter/packages
#11962

Description

@jtanium

Steps to reproduce

Create an SvgPicture with a semanticsLabel, but no directionality?

I'm only creating this issue because the stacktrace suggested it, and I couldn't find any existing issues related to this.

Expected results

Expected not to get a stacktrace in the console

Actual results

Got an exception.

Code sample

Code sample
    return SvgPicture.asset(
      assetPath,
      width: width,
      height: height,
      colorFilter: ColorFilter.mode(color ?? Colors.black, BlendMode.srcIn),
      semanticsLabel: 'My Label',
    );
Resolution
return Directionality(
      textDirection: TextDirection.ltr,
      child: SvgPicture.asset(
        assetPath,
        width: width,
        height: height,
        colorFilter: ColorFilter.mode(color ?? Colors.black, BlendMode.srcIn),
        semanticsLabel: 'My Label',
      ),
    );

Screenshots or Video

Screenshots / Video demonstration

N/A

Logs

Logs
══╡ EXCEPTION CAUGHT BY SCHEDULER LIBRARY ╞═════════════════════════════════════════════════════════
The following assertion was thrown during a scheduler callback:
A SemanticsData object with label "TRACER Logo" had a null textDirection.
'package:flutter/src/semantics/semantics.dart':
Failed assertion: line 959 pos 10: 'attributedLabel.string == '' || textDirection != null'

Either the assertion indicates an error in the framework itself, or we should provide substantially
more information in this error message to help you determine and fix the underlying cause.
In either case, please report this assertion by filing a bug on GitHub:
  https://github.com/flutter/flutter/issues/new?template=02_bug.yml

When the exception was thrown, this was the stack:
#2      new SemanticsData (package:flutter/src/semantics/semantics.dart:959:10)
#3      SemanticsNode.getSemanticsData (package:flutter/src/semantics/semantics.dart:3537:12)
#4      SemanticsNode._addToUpdate (package:flutter/src/semantics/semantics.dart:3581:32)
#5      SemanticsOwner.sendSemanticsUpdate (package:flutter/src/semantics/semantics.dart:4345:14)
#6      PipelineOwner.flushSemantics (package:flutter/src/rendering/object.dart:1499:24)
#7      PipelineOwner.flushSemantics (package:flutter/src/rendering/object.dart:1501:15)
#8      RendererBinding.drawFrame (package:flutter/src/rendering/binding.dart:636:25)
#9      WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:1261:13)
#10     RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:495:5)
#11     SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1434:15)
#12     SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1347:9)
#13     SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:1200:5)
#14     _invoke (dart:ui/hooks.dart:330:13)
#15     PlatformDispatcher._drawFrame (dart:ui/platform_dispatcher.dart:444:5)
#16     _drawFrame (dart:ui/hooks.dart:302:31)
(elided 2 frames from class _AssertionError)
════════════════════════════════════════════════════════════════════════════════════════════════════

flutter: unhandled element <style/>; Picture key: Svg loader

Flutter Doctor output

Doctor output
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.35.4, on macOS 15.6.1 24G90 darwin-arm64, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 36.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 16.4)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2025.1)
[✓] IntelliJ IDEA Ultimate Edition (version 2025.1.5.1)
[✓] Connected device (4 available)
[✓] Network resources

• No issues found!

Activity

  1. darshankawar commented on Sep 18, 2025

    @darshankawar
    Member

    @jtanium
    I tried with complete runnable code including your code snippet which worked properly without throwing the reported error.

    code
    
    import 'package:flutter/material.dart';
    import 'package:flutter_svg/flutter_svg.dart';
    
    void main() {
      runApp(const MyApp());
    }
    
    class MyApp extends StatelessWidget {
      const MyApp({super.key});
      @override
      Widget build(BuildContext context) {
        return MaterialApp(
          title: 'Flutter Demo',
          theme: ThemeData(primarySwatch: Colors.blue),
          home: const MyHomePage(title: 'Flutter Demo Home Page'),
        );
      }
    }
    
    class MyHomePage extends StatelessWidget {
      const MyHomePage({Key? key, required this.title}) : super(key: key);
      final String title;
      @override
      Widget build(BuildContext context) {
        return SvgPicture.asset(
          "assets/search.svg",
          width: 100,
          height: 100,
          colorFilter: ColorFilter.mode(Colors.yellow ?? Colors.black, BlendMode.srcIn),
          semanticsLabel: 'My Label',
          // clipBehavior: Clip.antiAlias,
        );
      }
    }
    
    search.svg:
    
    <svg width="25" height="25" viewBox="0 0 25 25" fill="none" xmlns="http://www.w3.org/2000/svg">
        <path d="M18 9.75C18 6.84375 16.4062 4.125 13.875 2.625C11.2969 1.17188 8.15625 1.17188 5.625 2.625C3.04688 4.125 1.5 6.84375 1.5 9.75C1.5 12.7031 3.04688 15.4219 5.625 16.9219C8.15625 18.375 11.2969 18.375 13.875 16.9219C16.4062 15.4219 18 12.7031 18 9.75ZM16.0781 17.1562C14.3906 18.6562 12.1406 19.5 9.75 19.5C4.35938 19.5 0 15.1406 0 9.75C0 4.40625 4.35938 0 9.75 0C15.0938 0 19.5 4.40625 19.5 9.75C19.5 12.1875 18.6094 14.3906 17.1562 16.125L23.7656 22.7344C24.0469 23.0156 24.0469 23.5312 23.7656 23.8125C23.4844 24.0938 22.9688 24.0938 22.6875 23.8125L16.0781 17.1562Z" fill="#001744"/>
    </svg>
    
    

    Please check this code and see if using it you still get same error or not. If not, please provide us complete runnable code including the asset you are using.

  2. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Sep 18, 2025
  3. jtanium commented on Sep 18, 2025

    @jtanium
    Author

    @darshankawar I don't think this is a problem worth spending a lot of time on. I was getting the stacktrace in the console, but it didn't really seem to affect my app. The stacktrace message just asked to file an issue, so I thought I would put it out here, along with my fix to help someone in the future; and maybe someone would recognize the problem easily.

  4. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Sep 18, 2025
  5. darshankawar commented on Sep 19, 2025

    @darshankawar
    Member

    Thanks for the feedback. I tried again by using attributedLabel and wrapping the code with Semantics but couldn't replicate the reported behavior. Based on the stacktrace though, I'll keep the issue open for team's tracking.

  6. added
    p: flutter_svgThe Flutter SVG drawing packages
    packageflutter/packages repository. See also p: labels.
    a: error messageError messages from the Flutter framework
    c: crashStack traces logged to the console
    frameworkflutter/packages/flutter repository. See also f: labels.
    workaround availableThere is a workaround available to overcome the issue
    and removed
    in triagePresently being triaged by the triage team
    on Sep 19, 2025
  7. jtanium commented on Sep 19, 2025

    @jtanium
    Author
  8. added
    a: accessibilityAccessibility, e.g. VoiceOver or TalkBack. (aka a11y)
    P2Important issues not at the top of the work list
    on Oct 7, 2025
  9. mbcorona commented on Jun 23, 2026

    @mbcorona
    Member

    Adding code sample that reproduces this issue

    import 'package:flutter/widgets.dart';
    import 'package:flutter_svg/flutter_svg.dart';
    
    const String _svg =
        '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24">'
        '<rect width="24" height="24" fill="black"/></svg>';
    
    void main() {
      // Enable the semantics tree so SemanticsData is built and flushed.
      WidgetsFlutterBinding.ensureInitialized().ensureSemantics();
    
      // NOTE: deliberately NO MaterialApp / WidgetsApp / Directionality ancestor.
      runApp(
        SvgPicture.string(
          _svg,
          semanticsLabel: 'My Label', // non-empty label, no text direction in scope
        ),
      );
    }
  10. self-assigned this
    on Jun 23, 2026
  11. added a commit that references this issue on Jul 31, 2026
    caddb39
  12. github-actions commented on Aug 14, 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.

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

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work lista: accessibilityAccessibility, e.g. VoiceOver or TalkBack. (aka a11y)a: error messageError messages from the Flutter frameworkc: crashStack traces logged to the consoleframeworkflutter/packages/flutter repository. See also f: labels.p: flutter_svgThe Flutter SVG drawing packagespackageflutter/packages repository. See also p: labels.team-frameworkOwned by Framework teamtriaged-frameworkTriaged by Framework teamworkaround availableThere is a workaround available to overcome the issue

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions