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

Compiler error in Android/iOS(DartVM) #10

Closed
abc873693 opened this issue May 13, 2020 · 4 comments
Closed

Compiler error in Android/iOS(DartVM) #10

abc873693 opened this issue May 13, 2020 · 4 comments

Comments

@abc873693
Copy link

I want to use both image_picker and image_picker_web.
It work in flutter web.
But native platform error.

Compiler message:
../../../development/flutter/.pub-cache/hosted/pub.dartlang.org/image_picker_web-1.0.8/lib/image_picker_web.dart:6:8: Error: Not found: 'dart:html'
import 'dart:html' as html;
       ^

../../../development/flutter/.pub-cache/hosted/pub.dartlang.org/image_picker_web-1.0.8/lib/src/web_image_picker.dart:2:8: Error: Not found: 'dart:html'

import 'dart:html' as html;

       ^

../../../development/flutter/.pub-cache/hosted/pub.dartlang.org/http-0.12.1/lib/src/browser_client.dart:6:8: Error: Not found: 'dart:html'

import 'dart:html';

       ^

../../../development/flutter/.pub-cache/hosted/pub.dartlang.org/image_picker_web-1.0.8/lib/image_picker_web.dart:32:10: Error: Type 'html.File' not found.

  Future<html.File> _pickFile(String type) async {

         ^^^^^^^^^

../../../development/flutter/.pub-cache/hosted/pub.dartlang.org/http-0.12.1/lib/src/browser_client.dart:34:18: Error: 'HttpRequest' isn't a type.

  final _xhrs = <HttpRequest>{};

                 ^^^^^^^^^^^
Running pod install...                                              2.8s
Building macOS application...
../../../development/flutter/.pub-cache/hosted/pub.dartlang.org/image_picker_web-1.0.8/lib/image_picker_web.dart:33:16: Error: 'FileUploadInputElement' isn't a type.
    final html.FileUploadInputElement input = html.FileUploadInputElement();
               ^^^^^^^^^^^^^^^^^^^^^^
../../../development/flutter/.pub-cache/hosted/pub.dartlang.org/image_picker_web-1.0.8/lib/image_picker_web.dart:33:47: Error: Method not found: 'FileUploadInputElement'.
    final html.FileUploadInputElement input = html.FileUploadInputElement();
                                              ^^^^^^^^^^^^^^^^^^^^^^
../../../development/flutter/.pub-cache/hosted/pub.dartlang.org/image_picker_web-1.0.8/lib/src/web_image_picker.dart:7:16: Error: 'FileUploadInputElement' isn't a type.
    final html.FileUploadInputElement input = html.FileUploadInputElement();
               ^^^^^^^^^^^^^^^^^^^^^^
../../../development/flutter/.pub-cache/hosted/pub.dartlang.org/image_picker_web-1.0.8/lib/src/web_image_picker.dart:7:47: Error: Method not found: 'FileUploadInputElement'.
    final html.FileUploadInputElement input = html.FileUploadInputElement();
                                              ^^^^^^^^^^^^^^^^^^^^^^
../../../development/flutter/.pub-cache/hosted/pub.dartlang.org/image_picker_web-1.0.8/lib/src/web_image_picker.dart:12:20: Error: Method not found: 'FileReader'.
    final reader = html.FileReader();
                   ^^^^^^^^^^
../../../development/flutter/.pub-cache/hosted/pub.dartlang.org/image_picker_web-1.0.8/lib/src/web_image_picker.dart:28:16: Error: 'FileUploadInputElement' isn't a type.
    final html.FileUploadInputElement input = html.FileUploadInputElement();
               ^^^^^^^^^^^^^^^^^^^^^^
../../../development/flutter/.pub-cache/hosted/pub.dartlang.org/image_picker_web-1.0.8/lib/src/web_image_picker.dart:28:47: Error: Method not found: 'FileUploadInputElement'.
    final html.FileUploadInputElement input = html.FileUploadInputElement();
                                              ^^^^^^^^^^^^^^^^^^^^^^
../../../development/flutter/.pub-cache/hosted/pub.dartlang.org/image_picker_web-1.0.8/lib/src/web_image_picker.dart:33:20: Error: Method not found: 'FileReader'.
    final reader = html.FileReader();
                   ^^^^^^^^^^
../../../development/flutter/.pub-cache/hosted/pub.dartlang.org/http-0.12.1/lib/src/browser_client.dart:58:34: Error: 'Blob' isn't a type.
      var blob = xhr.response as Blob ?? Blob([]);
                                 ^^^^
../../../development/flutter/.pub-cache/hosted/pub.dartlang.org/http-0.12.1/lib/src/browser_client.dart:46:15: Error: The method 'HttpRequest' isn't defined for the class 'BrowserClient'.
 - 'BrowserClient' is from 'package:http/src/browser_client.dart' ('../../../development/flutter/.pub-cache/hosted/pub.dartlang.org/http-0.12.1/lib/src/browser_client.dart').
Try correcting the name to the name of an existing method, or defining a method named 'HttpRequest'.
    var xhr = HttpRequest();
              ^^^^^^^^^^^
../../../development/flutter/.pub-cache/hosted/pub.dartlang.org/http-0.12.1/lib/src/browser_client.dart:58:42: Error: The method 'Blob' isn't defined for the class 'BrowserClient'.
 - 'BrowserClient' is from 'package:http/src/browser_client.dart' ('../../../development/flutter/.pub-cache/hosted/pub.dartlang.org/http-0.12.1/lib/src/browser_client.dart').
Try correcting the name to the name of an existing method, or defining a method named 'Blob'.
      var blob = xhr.response as Blob ?? Blob([]);
                                         ^^^^
../../../development/flutter/.pub-cache/hosted/pub.dartlang.org/http-0.12.1/lib/src/browser_client.dart:59:20: Error: The method 'FileReader' isn't defined for the class 'BrowserClient'.
 - 'BrowserClient' is from 'package:http/src/browser_client.dart' ('../../../development/flutter/.pub-cache/hosted/pub.dartlang.org/http-0.12.1/lib/src/browser_client.dart').
Try correcting the name to the name of an existing method, or defining a method named 'FileReader'.
      var reader = FileReader();
                   ^^^^^^^^^^
../../../development/flutter/packages/flutter_web_plugins/lib/src/plugin_registry.dart:29:5: Error: Method not found: 'webOnlySetPluginHandler'.
    ui.webOnlySetPluginHandler(_binaryMessenger.handlePlatformMessage);
    ^^^^^^^^^^^^^^^^^^^^^^^

@Ahmadre
Copy link
Owner

Ahmadre commented May 14, 2020

Hi thanks for raising your issue.

This is not an error, it's a Flutter thing.

But there's a solution like Rody Davis is also using for handling cross-platform functionalities in one project: Just use this:

https://pub.dev/packages/universal_html

instead of Flutter's html package and your errors should be gone.

Closing this, because it's not related to this package. For further questions raise an issue on Flutter Framework.

Best regards

@Ahmadre Ahmadre closed this as completed May 14, 2020
@parammittal162
Copy link

@abc873693 @Ahmadre can you please help me out by providing any reference or link in which both plugins have been used with UNIVERSAL HTML package.

Or maybe you have used it ....

@Ahmadre
Copy link
Owner

Ahmadre commented May 28, 2020

We have good news for you: flutter/plugins#2767

Official image_picker for web will come soon. You can link to that pr if you want to use it in early stage.

@parammittal162
Copy link

Thanks a lot @Ahmadre

TesteurManiak added a commit that referenced this issue Apr 3, 2021
removed futureOr and added nullcheck
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

3 participants