Closed sallaben closed 4 years ago
Can you describe it more? I'm current using but got no errors until now...
Try specifying the goBack() type, like this:
navService.goBack<void>();
Fixed in new version. Closing
bool goBack({Object result}) => navigationKey.currentState.pop<bool>(result);
"navigationKey.currentState.pop
returns an error
"A value of type 'void' can't be returned from method 'goBack' because it has a return type of 'bool'."
I am using latest version - no_context_navigation 1.0.2
https://pub.dev/packages/no_context_navigation
Please help, how to fix this issue.
bool goBack({Object result}) => navigationKey.currentState.pop<bool>(result);
"navigationKey.currentState.pop(result);"
returns an error
"A value of type 'void' can't be returned from method 'goBack' because it has a return type of 'bool'."
I am using latest version - no_context_navigation 1.0.2
https://pub.dev/packages/no_context_navigation
Please help, how to fix this issue.
Are you sure you're in the latest version? Because I've updated this function to this:
void goBack({T result}) => navigationKey.currentState.pop<T>(result);
Also, make sure you have had set NavigationKey in MaterialApp, navigationKey parameter.
Thanks @fmmalta . Your last given solution worked.
Could you please suggest me how can we pass multiple parameters in pushNamed function:
navService.pushNamed(ListofarticlesScreen.routeName, args: {'search', 'python'});
not receiving 'search' and 'python' params in 'ListofarticlesScreen.dart' constructor. Please suggest.
Could you please suggest me how can we pass multiple parameters in pushNamed function:
navService.pushNamed(ListofarticlesScreen.routeName, args: {'search', 'python'});
not receiving 'search' and 'python' params in 'ListofarticlesScreen.dart' constructor. Please suggest.
Create a model/helper object with all parameters you need, like:
class MyModel {
final String myParam1;
final int myParam2;
final double myParam3;
final bool myParam4;
const MyModel({this.myParam1, this.myParam2, this.myParam3, this.myParam4});
}
Fill this parameters before you pass in the args parameters.
onPressed: () => navService.pushNamed('/my-screen,
args: MyModel(myParam1: ...,
myParam2: ...,
myParam3: ...,
myParam4: ...,
myParam5: ....
),
);
In your router.dart file, an example, use this:
case '/my-screen': return MyScreen(myModel: settings.arguments);
On MyScreen, you will use MyModel as an object in your constructor, like this:
class MyClass {
final MyModel myModel;
const MyClass({Key key, this.myModel}) : super(key: key);
@override
Widget build(BuildContext context) {
final _myString = myModel.myParam1; ///Example getting the parameters from MyModel;
return ...
}
}
It's better to encapsulating your arguments/parameters instead of doing like you were doing. Make things much easier.
Thank you so much, you solved my another issue. 👍
Compiling with flutter sdk channel master for macos. Any ideas?