0

here is how i pass parameter as queryParameter , it accept all types , <String, dynamic> :

routes.goNamed(
    'confirm',
    queryParameters: {
      'isLogin': true,
    },
  );

but here when i want to get that parameter i need to parse that to type because queryParameters is <String, String> and queryParametersAll is <String, List> too .

GoRoute(
    name: 'confirm',
    path: 'confirm',
    builder: (context, state) {
      return AuthConfirmPage(
        isLogin: bool.parse(state.queryParameters['isLogin']!),
      );
    },
  ),

what is the correct way to solve this problem ? i dont want to get bool by convert string via bool.parse .

Md. Yeasin Sheikh
  • 54,221
  • 7
  • 29
  • 56
vrMan
  • 101
  • 1
  • 1
  • 6

1 Answers1

0

When passing parameters as query parameters in a URL, the values are typically treated as strings. When handling these query parameters, you'll need to parse and convert the values to the appropriate data types.

anyway if you don't need to use bool.parse, Following one is also possible

isLogin: state.queryParameters['isLogin']=='true',
Nikhith sunil
  • 229
  • 3
  • 4