Minor fix

This commit is contained in:
2023-11-28 16:17:09 +08:00
parent 91a447b016
commit f432967c12
6 changed files with 4 additions and 29 deletions

View File

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

View File

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

View File

@@ -1,13 +0,0 @@
// 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");
}
}

View File

@@ -1,6 +1,5 @@
import 'package:dio/dio.dart';
import 'package:dio_image_provider/dio_image_provider.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
import 'package:flutter/services.dart';
@@ -13,7 +12,6 @@ import 'package:photo_view/photo_view_gallery.dart';
import '../api/file.dart';
import '../api/gallery.dart';
import '../globals.dart';
import '../platform/replace_current_route.dart';
final _log = Logger("SinglePageViewer");
@@ -102,15 +100,9 @@ class _SinglePageViewer extends State<SinglePageViewer> with ThemeModeWidget {
}
void _onPageChanged(BuildContext context) {
GoRouter.optionURLReflectsImperativeAPIs = false;
final q = "/gallery/${widget.gid}/page/${_index + 1}";
context.replace(q,
context.replace("/gallery/${widget.gid}/page/${_index + 1}",
extra: SinglePageViewerExtra(data: _data, files: _files));
GoRouter.optionURLReflectsImperativeAPIs = true;
_page_changed = false;
if (kIsWeb) {
replaceCurrentRoute(q);
}
}
@override

View File

@@ -370,10 +370,10 @@ packages:
dependency: "direct main"
description:
name: go_router
sha256: "5668e6d3dbcb2d0dfa25f7567554b88c57e1e3f3c440b672b24d4a9477017d5b"
sha256: c247a4f76071c3b97bb5ae8912968870d5565644801c5e09f3bc961b4d874895
url: "https://pub.dev"
source: hosted
version: "10.1.2"
version: "12.1.1"
graphs:
dependency: transitive
description:

View File

@@ -23,7 +23,7 @@ dependencies:
sdk: flutter
flutter_web_plugins:
sdk: flutter
go_router: ^10.1.0
go_router: ^12.1.0
image: ^4.0.17
infinite_scroll_pagination: ^4.0.0
intl: any