diff --git a/flutter_modular/lib/src/infra/services/url_service/html_url_service.dart b/flutter_modular/lib/src/infra/services/url_service/html_url_service.dart index 5066d743..1f38f611 100644 --- a/flutter_modular/lib/src/infra/services/url_service/html_url_service.dart +++ b/flutter_modular/lib/src/infra/services/url_service/html_url_service.dart @@ -2,6 +2,7 @@ import 'dart:html'; +import 'package:flutter_modular/flutter_modular.dart'; import 'package:flutter_web_plugins/url_strategy.dart'; import 'url_service.dart'; @@ -11,13 +12,15 @@ class WebUrlService extends UrlService { String? getPath() { final href = window.location.href; - if (urlStrategy is PathUrlStrategy) { - return resolvePath(href); - } else if (href.contains('#')) { - return href.split('#').last; + if (urlStrategy is HashUrlStrategy) { + if (href.endsWith(Modular.initialRoute)) { + return Modular.initialRoute; + } else if (href.contains('#')) { + return href.split('#').last; + } } - return null; + return resolvePath(href); } }