FilledStacks / flutter-tutorials

The repo contains the source code for all the tutorials on the FilledStacks Youtube channel.
MIT License
4.75k stars 1.76k forks source link

Navigation service - Arguments Mistype #73

Closed tonini46 closed 4 years ago

tonini46 commented 4 years ago

Hi my problem occurs when I pass a Map<String, dynamic> argument. I get the exception attached.

Map<String, dynamic> data = {
          "action": "forgot_password",
          "msisdn": "",
          "calling_code": "",
          "reset_code": ""
        };
_navigationService.replaceWith(Routes.pinResetOtpReceiveViewRoute, arguments: data);

And in the navigated page:

class PinResetOtpReceiveView extends StatelessWidget {
  const PinResetOtpReceiveView({Key key, this.changePinData}) : super(key: key);  
  final Map<String, dynamic> changePinData; .....

So my issue is how do I access the passed argument from my navigated page without getting the exception? Screenshot_20200602-171233 1

FilledStacks commented 4 years ago

Use the PinResetOtpReceiveViewArguments file it's auto generated when you generate a view that has parameters. you can just add all your parameters to the view and then it'll generate that class when your run the build_runner build command.

tonini46 commented 4 years ago

Thanks, that was really helpful. You guys really come through for me.