Is there a way to have an argument with two types in Dart? Since you are expecting one of multiple types, what about having dynamic and then in the push method of NavTo, you could check the type:
1 2 3 4 5 6 7 8 9 10 11 | class NavTo { dynamic route; push(BuildContext context) { if (route is String) { ... } else if (route is Widget) { ... } } } |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.