$urlInterface = \Magento\Framework\App\ObjectManager::getInstance()
->get(\Magento\Framework\UrlInterface::class);
$currentUrl = $urlInterface->getCurrentUrl();
Example:
private $urlInterface;
public function __construct(
...
\Magento\Framework\UrlInterface $urlInterface
...
) {
$this->urlInterface = $urlInterface;
}
public function getCurrentUrl()
{
return $this->urlInterface->getCurrentUrl();
}