In a lawn, the best way to get rid of wild onions (or wild garlic) is to mow the grass, and then immediately spray with a lawn-weed killer, while the tops are still 'open'.
In a flower garden? Suggestion: Try a product called "Over The Top" (fluazafop, I think); read the list of plants (flowers) that WILL NOT be damaged by the spray. Very extensive list is on bottle, and [better] on their website. First, you'll have to use a string trimmer to cut the tops off the onions. My experience with this product is killing grass that grows in beds of creeping junipers (Blue Rug, Blue Pacific, etc.) Good Luck!