Skip to main content

TileAffinity

Where to place a control in controls that use ListTile to position a control next to a label.

Inherits: enum.Enum

Properties

  • LEADING - Positions the control on the leading edge, and the secondary control, if any, on the trailing edge.
  • PLATFORM - Positions the control relative to the text in the fashion that is typical for the current platform, and place the secondary control on the opposite side.
  • TRAILING - Positions the control on the trailing edge, and the secondary control, if any, on the leading edge.

Examples

Showcase

import flet as ft


def showcase_card(affinity: ft.TileAffinity) -> ft.Container:
tile = ft.ExpansionTile(
title="Project settings",
subtitle="Compare where the expand arrow appears.",
affinity=affinity,
expanded=True,
controls=[
ft.ListTile(title="General"),
ft.ListTile(title="Notifications"),
],
)

return ft.Container(
width=360,
padding=12,
border=ft.Border.all(1, ft.Colors.RED),
border_radius=10,
bgcolor=ft.Colors.SURFACE_CONTAINER_LOW,
content=ft.Column(
spacing=8,
controls=[
ft.Text(affinity.name, weight=ft.FontWeight.BOLD),
tile,
],
),
)


def main(page: ft.Page):
page.horizontal_alignment = ft.CrossAxisAlignment.CENTER

page.appbar = ft.AppBar(title="TileAffinity Showcase")
page.add(
ft.SafeArea(
content=ft.Column(
controls=[
ft.Text("Compare expand-arrow placement in ExpansionTile."),
ft.Row(
wrap=True,
spacing=12,
expand=True,
scroll=ft.ScrollMode.AUTO,
alignment=ft.MainAxisAlignment.CENTER,
controls=[
showcase_card(affinity) for affinity in ft.TileAffinity
],
),
],
),
)
)


if __name__ == "__main__":
ft.run(main)

Properties

LEADINGclass-attributeinstance-attribute

Positions the control on the leading edge, and the secondary control, if any, on the trailing edge.

PLATFORMclass-attributeinstance-attribute

Positions the control relative to the text in the fashion that is typical for the current platform, and place the secondary control on the opposite side.

TRAILINGclass-attributeinstance-attribute

Positions the control on the trailing edge, and the secondary control, if any, on the leading edge.