Reputation: 67
I'm trying to integrate deeplinking from email in our app. I have a login screen where I can give forgot my password and it will send an email with deeplink. So I can click that link and it will navigate to the reset password screen.
I'm using auto route for this deep linking as I had some issues with go router with custom scheme and host. Now there is a modal bottom sheet in the login screen which shows that email has sent to your email Id. This modal sheet is visible on top of login screen.
When I click the deep link from the email then it is navigating correctly to my reset screen by checking the URI; but if I press back button or cancel then it is showing a black screen and then if i again click the back button then it is showing the login screen.
Once I complete my reset process, I want to navigate the user to login screen. Since the user is already not finished or removed the login screen, I am just using Navigator.pop(context);
on the successful password reset and removing the current reset screen. But again I am seeing the black screen and if I press back button then it is showing the login screen.
My expectation is that after the successful reset user should not see the black screen and also the same thing should happen for back press while the user is in reset screen. So these are my codes which I tried for this deep linking.
main.dart
return MaterialApp.router(
title: 'TestApp',
theme: ThemeData(
useMaterial3: true,
colorScheme: ColorScheme.fromSeed(
seedColor: const Color.fromRGBO(26, 49, 60, 1))),
routerConfig: appRouter.config(deepLinkBuilder: (deepLink) {
if (deepLink.path.isEmpty && deepLink.uri.host.contains("test")) {
return DeepLink(
[ResetRoute(children: deepLink.uri.queryParameters)]);
} else {
return DeepLink.defaultPath;
}
}));
app_router.dart
@AutoRouterConfig()
class AppRouter extends $AppRouter {
@override
List<AutoRoute> get routes => [
AutoRoute(path: "/SplashScreen", page: SplashRoute.page, initial: true),
AutoRoute(path: "/EmailScreen", page: EmailRoute.page),
AutoRoute(path: "/RegisterScreen", page: RegisterRoute.page),
AutoRoute(path: "/ResetScreen", page: ResetRoute.page),
AutoRoute(path: "/EventsScreen", page: EventRoute.page),
AutoRoute(path: "/LoginScreen", page: LoginRoute.page),
AutoRoute(
path: "/NavigationMenuScreen", page: NavigationMenuRoute.page),
AutoRoute(
path: "/PersonalDetailsScreen", page: PersonalDetailsRoute.page)
];
}
app_router.gr.dart
abstract class $AppRouter extends RootStackRouter {
$AppRouter({super.navigatorKey});
@override
final Map<String, PageFactory> pagesMap = {
SplashRoute.name: (routeData) {
return AutoRoutePage<dynamic>(
routeData: routeData,
child: const SplashScreen(),
);
},
EmailRoute.name: (routeData) {
return AutoRoutePage<dynamic>(
routeData: routeData,
child: const EmailScreen(),
);
},
RegisterRoute.name: (routeData) {
return AutoRoutePage<dynamic>(
routeData: routeData,
child: RegisterScreen(queryParams: routeData.queryParams),
);
},
ResetRoute.name: (routeData) {
return AutoRoutePage<dynamic>(
routeData: routeData,
child: ResetScreen(queryParams: routeData.queryParams));
},
EventRoute.name: (routeData) {
return AutoRoutePage<dynamic>(
routeData: routeData,
child: EventsScreen(queryParams: routeData.queryParams));
},
LoginRoute.name: (routeData) {
return AutoRoutePage<dynamic>(
routeData: routeData,
child: LoginScreen(queryParams: routeData.queryParams));
},
NavigationMenuRoute.name: (routeData) {
return AutoRoutePage<dynamic>(
routeData: routeData,
child: NavigationMenu(queryParams: routeData.queryParams));
},
PersonalDetailsRoute.name: (routeData) {
return AutoRoutePage<dynamic>(
routeData: routeData,
child: PersonalDetails(queryParams: routeData.queryParams));
}
};
}
class SplashRoute extends PageRouteInfo<void> {
const SplashRoute() : super(SplashRoute.name);
static const String name = 'SplashRoute';
static const PageInfo<void> page = PageInfo<void>(name);
}
class EmailRoute extends PageRouteInfo<void> {
const EmailRoute() : super(EmailRoute.name);
static const String name = 'EmailRoute';
static const PageInfo<void> page = PageInfo<void>(name);
}
class RegisterRoute extends PageRouteInfo<void> {
const RegisterRoute({required Map<String, String> children})
: super(RegisterRoute.name, rawQueryParams: children);
static const String name = 'RegisterRoute';
static const PageInfo<void> page = PageInfo<void>(name);
}
class ResetRoute extends PageRouteInfo<void> {
const ResetRoute({required Map<String, String> children})
: super(ResetRoute.name, rawQueryParams: children);
static const String name = 'ResetRoute';
static const PageInfo<void> page = PageInfo<void>(name);
}
class EventRoute extends PageRouteInfo<void> {
const EventRoute({required Map<String, String> children})
: super(EventRoute.name, rawQueryParams: children);
static const String name = 'EventRoute';
static const PageInfo<void> page = PageInfo<void>(name);
}
class LoginRoute extends PageRouteInfo<void> {
const LoginRoute({required Map<String, String?> children})
: super(LoginRoute.name, rawQueryParams: children);
static const String name = 'LoginRoute';
static const PageInfo<void> page = PageInfo<void>(name);
}
class NavigationMenuRoute extends PageRouteInfo<void> {
const NavigationMenuRoute({required Map<String, String> children})
: super(NavigationMenuRoute.name, rawQueryParams: children);
static const String name = 'NavigationMenuRoute';
static const PageInfo<void> page = PageInfo<void>(name);
}
class PersonalDetailsRoute extends PageRouteInfo<void> {
const PersonalDetailsRoute({required Map<String, String> children})
: super(PersonalDetailsRoute.name, rawQueryParams: children);
static const String name = 'PersonalDetailsRoute';
static const PageInfo<void> page = PageInfo<void>(name);
}
In reset screen, after the successful api hit, I have tried this below code.
Navigator.pop(context);
Please check it and let me know how to resolve this problem. Thanks in advance.
Upvotes: 0
Views: 108