Home > front end >  2 positional argument(s) expected, but 1 found. and The argument type 'String?' can't
2 positional argument(s) expected, but 1 found. and The argument type 'String?' can't

Time:01-18

I have been able to open my files using the file picker package but I am to save the result path to the pdfFile variable.

This is the variable

File? pdfFile;

I am getting the error from the code below

onPressed: () async {
          FilePickerResult? result = await FilePicker.platform.pickFiles(
            type: FileType.custom,
            allowMultiple: false,
          ); //allowedExtensions: ['pdf', 'doc']);
          if (result == null) return;
          final path = result.files.single.path;
          setState(() {
            pdfFile = File(path); //2 positional argument(s) expected, but 1 found. and The argument type 'String?' can't be assigned to the parameter type 'List<Object>'.
          });
        }

CodePudding user response:

Make sure of improt section.

import 'dart:io'; // for File
import 'package:file_picker/file_picker.dart'; // for FilePickerResult
  •  Tags:  
  • Related