问题
I am trying to connect dart with a MySQL database. I installed the MySQL workbench and created a simple DB, have modified the pubspec.yaml and added any other dependencies I needed for MySQL. But I keep pulling up an exception in the browser.
EXCEPTION: Unsupported operation: RawSocket constructor STACKTRACE: dart:sdk_internal connect package:sqljocky5/comm/buffered_socket.dart 60:7 defaultSocketFactory package:sqljocky5/comm/buffered_socket.dart 72:20 connect dart:sdk_internal async package:sqljocky5/comm/buffered_socket.dart 70:6 connect package:sqljocky5/comm/comm.dart 163:26 connect dart:sdk_internal async package:sqljocky5/comm/comm.dart 156:53 connect package:sqljocky5/connection/impl.dart 102:22 connect dart:sdk_internal async package:sqljocky5/connection/impl.dart 101:64 connect package:sqljocky5/connection/connection.dart 36:7 connect package:pbcat_form/src/start/start.dart 84:22 main dart:sdk_internal async package:pbcat_form/src/start/start.dart 75:10 main package:angular/src/core/zone/ng_zone.dart 134:16 dart:sdk_internal run package:angular/src/core/zone/ng_zone.dart 131:12 [_run] dart:sdk_internal runGuarded package:angular/src/core/zone/ng_zone.dart 302:22 runGuarded package:angular/src/core/linker/app_view.dart 582:7 package:sqljocky5/comm/buffered_socket.dart 70:6 connect package:sqljocky5/comm/comm.dart 163:26 connect dart:sdk_internal async package:sqljocky5/comm/comm.dart 156:53 connect package:sqljocky5/connection/impl.dart 102:22 connect dart:sdk_internal async package:sqljocky5/connection/impl.dart 101:64 connect package:sqljocky5/connection/connection.dart 36:7 connect package:pbcat_form/src/start/start.dart 84:22 main dart:sdk_internal async package:pbcat_form/src/start/start.dart 75:10 main package:angular/src/core/zone/ng_zone.dart 134:16 dart:sdk_internal run package:angular/src/core/zone/ng_zone.dart 131:12 [_run] dart:sdk_internal runGuarded package:angular/src/core/zone/ng_zone.dart 302:22 runGuarded package:angular/src/core/linker/app_view.dart 582:7
回答1:
The code seems to be doing this :-
RawSocket.connect(host, port);
However there is no connect method on RawSocket, see here
This may have changed in Dart 2.2, the get/set RawOption methods have been added for instance
回答2:
https://api.dart.dev/stable/2.2.0/dart-io/RawSocket/connect.html
external static Future connect(host, int port, {sourceAddress, Duration timeout});
来源:https://stackoverflow.com/questions/54933232/exception-unsupported-operation-rawsocket-constructor-dart-with-sqljocky5-2