Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: wrap ListTile in material widget #4206

Merged
merged 1 commit into from
Oct 29, 2024

Conversation

OwenMcDonnell
Copy link
Contributor

@OwenMcDonnell OwenMcDonnell commented Oct 21, 2024

Description

As mentioned in flutter docs ListTile

...requires a Material widget ancestor in the tree to paint itself on, which is typically provided by the app's Scaffold. The tileColor, selectedTileColor, focusColor, and hoverColor are not painted by the ListTile itself but by the Material widget ancestor.

Fixes #4095

Test Code

import flet as ft

def main(page: ft.Page):

    page.add(
        ft.Container(
            shadow=ft.BoxShadow(color=ft.colors.PINK_400, blur_radius=10),
            border=ft.Border(
                top=ft.BorderSide(width=2, color=ft.colors.GREY_200),
                bottom=ft.BorderSide(width=2, color=ft.colors.GREY_200),
                right=ft.BorderSide(width=2, color=ft.colors.GREY_200),
                left=ft.BorderSide(width=2, color=ft.colors.GREY_200),
            ),
            border_radius=5,
            bgcolor="green",
            content=ft.ListTile(
                bgcolor="blue",
                selected=False,
                title=ft.Text('This is a test'),
                hover_color='red',
                on_click=lambda e: print('Test')
            )
        )
    )

ft.app(target=main)

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • I signed the CLA.
  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • My changes generate no new warnings

@OwenMcDonnell OwenMcDonnell changed the title wrap ListTile in material widget fix: wrap ListTile in material widget Oct 21, 2024
@FeodorFitsner FeodorFitsner merged commit cc3b29e into flet-dev:main Oct 29, 2024
2 checks passed
pengwon added a commit to pengwon/flet that referenced this pull request Oct 30, 2024
* main: (31 commits)
  Migrate `colors` and `icons` variables to Enums (flet-dev#4180)
  feat: expose more properties in Controls (flet-dev#4105)
  feat!: Refactor `Badge` Control to a Dataclass; create new `Control.badge` property (flet-dev#4077)
  fix: clicking on `CupertinoContextMenuAction` doesn't close context menu (flet-dev#3948)
  fix dropdown `max_menu_height` (flet-dev#3974)
  Fix undefined name "Future" --> asyncio.Future (flet-dev#4230)
  wrap ListTile in material widget (flet-dev#4206)
  Update CONTRIBUTING.md (flet-dev#4208)
  TextField: suffix_icon, prefix_icon and icon can be Control or str (flet-dev#4173)
  feat!: enhance `Map` control (flet-dev#3994)
  skip running flutter doctor on windows if no_rich_output is True (flet-dev#4108)
  add --pyinstaller-build-args to pack cli command (flet-dev#4187)
  fix/feat: make `SearchBar`'s view height adjustable; add new properties (flet-dev#4039)
  fix: prevent button `style` from being modified in `before_update()` (flet-dev#4181)
  fix: disabling filled buttons is not visually respected (flet-dev#4090)
  when `label` is set, use `MainAxisSize.min` for the `Row` (flet-dev#3998)
  fix: `NavigationBarDestination.disabled` has no visual effect (flet-dev#4073)
  fix autofill in CupertinoTextField (flet-dev#4103)
  Linechart: jsonDecode tooltip before displaying (flet-dev#4069)
  fixed bgcolor, color and elevation (flet-dev#4126)
  ...
@ClearSafety
Copy link

Thank you for attending to this issue ticket.
I'm not sure I understood the solution.
According to what was mentioned in the 'Description', ListTile requires a material ancestor to manage colours. Does Flet provides any control that could work as material ancestor for ListTile to deal with its colours renderization?

@ndonkoHenri
Copy link
Contributor

ndonkoHenri commented Oct 30, 2024

@ClearSafety try the latest pre-release: pip install flet --pre -U
Simply rerun your app and let us know.
Don't mind the description.

@ClearSafety
Copy link

@ndonkoHenri I did it and got the version 0.25.0.dev3614.
But for some reason, when I try to run the app, it arises an error in Terminal.
When I come back to the version 0.24.1, the app run smothely.

WARNING: Failed to write executable - trying to use .deleteme logic
Traceback (most recent call last):
File "", line 198, in run_module_as_main
File "", line 88, in run_code
File "C:\Users\RafaelOliveira\AppData\Local\Programs\Python\Python312\Scripts\flet.exe_main.py", line 7, in
File "C:\Users\RafaelOliveira\AppData\Local\Programs\Python\Python312\Lib\site-packages\flet\cli.py", line 24, in main
flet_cli.cli.main()
File "C:\Users\RafaelOliveira\AppData\Local\Programs\Python\Python312\Lib\site-packages\flet_cli\cli.py", line 88, in main
args.handler(args)
File "C:\Users\RafaelOliveira\AppData\Local\Programs\Python\Python312\Lib\site-packages\flet_cli\commands\run.py", line 144, in handle
from flet_desktop import close_flet_view
File "C:\Users\RafaelOliveira\AppData\Local\Programs\Python\Python312\Lib\site-packages\flet_desktop_init.py", line 14, in
from flet_core.utils import (
ImportError: cannot import name 'get_arch' from 'flet_core.utils' (C:\Users\RafaelOliveira\AppData\Local\Programs\Python\Python312\Lib\site-packages\flet_core\utils_init_.py)

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.

Container overlapping ListTile properties
4 participants