skip to Main Content

error: The argument type ‘File?’ can’t be assigned to the parameter type ‘File’. (argument_type_not_assignable at [aplikasi_scan_plat_nomor] libscreenhome.dart:82)

File? pickedImage;
image: FileImage(pickedImage),

2

Answers


  1. Your dataType is nullable which is ok.

    File? pickedImage; 
    

    But image doesnt accept null data.
    You can do a null check first.

    if(pickedImage!=null)
      YourWidget(
         image: FileImage(pickedImage),
    

    Adding null-assert(!) is risky without checking null first.

    Login or Signup to reply.
  2. The proper way would be to do a null check, but you can also assign an initial value your pickedImage.

    File pickedImage = File('initialValue');
    
    image: FileImage(pickedImage),
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search