I'm trying to send the id of the clicked element in the sidebar to this DokumentiScreen
page with routes.
Here is on tap method.
onTap: () {
print('sublink pressed');
Navigator.of(context).pushReplacementNamed(child['link']);
/Navigator.push(context, MaterialPageRoute(builder: (context) => const DokumentiScreen()));
And this is route used.
'/dokumenti/:id': (ctx) => const DokumentiScreen(),
And I'm getting this error :
The following assertion was thrown while handling a gesture:
Could not find a generator for route RouteSettings("/dokumenti/11", null) in the _WidgetsAppState.
Make sure your root app widget has provided a way to generate
this route.
Hope anyone can help :D
CodePudding user response:
// Navigate to Next Screen
static void goToNextScreen(BuildContext context, var uId) {
Navigator.of(context).push(new MaterialPageRoute<dynamic>(builder:
(BuildContext context) {
return NextScreen(uId);
},));
}
In Next Screen
class NextScreen extends StatefulWidget {
var uId;
NextScreen(this.uId);
@override
_NextScreenState createState() => _NextScreenState();
}
class _NextScreenState extends State<NextScreen> {
var uId;
@override
void initState() {
super.initState();
uId = widget.uId;
}
@override
Widget build(BuildContext context) {
return Scaffold()
}
}