I stopped breastfeeding DS1 at 16 months and he started sleeping through shortly afterwards. Before that he'd start the night in his own room, fed or cuddled to sleep by me but I'd bring him into my bed at the first wakeup and we'd cosleep.
The way I stopped was: when DS1 "asked" for a feed (nuzzling in or saying "mimi" which meant both milk and mummy 🙄) I'd say No, not right now but we'll have milk [before bed/before your nap/in the morning] etc. I'd then give him a cup of water or cow's milk, or a snack, or a cuddle, or play a little game with him - depending on if I thought he was asking for a feed out of hunger, thirst, boredom, wanting connection etc. I always kept my promises so I would always feed him when I said I would.
Over about a month I delayed all the feeds like this til we were down to just one feed first thing in the morning. Then when he "asked" for that one I'd say Nooo, let's go downstairs today and play instead. I'd make him his favourite breakfast and he was generally too excited to miss the feed much.
I do remember a few nights with him in my bed crying because I wouldn't feed him but it honestly wasn't that bad. On those occasions I'd hold him tight, sing to him etc, so he had lots of comfort and wasn't crying alone, and he was only waiting a few hours until the morning for his feed - it wasn't that he couldn't have it at all. The whole process was more painless than I was expecting.
He's almost 3 now and still prefers to have a grownup in his room until he goes to sleep, but when he does sleep now it's for 12+ hours. DS2 meanwhile is only 7 months and is also breastfed, but will actually put himself to sleep in his cot if I put him in awake, and often sleeps a solid 8 hours before waking for a feed. So actually I think the idea they must fall asleep in the conditions they will wake up in is a bit of a myth and varies from child to child.
One other thing I found helpful with both of my DC is Kerry Secker (Care It Out sleep consultant)'s idea of a "rolled up response". Basically when baby wakes, first of all you pause to see if they're actually awake and trying to communicate with you, rather than just grunting or crying in their sleep. If you're happy that they are, poke your head around the door and say some comforting words. If that doesn't work to settle them, try doing it by patting/stroking without picking then up. If that doesn't work you pick up and rock them and if they're still unsettled after that, only then do you feed them.
The idea is this gives them a chance to go back to sleep without feeding, but you're always there supporting them. With time they might get used to going to sleep with just a pat on the back etc. You might need to adapt this technique a bit if you're cosleeping all night.