This commit is contained in:
2023-11-28 15:55:42 +08:00
parent b9259f5086
commit 91a447b016
4 changed files with 27 additions and 3 deletions

View File

@@ -0,0 +1 @@
export 'replace_current_route_none.dart' if (dart.library.html) 'replace_current_route_web.dart';

View File

@@ -0,0 +1,3 @@
void replaceCurrentRoute(String query) {
throw UnimplementedError();
}

View File

@@ -0,0 +1,13 @@
// ignore: avoid_web_libraries_in_flutter
import 'dart:html';
void replaceCurrentRoute(String query) {
const usePathUrl = bool.fromEnvironment("usePathUrl");
if (usePathUrl) {
final q = query.substring(1);
final base = document.baseUri ?? "/";
window.history.replaceState(null, "", "$base$q");
} else {
window.history.replaceState(null, "", "#$query");
}
}