We add just a touch of sugar to enhance the sweetness of the corn and onion. The texture falls somewhere between a pudding and a soufflé—rich and custardy, with bubbles of air within. It's best served piping hot, but cold leftovers are good, too.
Preheat oven to 350°F with oven rack in middle of oven. Lightly coat a 13- x 9-inch glass or ceramic baking dish with cooking spray. Melt butter in a large skillet over medium-high until foamy. Add corn, onion, thyme, and garlic; cook, stirring occasionally, until lightly browned, 7 to 9 minutes. Remove from heat; stir in scallions. Let cool slightly, about 10 minutes.
Whisk together flour, sugar, baking powder, salt, and pepper in a small bowl. Whisk together milk and eggs in a large bowl until smooth. Whisk flour mixture into milk mixture until smooth. Stir in cooled corn mixture. Pour into prepared baking dish.
Bake at 350°F until lightly browned and center is set, 55 minutes to 1 hour.