iamSahdeep / seo_renderer

A Flutter Web Plugin to display Text Widget as Html for SEO purpose
MIT License
114 stars 15 forks source link

How to integrate go_router with seo_renderer? #21

Open o7planning opened 2 years ago

o7planning commented 2 years ago

Hello, I am using go_router for my project. Recently I wanted to integrate seo_renderer into my project.

https://pub.dev/packages/go_router

https://pub.dev/packages/seo_renderer

However, the examples show that these 2 libraries are not compatible with each other.

// seo_renderer:
runApp(
  RobotDetector(
    debug: true, // you can set true to enable robot mode
    child: MaterialApp(
      home: MyApp(),
      navigatorObservers: [seoRouteObserver],
    ),
  ),
);

// go_router
final _router = GoRouter(
  observers: [seoRouteObserver], // Not working.
  routes: [ ...]
);
// navigatorObservers is setted to null.
MaterialApp.router(
   routeInformationParser: _router.routeInformationParser,
   routerDelegate: _router.routerDelegate,
  title: 'GoRouter Example',
);

This my my question in stackoverflow:

https://stackoverflow.com/questions/72500928/how-to-integrate-go-router-with-seo-renderer

Hope to get an example from you.

o7planning commented 2 years ago

I have successfully integrated your library into my project with "Go_Router". There doesn't seem to be any need for any changes. Although I don't know if "seoRouteObserver" is really needed with "Router" because without it everything works.

krokyze commented 2 years ago

I have successfully integrated your library into my project with "Go_Router". There doesn't seem to be any need for any changes. Although I don't know if "seoRouteObserver" is really needed with "Router" because without it everything works.

seoRouteObserver is mandatory or else the package will not remove previous page from html when you'll navigate to the next screen.