Does seeing matters of the unseen in a dream contradict the fact that only Allah knows the unseen?
Question

It's a fact that only Allah know the unseen but I'm a little bit confused regarding the fact that some people see stuff happening in there dreams which comes true later or some people seeing jannah in there dreams and hell and etc
Praise be to Allah.No one knows the true unseen except Allah, may He be exalted, but He may disclose to some of His slaves some matters of the unseen, either through the angel, or through a true dream, or through inspiration, or by speaking directly to him.
Allah, may He be exalted, says (interpretation of the meaning):
{He knows what is [presently] before them and what will be after them, and they encompass not a thing of His knowledge except for what He wills} [Al-Baqarah 2:255]
{[He is] Knower of the unseen, and He does not disclose His [knowledge of the] unseen to anyone,
Except whom He has approved of messengers} [Al-Jinn 72:26-27].
-1-
Part of the unseen of which Allah informed His prophets through the angel is knowledge of what will happen of the portents of the Hour; the description of the gathering, the reckoning and the sirat (bridge over Hell); and many of the details of Paradise and Hell.
-2-
Part of the unseen of which Allah informs His slaves through a true dream is when a person sees what is going to happen to him or to someone else in the future, then it happens as he saw it. So he may see that So-and-so is going to die, or that he is going to get married to So-and-so, or that he will have a child, and the like.
This is part of the unseen which Allah discloses to some of His slaves. Hence true dreams are a part of prophecy.
Al-Bukhari (6989) narrated from Abu Sa‘id al-Khudri that he heard the Messenger of Allah (blessings and peace of Allah be upon him) say: “True dreams are one of the forty-six parts of prophecy.”
Muslim (8) also narrated it from Abu Hurayrah.
What is meant by true dreams being one of the parts of prophecy is that the word nubuwwah (prophecy, prophethood) is taken from the words naba’ and ianba’, which refer to informing. What is meant is that the dream is true foretelling from Allah, and there is no lie in it. Similarly, the word nubuwwah refers to true foretelling from Allah, Who cannot lie. Hence dreams are similar to prophecy in the sense that what is foretold about the unseen is true."(Sharh Sahih al-Bukhari by Ibn Battal  9/517).
So if someone sees in his dream something of the future unseen, then it comes to pass as he saw it, this means that Allah has blessed him with knowing something of the unseen that no one knows except Him, may He be glorified, and He has told us that He may disclose it to some of His slaves.
-3-
Allah may inform His slave of some matter of the unseen by means of inspiration, as al-Bukhari (3469) and Muslim (2398) narrated from Abu Hurayrah (may Allah be pleased with him) that the Prophet (blessings and peace of Allah be upon him) said: “Among the nations that came before you there were men who were inspired. If there are any among my ummah who are inspired, then ‘Umar ibn al-Khattab is among them.”
According to a mu‘allaq report narrated by al-Bukhari (3689), “Among those of the Children of Israel who came before you there were some men who were spoken to without them being prophets; if there is anyone among my ummah who could be one of them, it is ‘Umar.”
Al-Khattabi (may Allah have mercy on him) said: “if there is anyone among my ummah who could be one of them, it is ‘Umar ibn al-Khattab (may Allah be pleased with him)” – the one who is inspired is the one into whose heart something is cast, so it is as if he is told about it; something occurs to him and it happens to him, or something crosses his mind and it comes to pass. This is a high status of the awliya’ (those friends of llah) and a lofty status among those who are brought close to Allah."( A‘lam al-Hadith  3/1571).
An example of that is when Allah inspired the mother of Musa (peace be upon him): Throw him into the river; he will be saved and will be one of the messengers. Allah called this inspiration wahy, as He says (interpretation of the meaning):
{And We inspired [wa awhayna] to the mother of Moses, “Suckle him; but when you fear for him, cast him into the river and do not fear and do not grieve. Indeed, We will return him to you and will make him [one] of the messengers”} [al-Qasas 28:7].
Shaykh al-Islam Ibn Taymiyah (may Allah have mercy on him) said: This wahy (inspiration) is for people other than the prophets; it may happen when they are awake or when they are asleep, and it may happen with an audible voice or a voice that is in the person’s heart, not coming from outside himself, when awake or when asleep.(Majmu‘ al-Fatawa 12/398).
-4-
Allah may inform His Messenger about the unseen by speaking to him directly, as happened to a number of the prophets, including our Prophet (blessings and peace of Allah be upon him) on the night of the Mi‘raj (ascent to heaven).
Allah, may He be exalted, says (interpretation of the meaning):
{ And it is not for any human being that Allah should speak to him except by revelation or from behind a partition or that He sends a messenger to reveal, by His permission, what He wills. Indeed, He is Most High and Wise} [Ash-Shura 42:51].
These are four ways in which Allah may inform some of His slaves about the unseen, one of which is dreams. So a person may see something of the future, then it comes to pass as he saw it, or Allah may cause him to see Paradise or Hell.
At the end of time, true dreams will increase and will bring some glad tidings, and the truthfulness of the dreams will be indicative of the sincerity of the one who sees the dream, as Ahmad (10590), Abu Dawud (5019), at-Tirmidhi (2270), and Ibn Majah (3917) narrated from Abu Hurayrah (may Allah be pleased with him), from the Prophet (blessings and peace of Allah be upon him), who said: “Towards the end of time, a Muslim’s dream will hardly be false and the truest of them in dreams will be the truest of them in speech. The dream of the Muslim is one of the forty-six parts of prophecy.” And he said: “Dreams are of three types: good dreams, which are glad tidings from Allah; another type of dream, which comes from the Shaytan and is intended to make him sad; and dreams that come from what a person is thinking of to himself. If one of you sees something that he dislikes, let him not tell anyone about it, and let him get up and pray.”
Classed as sahih by al-Albani and Shu‘ayb al-Arna’ut, who said: [Sahih] according to the conditions of al-Bukhari and Muslim.
May Allah grant us and you true dreams.
And Allah knows best.