Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

browser refresh issue #1812

Open
kencana16 opened this issue Dec 8, 2023 · 2 comments
Open

browser refresh issue #1812

kencana16 opened this issue Dec 8, 2023 · 2 comments

Comments

@kencana16
Copy link

i have a web app that using path parameter inside route. the path param contain # character.
it looks run as well,
image

but when i trying to refresh web browser, the path is truncated at # char.
image

from the capture above the URL is looks fine. but if we use usePathUrlStrategy(); URL also become to http://localhost:64319/#/seconds/123

note : for the prev version (I'm forget the version) this package make my url keep encoded(), and there is no issue when url is encoded. i also trying to encode param before navigate. but in url gonna decoded again

@kencana16
Copy link
Author

import 'package:auto_route/annotations.dart';
import 'package:auto_route/auto_route.dart';
import 'package:flutter/material.dart';

import 'main.gr.dart';

void main() {
  
  runApp(MainApp());
}

class MainApp extends StatelessWidget {
  // make sure you don't initiate your router
  // inside of the build function.
  final _appRouter = AppRouter();

  @override
  Widget build(BuildContext context) {
    return MaterialApp.router(
      routerConfig: _appRouter.config(),
    );
  }
}

@AutoRouterConfig()
class AppRouter extends $AppRouter {
  @override
  List<AutoRoute> get routes => [
        AutoRoute(page: FirstRoute.page, initial: true),
        AutoRoute(page: SecondsRoute.page, path: "/seconds/:id"),
      ];
}

@RoutePage()
class FirstPage extends StatelessWidget {
  FirstPage({super.key});

  List<String> params = [
    "123#456#789",
    "123%23456%23789",
  ];

  @override
  Widget build(BuildContext context) {
    return Column(
      children: params
          .map((e) => Padding(
                padding: const EdgeInsets.all(16.0),
                child: ElevatedButton(
                    onPressed: () => context.pushRoute(SecondsRoute(
                          id: e,
                          query: e,
                        )),
                    child: Text(e)),
              ))
          .toList(),
    );
  }
}

@RoutePage()
class SecondsPage extends StatelessWidget {
  final String id;
  final String? query;
  const SecondsPage(
      {super.key, @PathParam() required this.id, @QueryParam() this.query});

  @override
  Widget build(BuildContext context) {
    return Center(
      child: Column(
        children: [
          Text("id :${id}"),
          Text("query :${query}"),
          Text("pathParam :${AutoRouter.of(context).current.pathParams}"),
          Text("queryparam :${AutoRouter.of(context).current.queryParams}"),
        ],
      ),
    );
  }
}

@kencana16
Copy link
Author

@Milad-Akarie. can i make my browser not auto decode the URL path/param after pages loaded?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant