I have a payment confirmation route that takes a path parameter of true or false (true when payment was successful and false when unsuccessful). my app should work on both web and mobile. I have used auto_route package for routing and I have defined my route like so:
AutoRoute(
path: '/business/campaigns/payment_result/:result',
page: PaymentConfirmationPage,
guards: [AuthenticationRouteGuard, BusinessAccessRouteGuard],
),
and I have given the result like this to my payment page:
class PaymentConfirmationPage extends StatelessWidget {
const PaymentConfirmationPage( {
@PathParam() required bool result,
Key? key})
: super(key: key);
@override
Widget build(BuildContext context) {
final bool result = context.router.current.pathParams.getBool('result');
return Container(child: Text(result.toString()));
}
}
However, when I navigate to the page like this:
context.router.push(PaymentConfirmationRoute(result: false));
I get this error on both web and mobile:
Class 'bool' has no instance method 'toLowerCase'. Receiver: false Tried calling: toLowerCase()
But when I manually enter the route
domain/business/campaigns/payment_result/false
in my browser, everything works fine.
I could use enums instead, but if bools don't work as pathParams, then why is there a getBool function? Am I making a mistake?
when I click on the relevent error-causing widget printed out in my console, I am directed to the router.gr file, which is generated by auto_route package. below is where I'm lead to:
return _i83.MaterialPageX<dynamic>(
routeData: routeData,
child: _i39.PaymentConfirmationPage(
result: args.result,
key: args.key,
),
);