xvrh / puppeteer-dart

A Dart library to automate the Chrome browser over the DevTools Protocol. This is a port of the Puppeteer API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Connecting via websocket throws an error because of missing map entry

Wizzel1 opened this issue · comments

I am trying to connect to a brightdata scrapingbrowser but because the object I am recieving does not contain the "params" entry, an exception gets thrown.

Unbenannt

Something as simple as: (object['params'] ?? {}) as Map<String, dynamic> could unblock you?

I prefer you submit the pull request yourself once you have validated that it really works for you.

I guess that should fix it. I wasn't sure if that could have any sideeffects so I wanted to hear your opinion first.

I don't think it could break anything. It's just a bit suspicious and probably means that there is other subtle differences like that.

I tried what you suggested but now I am getting another error :
type '_Map<dynamic, dynamic>' is not a subtype of type 'Map<String, dynamic>' in type cast in the same line. Any idea why?

My fault! The line should have been:

      _eventController.add(Event._(object['method'] as String,
          (object['params']) as Map<String, dynamic>? ?? {}));

Yes that seems to work thanks. Looks like I already created a PR :D