@Kars mentioned that we need delayed() after query(). In my case, I needed delayed() BFFORE query().
final connection = await MySqlConnection.connect(new ConnectionSettings(
host: 'localhost',
port: 3306,
user: 'u1',
password: 'p2',
db: 'db_temp',
));
await Future.delayed(Duration(seconds: 2)); // need this
var results = await connection.query('select * from roles');
print(results);
for (var row in results) {
print('${row[0]}');
}
// Finally, close the connection
await connection.close();