All you need to do is cross-multiply.
So, the numerators will represent the number of cakes and the denominators will represent the amount of flour.
So, 12/150 = 30/x and here you cross multiply.
12x = 150*30
12x = 4500
12x/12 = 4500/12 here, you're dividing both sides by 12 to make x stand alone
x = 375g of flour