How do I disable flex on a datatable styled as list view?

I have the following datatable, with style_as_list_view=True:

But I want it to look like this, so it only takes up the space it needs to:

I seem to be able to get it the way I want by disabling flex in the element’s properties:

How do I set this property in the python code?