You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a parent Container which I add child controls dynamically with different sizes,
I don't want my parent to allocate all the page's available space so I use tight=True
The parent Container adapt itself to largest child control as i wanted
But i want my child controls expand their parent's (not page) size
I don't want to assign a width value to my parent because I am adding dynamic child controls
which their sizes may vary
The code below is an example;
There is a large control added which determines the parent width
And there is a relatively small row containing 2 controls, i want one of them at left, and other at the right edge of parent
So i use the SPACE_BETWEEN alignment option
But it does'nt work probably because the row is not allocating the available width of the parent Container
And when I use expand=True option to the row, it all gets messy
Any ideas how can I achieve this
Code sample
importfletasftdefmain(page: ft.Page):
# rootpage.vertical_alignment=ft.MainAxisAlignment.CENTERpage.horizontal_alignment=ft.CrossAxisAlignment.CENTER# parent Controlparent_container=ft.Container(border=ft.border.all(color=ft.colors.PRIMARY))
parent_container.content=ft.Column(tight=True, horizontal_alignment=ft.CrossAxisAlignment.CENTER)
# child Controlslarge_control=ft.Text(value='I am a large Title', style=ft.TextThemeStyle.HEADLINE_MEDIUM)
small_control_1=ft.Text(value='SC1')
small_control_2=ft.Text(value='SC2')
row=ft.Row(controls=[small_control_1, small_control_2],
alignment=ft.MainAxisAlignment.SPACE_BETWEEN,
# expand=True (gets messy)tight=True)
# add child to parent's contentparent_container.content.controls.append(large_control)
parent_container.content.controls.append(row)
# add parent to rootpage.add(parent_container)
app=ft.app(target=main, view=ft.WEB_BROWSER)
I have searched for answers to my question both in the issues and in previous discussions.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Question
I have a parent Container which I add child controls dynamically with different sizes,
I don't want my parent to allocate all the page's available space so I use
tight=True
The parent Container adapt itself to largest child control as i wanted
But i want my child controls expand their parent's (not page) size
I don't want to assign a width value to my parent because I am adding dynamic child controls
which their sizes may vary
The code below is an example;
There is a large control added which determines the parent width
And there is a relatively small row containing 2 controls, i want one of them at left, and other at the right edge of parent
So i use the
SPACE_BETWEEN
alignment optionBut it does'nt work probably because the row is not allocating the available width of the parent Container
And when I use
expand=True
option to the row, it all gets messyAny ideas how can I achieve this
Code sample
Beta Was this translation helpful? Give feedback.
All reactions