mysql1_dart
mysql1_dart copied to clipboard
Unhandled Exception: Invalid argument(s): Illegal length 0
when i try to make a simple select, the app lauchs this exception:
E/flutter (11252): [ERROR:flutter/lib/ui/ui_dart_state.cc(166)] Unhandled Exception: Invalid argument(s): Illegal length 0
E/flutter (11252): #0 _NativeSocket.read (dart:io-patch/socket_patch.dart:819:7)
E/flutter (11252): #1 _RawSocket.read (dart:io-patch/socket_patch.dart:1614:22)
E/flutter (11252): #2 Buffer.readFromSocket (package:mysql1/src/buffer.dart:48:30)
E/flutter (11252): #3 BufferedSocket._readBuffer (package:mysql1/src/buffered_socket.dart:178:36)
E/flutter (11252): #4 BufferedSocket._onData (package:mysql1/src/buffered_socket.dart:93:9)
E/flutter (11252): #5 _rootRunUnary (dart:async/zone.dart:1206:13)
E/flutter (11252): #6 _CustomZone.runUnary (dart:async/zone.dart:1100:19)
E/flutter (11252): #7 _CustomZone.runUnaryGuarded (dart:async/zone.dart:1005:7)
E/flutter (11252): #8 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:357:11)
E/flutter (11252): #9 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:285:7)
E/flutter (11252): #10 _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:808:19)
E/flutter (11252): #11 _StreamController._add (dart:async/stream_controller.dart:682:7)
E/flutter (11252): #12 _StreamController.add (dart:async/stream_controller.dart:624:5)
E/flutter (11252): #13 new _RawSocket.<anonymous closure> (dart:io-patch/socket_patch.dart:1556:33)
E/flutter (11252): #14 _NativeSocket.issueReadEvent.issue (dart:io-patch/socket_patch.dart:1052:14)
E/flutter (11252): #15 _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
E/flutter (11252): #16 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
E/flutter (11252):
this is the function that makes the query (I call that function in a FutureBuilder in flutter):
Future<bool> askPlacaTurno(String idServicio)async{
var conexion = await conectarse();
var res = await conexion.query("select placa from servicios where id = ?", [idServicio]);
bool usaPlaca = false;
for(var row in res){
usaPlaca = row[0] == 'on' ? true : false;
}
return usaPlaca;
}
the connection and close connection functions:
Future conectarse() async{
final conexion = await MySqlConnection.connect(ConnectionSettings(
host: "192.168.0.18",
port: 3306,
user: "root",
password: '',
db: "gobernacion"
)
);
print("conectado a la base de datos");
return conexion;
}
Future desconectarse(MySqlConnection conexion) async{
await conexion.close();
}
I think the correct query method should be:
var res = await conexion.query("select placa from servicios where id = ?", idServicio);
idServicio without the brackets.