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 container.dart for issue #2628 #2701

Merged
merged 8 commits into from
Feb 29, 2024
Merged

Conversation

isaffathir
Copy link
Contributor

@isaffathir isaffathir commented Feb 21, 2024

Closes #2628
The Ink or InkWell widget must have a Material widget as an ancestor.

seems container.dart doesn't have:

var ink = Ink(
decoration: boxDecor,
child: InkWell(

so i try to wrap InkWell with Material :
https://github.com/flet-dev/flet/pull/2701/files#diff-3d2babe2e48d8eaf9b1c35294b8c498c905a03e16f8e490258b215a98e5ec568R151-R154

i also remove Ink cause Flet already use Container as parent, because Container can take a BoxDecoration as i read this

This is how i fix this issue, hopefully it will help.

@isaffathir
Copy link
Contributor Author

2024-02-21.10-31-55.mp4

Test Code:

import flet as ft

def main(page: ft.Page):
    page.vertical_alignment = ft.MainAxisAlignment.CENTER
    page.horizontal_alignment = ft.CrossAxisAlignment.CENTER
    page.theme_mode = ft.ThemeMode.DARK
    button = ft.Container(
        bgcolor=ft.colors.GREEN,
        content=ft.Icon(ft.icons.MENU_BOOK_ROUNDED, color=ft.colors.BLUE, size=30),
        padding=18,
        alignment=ft.alignment.center,
        border_radius=20,
        border=ft.Border(
            top=ft.BorderSide(width=2, color=ft.colors.RED),
            left=ft.BorderSide(width=2, color=ft.colors.RED),
            bottom=ft.BorderSide(width=2, color=ft.colors.RED),
            right=ft.BorderSide(width=2, color=ft.colors.RED),
        ),
        shadow=ft.BoxShadow(
            blur_radius=20,
            color=ft.colors.YELLOW_ACCENT_700,
            blur_style=ft.ShadowBlurStyle.OUTER,
        ),
        on_click=lambda e: print("Clicked"),
        ink=True,
        bottom=20,
        right=20,
    )
    simply_container = ft.Container(
        bgcolor=ft.colors.with_opacity(1, ft.colors.BLACK),
        height=page.height * 0.8,
        width=page.width * 0.8,
        bottom=20,
        right=40,
    )

    stack = ft.Stack(controls=[simply_container, button], expand=True)
    page.add(stack)


ft.app(target=main)

@ndonkoHenri
Copy link
Collaborator

Thanks @isaffathir.

But each new/non-existing dart property you add should be "exposed" in Flet's python API. Just like you did in the first PR.

@isaffathir
Copy link
Contributor Author

isaffathir commented Feb 21, 2024

Thanks @isaffathir.

But each new/non-existing dart property you add should be "exposed" in Flet's python API. Just like you did in the first PR.

Material is imported from material.dart

import 'package:flutter/material.dart';

i just wrap InkWell with Material. are this new? let me know if im wrong answer or misunderstand

@lekshmanmj
Copy link
Contributor

Thanks @isaffathir for fixing the bug and that too immediately when I mentioned you with this issue.

@ndonkoHenri
Copy link
Collaborator

i just wrap InkWell with Material. are this new? let me know if im wrong answer or misunderstand

Ah, i forgot to check which issue you were trying to fix.

@isaffathir
Copy link
Contributor Author

As suggestion from this that need transparent Material also here, yes we can use Ink if don't want use Material instead,but because flet add Container as parent for the return using Ink as a child will cause #2628 problem,thats why need transparent Material as ancestor

@FeodorFitsner FeodorFitsner merged commit d10010c into flet-dev:main Feb 29, 2024
2 checks passed
zrr1999 pushed a commit to zrr1999/flet that referenced this pull request Jul 17, 2024
* initial commit

* add mouseCursor and delete not needed event

* Update ink_well.py

* Fix container.dart

The Ink or InkWell widget must have a Material widget as an ancestor.

* Revert change,duplicate control InkWell

Flet already use InkWell on container.dart

* Add on_release (Callback after click)

* Add ink_color
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 Issue when ink = True
4 participants