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

Unhandled Exception error: type 'SocketException' is not a subtype of type 'bool #18

Closed
jkarelbroer opened this issue Jun 26, 2019 · 1 comment
Labels
needinfo This issue does not have enough information to action

Comments

@jkarelbroer
Copy link

jkarelbroer commented Jun 26, 2019

Hi,

Thanks for providing this useful package!

The connection works fine on a local MySQL db (with MAMP), but when trying to connect to an external MySQL database, the connection fails and I receive the error listed below.
Any idea what this error means?

` Future getData({String sql, List args}) async {
String sqlStatement = sql ?? 'select ID, name, email from mytable ';
List arguments = args ?? [];
MySqlConnection connection;
var settings = ConnectionSettings(
host: '000.00.000.000',
port: 0000,
user: 'myuser',
password: 'mypassword',
db: 'mydb');

try {
  connection = await MySqlConnection.connect(settings);
} catch (e) {
  if (e) {
    print(e);
    return;
  }
}

var results = await connection.query(sqlStatement, arguments);
if (results.length > 0) {
  for (var row in results) {
    print('ID: ${row[0]}, name: ${row[1]}, email: ${row[2]}');
  }
}
await connection.close();

}`

[VERBOSE-2:ui_dart_state.cc(148)] Unhandled Exception: type 'SocketException' is not a subtype of type 'bool' #0 MySQLCon.getData (package:brov_research_app/components/database.dart:18:11) <asynchronous suspension> #1 _MyHomePageState.build.<anonymous closure> (package:brov_research_app/main.dart:56:22) #2 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:511:14) #3 _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:566:30) #4 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:166:24) #5 TapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:240:9) #6 TapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:211:7) #7 GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:156:27) #8 _WidgetsFlutterBinding&BindingBase&GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:225:20) #9 _WidgetsFlutterBinding&Bind<…>

@adamlofts
Copy link
Owner

if (e) { is not valid dart.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needinfo This issue does not have enough information to action
Projects
None yet
Development

No branches or pull requests

2 participants