Skip to content

Commit

Permalink
Fixes leading/trailing widgets not centered in listTile (#940)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdlukaa authored Oct 7, 2023
2 parents abb4df6 + 26c0a20 commit 1b4fadf
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## [next]

* fix: items not aligned centered in listtile ([#939](https://github.com/bdlukaa/fluent_ui/issues/939))
+ added `contentAlignment` to `ListTile`
* Added `contentPadding` to `ListTile`

## 4.7.5

* fix: do not enforce a tree view item on `TreeView` ([#934](https://github.com/bdlukaa/fluent_ui/issues/934))
Expand Down
20 changes: 17 additions & 3 deletions lib/src/controls/surfaces/list_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ class ListTile extends StatelessWidget {
this.autofocus = false,
this.semanticLabel,
this.cursor,
this.contentAlignment = CrossAxisAlignment.center,
this.contentPadding = kDefaultListTilePadding,
}) : assert(
subtitle != null ? title != null : true,
'To have a subtitle, there must be a title',
Expand All @@ -67,6 +69,8 @@ class ListTile extends StatelessWidget {
this.onSelectionChange,
this.semanticLabel,
this.cursor,
this.contentAlignment = CrossAxisAlignment.center,
this.contentPadding = kDefaultListTilePadding,
}) : assert(
subtitle != null ? title != null : true,
'To have a subtitle, there must be a title',
Expand Down Expand Up @@ -154,6 +158,16 @@ class ListTile extends StatelessWidget {
/// * [SystemMouseCursors.click], which turns the mouse cursor to click
final MouseCursor? cursor;

/// How the children should be placed along the cross axis in a flex layout.
///
/// Defaults to CrossAxisAlignment.center
final CrossAxisAlignment contentAlignment;

/// Padding applied to list tile content
///
/// Defaults to [kDefaultListTilePadding]
final EdgeInsetsGeometry contentPadding;

@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);
Expand Down Expand Up @@ -217,7 +231,7 @@ class ListTile extends StatelessWidget {
const placeholder = SizedBox(width: 12.0);

final tile = Row(
crossAxisAlignment: CrossAxisAlignment.start,
crossAxisAlignment: contentAlignment,
children: [
if (leading != null)
Padding(
Expand Down Expand Up @@ -299,7 +313,7 @@ class ListTile extends StatelessWidget {
builder: (context, height, child) => Center(
child: Padding(
padding: EdgeInsets.symmetric(
vertical: kDefaultListTilePadding.vertical,
vertical: contentPadding.vertical,
),
child: Container(
height: height * 0.7,
Expand All @@ -322,7 +336,7 @@ class ListTile extends StatelessWidget {
placeholder,
Expanded(
child: Padding(
padding: kDefaultListTilePadding,
padding: contentPadding,
child: tile,
),
),
Expand Down

0 comments on commit 1b4fadf

Please sign in to comment.