Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The argument type 'File/*1*/' can't be assigned to the parameter type 'File/*2*/'. #19

Open
grrrgpratik opened this issue Apr 5, 2021 · 8 comments

Comments

@grrrgpratik
Copy link

This issue is still not fixed in the latest version i.e 2.0.4

flutter run -d chrome

Launching lib\main.dart on Chrome in debug mode...
lib/screens/myprofilescreen.dart:93:51: Error: The argument type 'File/1/' can't be assigned to the parameter type
'File/2/'.

  • 'File/1/' is from 'package:universal_io/src/io/file.dart'
    ('/D:/flutter/.pub-cache/hosted/pub.dartlang.org/universal_io-2.0.4/lib/src/io/file.dart').
  • 'File/2/' is from 'dart:io'.
    : new FileImage(_imageFile),
    ^
    lib/screens/CreatePostScreen.dart:163:46: Error: The argument type 'File/1/' can't be assigned to the parameter type
    'File/2/'.
  • 'File/1/' is from 'package:universal_io/src/io/file.dart'
    ('/D:/flutter/.pub-cache/hosted/pub.dartlang.org/universal_io-2.0.4/lib/src/io/file.dart').
  • 'File/2/' is from 'dart:io'.
    child: _image != null ? Image.file(_image) : null,
    ^
    lib/screens/EditPostScreen.dart:155:46: Error: The argument type 'File/1/' can't be assigned to the parameter type
    'File/2/'.
  • 'File/1/' is from 'package:universal_io/src/io/file.dart'
    ('/D:/flutter/.pub-cache/hosted/pub.dartlang.org/universal_io-2.0.4/lib/src/io/file.dart').
  • 'File/2/' is from 'dart:io'.
    child: _image != null ? Image.file(File(_image.path)) : null,
@terrier989
Copy link
Member

Hi! Package universal_html has a test case for File and it runs without problems in browsers. Does your application (or some dependency) accidentally contain directive import 'package:universal_io/src/io/file.dart';?

@bcgreijnlautier
Copy link

Here's a workaround you can use for now (and maybe this will help lead you to the root cause @terrier989):

Explicitly define the data type for your File as dynamic, then pass it to Image.file(). Here's a working example of how I'm using it:

dynamic file = File(source.path);
provider = FileImage(file);

@myjinifuture
Copy link

myjinifuture commented Aug 10, 2021

There is a conflict between different file types.
(eg. mine was html and dart)
To resolve this import io package as

import 'dart: io' as i;

and declare file variable as

i.File imageFile;

@amr-eniou-3r
Copy link

I found the issue universal_io is working fine for me but Image.file is not universal so I used Image.memory( File(alternativeLocalImagePath).readAsBytesSync())

@am1tr0r
Copy link

am1tr0r commented Oct 29, 2021

Here's a workaround you can use for now (and maybe this will help lead you to the root cause @terrier989):

Explicitly define the data type for your File as dynamic, then pass it to Image.file(). Here's a working example of how I'm using it:

dynamic file = File(source.path); provider = FileImage(file);

@bcgreijnlautier not working for me . if I use dynamic type , I get this error "Expected a value of type 'File', but got one of type '_File'".
have anyone found a proper solution ?

@jbryanh
Copy link

jbryanh commented Jan 4, 2022

Perhaps this helps:

I am trying to convert my firebase project to a web app. The conflict is the universal file vs. the FirebaseStorage dart.io and the following is where I get stuck:

../../Developer/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_storage-10.0.5/lib/src/reference.dart:128:52: Error: The argument type 'File/*1*/' can't be assigned to the parameter type 'File/*2*/'.
 - 'File/*1*/' is from 'package:universal_io/src/io/file.dart' ('../../Developer/flutter/.pub-cache/hosted/pub.dartlang.org/universal_io-2.0.4/lib/src/io/file.dart').
 - 'File/*2*/' is from 'dart:io'.
    return UploadTask._(storage, _delegate.putFile(file, metadata));

My import is import 'package:universal_io/io.dart';

@Joseph-Nathan
Copy link

same problem , any news ?

@jbryanh
Copy link

jbryanh commented Mar 28, 2022

Assuming you are using XFile, there is a bug in fromData as documented here. That was the cause of my error, not related to universal_io

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants