In a bowl, whisk together the flour, baking powder, baking soda, and salt.
1 3/4 cups all-purpose flour, 1 1/2 teaspoons baking powder, 1/4 teaspoon baking soda, 1/4 teaspoon salt
In a second bowl, combine the coconut milk, sour cream, pineapple juice, and vanilla extract.
½ cup full-fat canned coconut milk, 1/4 cup full-fat sour cream, 1/3 cup pineapple juice, 2 teaspoons vanilla extract
In a third bowl, beat the butter and white sugar with a handheld mixer on speed 7 for 2 minutes until fluffy.
10 Tablespoons unsalted butter, 1 cup granulated white sugar
Add the eggs one at a time, beating for 20 seconds after each addition.
3 large eggs
Alternate adding the dry and wet ingredients to the butter mixture. Start with 1/3 of the dry mixture, mix in with a rubber spatula, then add 1/2 of the wet mixture, and mix. Repeat with half of the remaining dry mixture, then all of the remaining wet mixture, and finally the last of the dry mixture. Fold in the coconut flakes, if using.
1/3 cup coconut flakes
Spread the batter evenly over the pineapple layer, smoothing and leveling the surface.