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 argument type 'Null' can't be assigned to the parameter type 'PatientPrescription'

How to fix this error.

enter image description here

My code

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

_patientDocument, patientDocument: [], patientPrescription: null,); //NULL ERROR

>Solution :

Make patientPrescription a nullable variable. Here is how to create a nullable variable in dart- "Put a question mark after the datatype". For example, let us create a String variable called "apple" as follows-

main(){
   String apple="hello";
   apple=null;
  print(apple);
}

Now, dart will give an error. However, if I replace String with String?, the error will be gone.


main(){
   String? apple="hello";
   apple=null;
  print(apple);
}

Similarly, int can be replaced with int?, double can be replaced with double?
I hope this helped.

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