GoRouter not driving me to the screen im requesting on android

47 views Asked by At

sorry for asking but goRouter is not working on my project for deeplinking

I have set all My android manifest:

<meta-data android:name="flutter_deeplinking_enable" android:value="true" />
  <intent-filter android:autoVerify="true">

    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />
    <data android:scheme="http" android:host="servlymaindev.web.app" android:pathPrefix="/" />
    <data android:scheme="https" />

  </intent-filter>

my main is using stream builder for firebase auth

StreamBuilder(
    stream: router.auth.authStateChanges,
    builder: (context, snapshot) {
      return MaterialApp.router(
        title: 'Myservy: App de Servicios',
        theme: apptheme,
        routeInformationParser: router.router.routeInformationParser,
        routerDelegate: router.router.routerDelegate,
        routeInformationProvider: router.router.routeInformationProvider,
      );
    }),

and my router is set

class AppRouter {
  static final AppRouter _singleton = AppRouter._internal();
  late final FirebaseAuth auth;

  AppRouter({required this.auth});

  factory AppRouter.withAuth() {
    return _singleton..auth = FirebaseAuth();
  }

  AppRouter._internal();
  final GoRouter router = GoRouter(
    debugLogDiagnostics: true,
    routes: [
      GoRoute(
        path: '/',
        name: AppRouterConstants.loginScreen,
        pageBuilder: (context, state) {
          return const MaterialPage(child: LoginScreen());
        },
      ),
      GoRoute(
        path: '/main',
        name: AppRouterConstants.mainScreen,
        pageBuilder: (context, state) => const MaterialPage<void>(
          child: MainScreen(),
        ),
      ),
      GoRoute(
        path: '/service/:id',
        name: AppRouterConstants.serviceScreen,
        pageBuilder: (context, state) => MaterialPage<void>(
          child: ServiceScreen(serviceId: state.pathParameters['id']!),
        ),
      ),
      GoRoute(
        path: '/provider/:id',
        name: AppRouterConstants.providerScreen,
        pageBuilder: (context, state) => MaterialPage<void>(
          child: ProviderScreen(providerId: state.pathParameters['id']!),
        ),
      ),
      GoRoute(
        path: '/highlighted-new-services',
        name: AppRouterConstants.highlightedNewServicesScreen,
        pageBuilder: (context, state) => const MaterialPage<void>(
          child: HighlightedNewServicesScreen(),
        ),
      ),
      GoRoute(
        path: '/highlighted-services',
        name: AppRouterConstants.highlightedServicesScreen,
        pageBuilder: (context, state) => const MaterialPage<void>(
          child: HighlightedServicesScreen(),
        ),
      ),
      GoRoute(
        path: '/highlighted-providers',
        name: AppRouterConstants.highlightedProviderScreen,
        pageBuilder: (context, state) => const MaterialPage<void>(
          child: HighlightedProviderScreen(),
        ),
      ),
      GoRoute(
        path: '/search',
        name: AppRouterConstants.searchScreen,
        pageBuilder: (context, state) => MaterialPage<void>(
          child: SearchScreen(query: state.uri.queryParameters['query']),
        ),
      ),
      GoRoute(
        path: '/details/:serviceCenterId/:id',
        name: AppRouterConstants.detailsScreen,
        pageBuilder: (context, state) => MaterialPage<void>(
          child: DetailsScreen(
              serviceCenterId: state.pathParameters['serviceCenterId']!,
              serviceRequestId: state.pathParameters['id']!,
              index: int.parse(state.uri.queryParameters['index'] ?? '0')),
        ),
      ),
      GoRoute(
        path: '/payment',
        name: AppRouterConstants.paymentScreen,
        pageBuilder: (context, state) => MaterialPage<void>(
          child: PaymentScreen(
            data: state.extra as Map,
          ),
        ),
      ),
      GoRoute(
        path: '/profile',
        name: AppRouterConstants.profileScreen,
        pageBuilder: (context, state) => const MaterialPage<void>(
          child: ProfileScreen(),
        ),
      ),
      GoRoute(
        path: '/assisted-sale/:serviceCenterId',
        name: AppRouterConstants.assistedSaleScreen,
        pageBuilder: (context, state) => MaterialPage<void>(
          child: AssistedSaleWebviewScreen(
            assistedSaleId: state.uri.queryParameters['id'] ?? '',
            serviceCenterId: state.pathParameters['serviceCenterId']!,
            serviceData: state.extra as Map?,
          ),
        ),
      ),
    ],
    redirect: (context, state) {
      final token = Preferences.getJWT();

      if (token != null &&
          !JwtDecoder.isExpired(token) &&
          state.fullPath == '/') {
        return '/main';
      }

      if ((token == null || JwtDecoder.isExpired(token)) &&
          state.fullPath != '/') {
        return '/';
      }

      return null;
    },
  );
}

but the deeplinkg is opening the app but no the requested path

i tried using: https://servlymaindev.web.app/profile but is always opening / not /profile

dont know what else to do :(

using flutter and go Router i tried using: https://servlymaindev.web.app/profile but is always opening / not /profile

0

There are 0 answers