After eating it's best to wait at least 2 to 3 hours before going to sleep to allow time for the food to digest.
That is especially true if you eat a large meal as when your body is lying down your body cannot easily digest the food.
Your body digests food more easily when you're in the upright position so that's why you should eat the food and then wait 3 hours before going to bed.
After 3 hours the food should be nearly digested and you can go to sleep without any issues.
I eat my last meal around 3 to 4 hours before bed anyway so it's never an issue to needing to wait to go to bed.
You can eat and then go to bed but your digest the food better if you wait to lie down for 2 to 3 hours after eating the food.