Skip to content

feat: make NavigationDrawerDestination.label accept custom controls#6395

Open
ndonkoHenri wants to merge 12 commits intorelease/v0.85.0from
nav-drawer-label
Open

feat: make NavigationDrawerDestination.label accept custom controls#6395
ndonkoHenri wants to merge 12 commits intorelease/v0.85.0from
nav-drawer-label

Conversation

@ndonkoHenri
Copy link
Copy Markdown
Contributor

@ndonkoHenri ndonkoHenri commented Apr 8, 2026

Fix #6379

Test Code

import flet as ft


def main(page: ft.Page):
    async def handle_show_drawer():
        await page.show_drawer()

    page.drawer = ft.NavigationDrawer(
        controls=[
            ft.NavigationDrawerDestination(
                icon=ft.Icon(ft.Icons.MAIL_OUTLINED),
                label=ft.Text("Item 2", color=ft.colors.RED_500),
                selected_icon=ft.Icons.MAIL,
            ),
            ft.NavigationDrawerDestination(
                icon=ft.Icon(ft.Icons.PHONE_OUTLINED),
                label="Item 3",
                selected_icon=ft.Icons.PHONE,
            ),
        ],
    )

    page.add(
        ft.SafeArea(
            content=ft.Button(
                content="Show drawer",
                on_click=handle_show_drawer,
            )
        )
    )


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

Summary by Sourcery

Make NavigationDrawerDestination labels accept controls and enhance navigation drawer theming and examples.

New Features:

  • Allow NavigationDrawerDestination.label to be specified as either text or a custom control.
  • Add state-based icon theming support to NavigationDrawerTheme for navigation drawer icons.
  • Introduce adaptive navigation and theming examples for NavigationDrawer, NavigationBar, and NavigationRail in the Python SDK and documentation.

Enhancements:

  • Improve NavigationDrawer defaults and documentation, including default tile padding and clarified property descriptions.
  • Refactor Flutter control utilities to better build icons/labels from controls and simplify visual density parsing.
  • Update integration tests to capture screenshots for new navigation drawer theming and adaptive navigation examples.

Build:

  • Ensure website docs task installs front-end dependencies before running the dev server.

Documentation:

  • Expand NavigationDrawer, NavigationBar, and NavigationRail docs with theming and adaptive navigation examples and imagery.

Tests:

  • Add golden-style integration tests for navigation drawer theming and adaptive navigation layouts.

Chores:

  • Add pyproject metadata for new NavigationDrawer theming and adaptive navigation example apps.

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've reviewed this pull request using the Sourcery rules engine

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages bot commented Apr 8, 2026

Deploying flet-website-v2 with  Cloudflare Pages  Cloudflare Pages

Latest commit: 3e7c4a1
Status: ✅  Deploy successful!
Preview URL: https://9911f00d.flet-website-v2.pages.dev
Branch Preview URL: https://nav-drawer-label.flet-website-v2.pages.dev

View logs

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages bot commented Apr 8, 2026

Deploying flet-examples with  Cloudflare Pages  Cloudflare Pages

Latest commit: 3e7c4a1
Status: ✅  Deploy successful!
Preview URL: https://57200613.flet-examples.pages.dev
Branch Preview URL: https://nav-drawer-label.flet-examples.pages.dev

View logs

@ndonkoHenri ndonkoHenri changed the title feat: make NavigationDrawerDestination.label more customizable feat: make NavigationDrawerDestination.label accept custom controls Apr 8, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR expands NavigationDrawerDestination.label to support passing a Control (e.g., ft.Text(...)) for richer label customization, and adds NavigationDrawer theming capabilities (state-based label text styles and icon theme) alongside new documentation/examples.

Changes:

  • Allow NavigationDrawerDestination.label to be a string or a Control, and update Flutter rendering to build label widgets via buildTextOrWidget().
  • Add NavigationDrawerTheme.icon_theme parsing/handling to enable state-based icon theming for drawer destinations.
  • Add new docs/examples (theming + adaptive navigation) and golden assets; extend integration tests to generate/update screenshots/GIFs.

Reviewed changes

Copilot reviewed 14 out of 31 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
website/docs/controls/navigationrail/index.md Adds adaptive navigation example reference and GIF.
website/docs/controls/navigationdrawer/index.md Improves image alt text; adds theming + adaptive navigation examples.
website/docs/controls/navigationbar/index.md Adds adaptive navigation example reference and GIF.
sdk/python/Taskfile.yml Ensures website deps are installed before yarn start.
sdk/python/packages/flet/src/flet/controls/theme.py Documents label selected state styling; adds NavigationDrawerTheme.icon_theme.
sdk/python/packages/flet/src/flet/controls/material/navigation_drawer.py Updates API/docs for destinations; changes tile_padding default; updates docs/examples in docstrings.
sdk/python/packages/flet/integration_tests/examples/material/test_navigation_drawer.py Adds theming + adaptive navigation screenshot/GIF tests; updates docs screenshot setup.
sdk/python/packages/flet/integration_tests/examples/material/golden/macos/navigation_drawer/* Adds/updates golden images/GIFs for new/updated examples.
sdk/python/examples/controls/navigation_drawer/theming/* New theming example demonstrating label/icon theming.
sdk/python/examples/controls/navigation_drawer/adaptive_navigation/* New adaptive navigation example (NavigationBar ↔ NavigationRail + end drawer).
packages/flet/lib/src/utils/theme.dart Parses NavigationDrawerThemeData.iconTheme from icon_theme.
packages/flet/lib/src/extensions/control.dart Extends buildIconOrWidget() with required / error handling options.
packages/flet/lib/src/controls/navigation_drawer.dart Uses buildTextOrWidget() for labels; enforces icon via required: true.
client/pubspec.lock Bumps transitive test deps (matcher, test_api).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ndonkoHenri ndonkoHenri changed the base branch from main to release/v0.85.0 April 8, 2026 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: Add a way to change the color of the label in the NavigationDrawerDestination

2 participants