Skip to content

Commit 77d9eb3

Browse files
committed
[vector_graphics] Provide textDirection for semantics label to avoid crash without Directionality
1 parent 7d84a69 commit 77d9eb3

4 files changed

Lines changed: 21 additions & 2 deletions

File tree

packages/vector_graphics/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
## NEXT
1+
## 1.2.3
22

33
* Updates minimum supported SDK version to Flutter 3.38/Dart 3.10.
4+
* Fixes a crash when a `semanticsLabel` is provided without an ambient `Directionality` (flutter/flutter#175532).
45

56
## 1.2.2
67

packages/vector_graphics/lib/src/vector_graphics.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,7 @@ class _VectorGraphicWidgetState extends State<VectorGraphic> {
538538
container: widget.semanticsLabel != null,
539539
image: true,
540540
label: widget.semanticsLabel ?? '',
541+
textDirection: Directionality.maybeOf(context) ?? TextDirection.ltr,
541542
child: child,
542543
);
543544
}

packages/vector_graphics/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: vector_graphics
22
description: A vector graphics rendering package for Flutter using a binary encoding.
33
repository: https://github.com/flutter/packages/tree/main/packages/vector_graphics
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+vector_graphics%22
5-
version: 1.2.2
5+
version: 1.2.3
66

77
environment:
88
sdk: ^3.10.0

packages/vector_graphics/test/vector_graphics_test.dart

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,23 @@ void main() {
415415
);
416416
});
417417

418+
testWidgets('Semantic label works without an ambient Directionality (flutter/flutter#175532)', (
419+
WidgetTester tester,
420+
) async {
421+
final testBundle = TestAssetBundle();
422+
423+
await tester.pumpWidget(
424+
DefaultAssetBundle(
425+
bundle: testBundle,
426+
child: const VectorGraphic(loader: AssetBytesLoader('foo.svg'), semanticsLabel: 'Foo'),
427+
),
428+
);
429+
await tester.pumpAndSettle();
430+
431+
expect(tester.takeException(), isNull);
432+
expect(find.bySemanticsLabel('Foo'), findsOneWidget);
433+
});
434+
418435
testWidgets('Default placeholder builder', (WidgetTester tester) async {
419436
final testBundle = TestAssetBundle();
420437

0 commit comments

Comments
 (0)