push same page with different parameters in getx route delegate flutter

I want to open the same page again with different params

the issue is that if I open the category page from any other page it works great with params. but if I open the category page from category page but with different parameters, nothing happens only the URL updates nothing else.


http://localhost:64178/category?id=shirt

if I click on the shoes button, I want to open/push/refresh the same page with shoes parameter

Get.rootDelegate.toNamed(
      '/category',
      parameters: {
        'id': 'shoes',
      },
 );

but only the params in the URL bar update not the page itself.

http://localhost:64178/category?id=shoes


here is my code

GetMaterialApp.router(
      title: 'Test',
      theme: ThemeData(
        primarySwatch: Colors.amber,
        textTheme: GoogleFonts.poppinsTextTheme(),
      ),
      unknownRoute: GetPage(
        name: '/login',
        page: () => const ErrorPage(),
      ),
      routerDelegate: AppRouterDelegate(),
      routeInformationParser: GetInformationParser(
        initialRoute: '/',
      ),
      backButtonDispatcher: BackButtonDispatchers(),
      navigatorObservers: [GetObserver()],

      getPages: [
        GetPage(
          name: '/',
          page: () => const Home(),
        ),
        GetPage(
          name: '/category',
          preventDuplicates: false,
          page: () => const CollectionPage(),
        ),
    ]
)


class AppRouterDelegate extends GetDelegate {
  @override
  Widget build(BuildContext context) {
    return Navigator(
      onPopPage: (route, result) => route.didPop(result),
      pages: currentConfiguration != null
          ? [currentConfiguration!.currentPage!]
          : [GetNavConfig.fromRoute('/home')!.currentPage!],
    );
  }
}

here is the code to push/open a new page

Get.rootDelegate.toNamed(
      '/category',
      parameters: {
        'id': 'shirt',
      },
 );


Comments

Popular posts from this blog

Spring Elasticsearch Operations

Network Error and Timeout on Authorize.net JS

Object oriented programming concepts (OOPs)