Heat butter in a pan. Add garlic and sauté for a few seconds until fragrant.
Add onions and green chilies (if using) and sauté until translucent.
Stir in the flour and cook for 1 minute on low flame.
Slowly add milk while stirring to avoid lumps.
Once the mixture thickens, add chopped spinach and boiled corn.
Add salt, pepper, chili flakes, and herbs. Mix well.
Add grated cheese and mix until it melts into a creamy mixture.
Let the filling cool for 5–10 minutes.