skip to Main Content

error: Non-nullable instance field ‘pickedImage’ must be initialized.
error: Non-nullable instance field ‘textResult’ must be initialized.
error: The non-nullable variable ‘hasilScan’ must be initialized.

  File pickedImage;
  String textResult;
  static String hasilScan;

2

Answers


  1. In flutter after null safety was enabled, you can’t leave a variable without assiging a value to it.
    you can either use late modifier, but you have to assign a value to it later

    late String textResult;
    

    or make it nullable using null check operator

    String? textResult;
    

    or just assign a value to it :

    String textResult = 'some text';
    
    Login or Signup to reply.
  2. Thats simple either assign a value to variable or make variable type Nullablae using ?.
    Like File? File;
    String? string;

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search