Although I really like indoor plants, in my honest opinion, they have no way to prevent pests.
Most pests are attracted by wet environments. If your soil is constantly wet, I bet there will be flies. If the soil contains organic substance, there will be other bugs too.
I can't see if you have a tray under the container. If there isn't a tray to hold the excess water, you can't release the excess water. And if there is a tray, you should remove the water from it regularly.
Second, you may review your soil. You should buy soil that comes in a loose shape, instead of a black soil block. For example, I always use the following kind of soil if I don't want bugs in my soil:
It is free of bugs and it contains a fair amount of perlite and vermiculite, which helps to improve drainage. Thus it is good to prevent fly-like creatures. If you don't know which type of soil should you buy in the shop, you can check the soil made for African Violets. They have higher standards to regulate the property of the soil. Check this.
Lastly, I don't recommend using such a big container because it is harder to maintain. You may consider using individual pots.