Yes, you are entitled to the dividends if you had the share on the ex div date, doesn't matter if you sold them the day after.
HotCopper Highlights: Stakk's out-of-nowhere Robinhood deal; ADNOC dumps Santos after first date & more