No single food or type of food provides all the nutrients you need in the right amounts for a day. Enjoy many different foods for all the nutrients and substances they provide.
Eating dinner less than two hours before you go to bed won't necessarily cause weight gain, but it does mean that this meal should be the smallest of the day.