Home > database >  How to return multiple arguments when popUntil?
How to return multiple arguments when popUntil?

Time:06-30

Navigator.popUntil(context, (route) => route.isFirst);

I try this back transition this. I wanna get bool argument at the same time.

class Position {
  Position(bool isFirst, bool value);
}

Navigator.popUntil(context, ((route) {
  return Position(route.isFirst, true);
}));

I tried this, but I got error.

The return type 'Position' isn't a 'bool', as required by the closure's context.

How can I do?

CodePudding user response:

Please do check the argument in position constructor. I could see two data type mentioned in the place of variable name.

class Position {
  Position(bool isFirst, bool bool);
}

Change the above one to like below:

class Position {
  Position(bool isFirst, bool value1);
}

CodePudding user response:

Please follow this link : Flutter - Pass Data Back with .popUntil

it should be boolean value. for values you can write :

Navigator.popUntil(context, ((route) {
 (route.settings.arguments as Map)['result'] = 'data';
   return true;
}));
  • Related