I somewhat completed the part to add playlist and its video matching conditions.
The idea is for the back end to wait for new video then match it by channel and a text in the title / description and add it to a playlist.
From the back-end server’s perspective, it is best to store the conditions as rows to easily query them.
From the front-end client’s perspective, the user might want to use multiple matching text per one channel or vice versa, and I wanted the dialog UI to work even if the user enters duplicate data, etc. So I converted the list of conditions to list of condition groups, then use it to generate fields and buttons in table rows to manage the layout. It’ll convert the format back when the dialog closes.
I had some issues with the width of the text field, but restricting the total width of the table and adding the Flexible widget around the field solved it.
The main issue I ran into was that the text inside those fields didn’t update as I deleted condition entries. Using a UniqueKey to force an update every setState worked, but it would also defocus the field once a letter is typed (you have to click again to type more). I ended up creating a TextEditingController for each field, then store them in a list mirroring the structure of the text data (+1 more for each new field), then delete the one in the same location of the text data that I am deleting.
I messed around a lot with alternatives until I settled on these solutions that kinda works, but the current implementation is not very scalable, so I’ll rewrite it again with custom classes and see if I can make it better.