Access values from constructor, from passing data to stateless widget Flutter

here is my code,

class ProfileOthers extends StatefulWidget {
  const ProfileOthers({super.key, required});

  final Map<String, dynamic> data; //I am hoping to make use of this data

  State<ProfileOthers> createState() => _ProfileOthersState();

Want to pass arguments in stateless widget from another screen, I’m new in flutter.

>Solution :

class UserProfileScreen extends StatefulWidget {
   final Map<String, dynamic> userData;
   const UserProfileScreen ({super.key, required this.userData});

  State<UserProfileScreen> createState() => _UserProfileScreenState();

you can access this parameter as shown below,


Leave a Reply