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

[Bug]: illegal cast in device_info_plus when compiled to Wasm #3253

Open
8 tasks done
arnaudruffin opened this issue Sep 12, 2024 · 0 comments · May be fixed by #3254
Open
8 tasks done

[Bug]: illegal cast in device_info_plus when compiled to Wasm #3253

arnaudruffin opened this issue Sep 12, 2024 · 0 comments · May be fixed by #3254
Labels
bug Something isn't working triage

Comments

@arnaudruffin
Copy link

Platform

web in asm mode

Plugin

device_info_plus

Version

10.1.2

Flutter SDK

3.24.2 (stable)

Steps to reproduce

use device_info_plus in a project compile for webasm. It compiles, but on the execution you got illegal cast errors.

  1. compile to wasm (see https://docs.flutter.dev/platform-integration/web/wasm for details)
    flutter build web --wasm --no-strip-wasm
  2. serve the result
cd build/web
dhttpd '--headers=Cross-Origin-Embedder-Policy=credentialless;Cross-Origin-Opener-Policy=same-origin'
  1. open the app in your browser and check its console

Code Sample

void main() async {
  final BaseDeviceInfo deviceInfo = await DeviceInfoPlugin().deviceInfo;
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return Container();
  }
}

Logs

Webasm can't run in flutter -run --verbose. This log is from the web browser.

main.dart.wasm:0x41ed24 Uncaught RuntimeError: illegal cast
    at DeviceInfoPlusWebPlugin.deviceInfo (main.dart.wasm:0x41ed24)
    at DeviceInfoPlugin.webBrowserInfo inner (main.dart.wasm:0x41e9ed)
    at DeviceInfoPlugin.deviceInfo inner (main.dart.wasm:0x41e8cf)
    at run inner (main.dart.wasm:0x23551b)
    at _awaitHelperWithTypeCheck closure at org-dartlang-sdk:///dart-sdk/lib/_internal/wasm/lib/async_patch.dart:97:16 (main.dart.wasm:0x233ee2)
    at closure wrapper at org-dartlang-sdk:///dart-sdk/lib/_internal/wasm/lib/async_patch.dart:97:16 trampoline (main.dart.wasm:0x233f4a)
    at _RootZone.runUnary (main.dart.wasm:0x1e0c26)
    at _Future._propagateToListeners (main.dart.wasm:0x1e0565)
    at _Future._completeWithValue (main.dart.wasm:0x1e019c)
    at _Future._asyncCompleteWithValue closure at org-dartlang-sdk:///dart-sdk/lib/async/future_impl.dart:735:29 (main.dart.wasm:0x1e0147)

Flutter Doctor

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.24.2, on macOS 14.6.1 23G93 darwin-arm64, locale fr-FR)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2024.1)
[✓] IntelliJ IDEA Ultimate Edition (version 2024.2.1)
[✓] VS Code (version 1.93.0)
[✓] VS Code (version 1.92.0-insider)
[✓] Connected device (3 available)
[✓] Network resources

Checklist before submitting a bug

  • I searched issues in this repository and couldn't find such bug/problem
  • I Google'd a solution and I couldn't find it
  • I searched on StackOverflow for a solution and I couldn't find it
  • I read the README.md file of the plugin
  • I'm using the latest version of the plugin
  • All dependencies are up to date with flutter pub upgrade
  • I did a flutter clean
  • I tried running the example project
@arnaudruffin arnaudruffin added bug Something isn't working triage labels Sep 12, 2024
arnaudruffin added a commit to arnaudruffin/plus_plugins that referenced this issue Sep 12, 2024
@arnaudruffin arnaudruffin linked a pull request Sep 12, 2024 that will close this issue
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant