Navigation from Custom Widget

How can I navigate to another page (onTap) within a custom widget? If I use

Navigator.of(context).pushNamed('page');

I get an error (Navigator.onGenerateRoute was null, but the route named "page" was referenced.)

If I try to do it as in the generated code (context.pushNamed), the code will not compile.

3
15 replies