Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/flutter_markdown/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## NEXT
## 0.7.3+1

* Fixes issue with table column alignments not being respected.
* Updates minimum supported SDK version to Flutter 3.19/Dart 3.3.

## 0.7.3
Expand Down
10 changes: 9 additions & 1 deletion packages/flutter_markdown/lib/src/builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,15 @@ class MarkdownBuilder implements md.NodeVisitor {
child: DefaultTextStyle(
style: styleSheet.tableBody!,
textAlign: textAlign,
child: Wrap(children: children as List<Widget>),
child: Wrap(
alignment: switch (textAlign) {
TextAlign.left => WrapAlignment.start,
TextAlign.center => WrapAlignment.center,
TextAlign.right => WrapAlignment.end,
_ => WrapAlignment.start,
},
children: children as List<Widget>,
),
),
),
);
Expand Down
2 changes: 1 addition & 1 deletion packages/flutter_markdown/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: A Markdown renderer for Flutter. Create rich text output,
formatted with simple Markdown tags.
repository: https://github.com/flutter/packages/tree/main/packages/flutter_markdown
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+flutter_markdown%22
version: 0.7.3
version: 0.7.3+1

environment:
sdk: ^3.3.0
Expand Down
19 changes: 19 additions & 0 deletions packages/flutter_markdown/test/table_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,25 @@ void defineTests() {
},
);

testWidgets(
'should work with table alignments',
(WidgetTester tester) async {
const String data =
'|Header 1|Header 2|Header 3|\n|:----|:----:|----:|\n|Col 1|Col 2|Col 3|';
await tester.pumpWidget(
boilerplate(
const MarkdownBody(data: data),
),
);

final Iterable<Wrap> wraps = tester.widgetList(find.byType(Wrap));

expect(wraps.first.alignment, WrapAlignment.start);
expect(wraps.elementAt(1).alignment, WrapAlignment.center);
expect(wraps.last.alignment, WrapAlignment.end);
},
);

testWidgets(
'should work with styling',
(WidgetTester tester) async {
Expand Down