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

InAppLocalhostServer - Error: type 'List<dynamic>' is not a subtype of type 'List<int>' in type cast #724

Closed
demchiva opened this issue Mar 15, 2021 · 2 comments

Comments

@demchiva
Copy link

demchiva commented Mar 15, 2021

Hi, when i call this code

flutter_inappwebview: ^5.1.0+4
final InAppLocalhostServer localhostServer = InAppLocalhostServer();

@override
  void initState() {
    super.initState();
    startServer();
  }

void startServer() async {
    await localhostServer.start();
  }

I get this error.

 #0      InAppLocalhostServer.start.<anonymous closure>.<anonymous closure>.<anonymous closure> (package:flutter_inappwebview/src/in_app_localhost_server.dart:42:25)
 #1      InAppLocalhostServer.start.<anonymous closure>.<anonymous closure>.<anonymous closure> `(package:flutter_inappwebview/src/in_app_localhost_server.dart:41:23)`
 #2      _rootRunUnary (dart:async/zone.dart:1362:47)
 #3      _CustomZone.runUnary (dart:async/zone.dart:1265:19)
 #4      _CustomZone.runUnaryGuarded (dart:async/zone.dart:1170:7)
 #5      _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341:11)
 #6      _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
 #7      _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:733:19)
 #8      _StreamController._add (dart:async/stream_controller.dart:607:7)
 #9      _StreamController.add (dart:async/stream_controller.dart:554:5)
 #10     _HttpServer._handleRequest (da

flutter doctor

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 2.0.1, on Microsoft Windows [Version 10.0.18363.1377], locale ru-RU)
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
[√] Chrome - develop for the web
[√] Android Studio (version 4.1.0)
[√] IntelliJ IDEA Community Edition (version 2018.3)
[√] VS Code (version 1.51.1)
[√] Connected device (2 available)

• No issues found!

with version flutter_inappwebview: ^4.0.0+4 it works correct.

Thanks for your time.

@demchiva
Copy link
Author

When i change line 42

var body = [] as List<int>;

in file in_app_localhost_server.dart to line

List<int> body = [];

it is fix the problem.

@ritterdn
Copy link

This change got us past the error and allowed us to load an html file downloaded from the web and access local css/js/imgs from the project's assets directory. So we're back in business, highly recommend this fix, thanks demchiva!

@pichillilorenzo pichillilorenzo changed the title Error: type 'List<dynamic>' is not a subtype of type 'List<int>' in type cast InAppLocalhostServer - Error: type 'List<dynamic>' is not a subtype of type 'List<int>' in type cast Mar 18, 2021
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

2 participants