I have made a separate class named Userprofiles
which consist of user profile information only. I want to access this page/screen through my profile option which is on the dashboard screen of my application inside navigation drawer widget
.
While passing the class name in Navigator.push
I'm facing an error which says named parameter is not defined. Please help me resolve the issue as I am new to flutter.
buildMenuItem(
text: 'Profile',
icon: Icons.people,
onClicked: () {Navigator.push(context, MaterialPageRoute(builder: (context)=> Profilepage(getprofiles: )));}
),
Here is the code for Userprofiles screen
class Profilepage extends StatelessWidget {
final Userprofiles getprofiles;
Profilepage({required this.getprofiles});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Profile'),
),
body: Card(
child: Column(
children: [
Row(
children: [
Text('First name'),
Text(getprofiles.firstname)
],
),
Row(
children: [
Text('Last name'),
Text(getprofiles.lastname)
],
CodePudding user response:
it is happening because you have to define userprofile in UserProfile screen and have made it required, so you have always to pass userprofile to ProfileScreen where ever you called it
Solution:
- provide a user profile in the Navigation
- remove the required keyword in userProfile screen