Skip to content

Commit

Permalink
Issues/58053 - Set default textBaseline to alphabetic in the Table wi…
Browse files Browse the repository at this point in the history
…dget (flutter#60586)
  • Loading branch information
ramnavan authored Jul 6, 2020
1 parent de205ec commit 60deae8
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,4 @@ Brian Wang <[email protected]>
法的空间 <[email protected]>
CaiJingLong <[email protected]>
Alex Li <[email protected]>
Ram Navan <[email protected]>
4 changes: 3 additions & 1 deletion packages/flutter/lib/src/widgets/table.dart
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class Table extends RenderObjectWidget {
this.textDirection,
this.border,
this.defaultVerticalAlignment = TableCellVerticalAlignment.top,
this.textBaseline,
this.textBaseline = TextBaseline.alphabetic,
}) : assert(children != null),
assert(defaultColumnWidth != null),
assert(defaultVerticalAlignment != null),
Expand Down Expand Up @@ -201,6 +201,8 @@ class Table extends RenderObjectWidget {
final TableCellVerticalAlignment defaultVerticalAlignment;

/// The text baseline to use when aligning rows using [TableCellVerticalAlignment.baseline].
///
/// Defaults to [TextBaseline.alphabetic].
final TextBaseline textBaseline;

final List<Decoration> _rowDecorations;
Expand Down
24 changes: 24 additions & 0 deletions packages/flutter/test/widgets/table_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -932,5 +932,29 @@ void main() {
},
);

testWidgets(
'Table widget - Default textBaseline is set to TableBaseline.alphabetic',
(WidgetTester tester) async {
await tester.pumpWidget(
Directionality(
textDirection: TextDirection.ltr,
child: Table(
defaultVerticalAlignment: TableCellVerticalAlignment.baseline,
children: const <TableRow>[
TableRow(
children: <Widget>[
Text('Some Text'),
],
),
],
),
),
);

final RenderTable table = tester.renderObject(find.byType(Table));
expect(table.textBaseline, TextBaseline.alphabetic);
},
);

// TODO(ianh): Test handling of TableCell object
}

0 comments on commit 60deae8

Please sign in to comment.