Issue
How to fix this error.
My code
_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.
Answered By - DHRUV BADAYA
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.