Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

The named parameter 'userId' isn't defined

am trying to call the user again while he is auth == true . when the user press he need to be called the same user . any solutions?

class upload extends StatefulWidget {
  String? userId;
  upload({Key? key, this.userId}) : super(key: key);

  @override
  State<upload> createState() => _uploadState();
}

class _uploadState extends State<upload> {
  File? file;
  String? downloadUrl;
//.......
//.......
//.......
 @override
  void initState() {
    super.initState();
    FirebaseFirestore.instance
        .collection("users")
        .doc(user!.uid)
        .get()
        .then((value) {
      this.loggedInUser = usermodel.fromMap(value.data());
      setState(() {});
    });
  }
//...........
//...........
onPressed: () => selectImage(context, userId: loggedInUser.uid),
~~~!

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

In your selectImage function, if you defined it like this:

selectImage(BuildContext context, String userId) {
//....etc

then when you call the method, it should look like this:

onPressed: () => selectImage(context, loggedInUser.uid),

Because you are using positional parameters, not named parameters.

If you want to use named, change it to this:

selectImage({required BuildContext context, required String userId}) {
//....etc
onPressed: () => selectImage(context: context, userId: loggedInUser.uid),

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading