It is highly recommended to use the dotnet-sdk extension provided by flatpak instead of one installed from your package manager, as that may break with system updates.
To install the dotnet-sdk:
flatpak install flathub org.freedesktop.Sdk.Extension.dotnet6
You might need to adjust dotnet6
to the version you want to install.
Then you need to enable the flatpak extension by setting the environment variable:
FLATPAK_ENABLE_SDK_EXT
to either dotnet6
or *
(to enable all extensions, be sure to check what you enable here).